解决方案 »

  1.   

    方案二没写完整
            if (results != null)
            {
               DirectoryEntry userEntry = new DirectoryEntry(results.Path, LDAPUser, LDAPPassword);
               return new UserInfo(userEntry);
             }           UserInfo.name=...
               UserInfo.Tel=...
               ...
    实际上UserInfo里面的字段赋值都是通过
     public string GetPropertyValue(DirectoryEntry propertyEntry,string properties)
            {
                if (propertyEntry.Properties.Contains(properties))
                {
                    return propertyEntry.Properties[properties][0].ToString();
                }
                else
                {
                    return String.Empty;
                }
            }
      

  2.   

    UserPrincipal.Save():将对主体对象所做的更改保存到存储区中。 如果它是一个新主体对象,则此方法会将其插入到存储区中。 (继承自 Principal。)
      

  3.   


    PrincipalContext ctx = new PrincipalContext(
                                             ContextType.Domain,
                                             "fabrikam.com", 
                                             "CN=Users,DC=fabrikam,DC=com",
                                             "administrator", 
                                             "securelyStoredPassword"); UserPrincipal usr = new UserPrincipal(ctx);usr.Name = "Jim Daly";
    usr.Description = "This is the user account for Jim Daly";
    usr.EmailAddress = "[email protected]";
    usr.SetPassword("securelyStoredPassword");
    usr.Save();usr.Dispose();
    ctx.Dispose();
      

  4.   

    找到一个参考的文章:http://stackoverflow.com/questions/7408665/updating-name-field-on-userprincipal