aru*_*lam 2 c# active-directory
我有这个代码,我可以在Active Directory中更改显示名称,密码等
UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(principalContext, userName);
userPrincipal.DisplayName = "Some NAME";
userPrincipal.SetPassword("NEW_PASSWORD");
userPrincipal.Save();
Run Code Online (Sandbox Code Playgroud)
我查看了userPrincipal的属性,但找不到电话号码属性.我的问题是如何在代码中更改用户的电话号码.
谢谢
更正(对不起所有编辑):
这就是我做的......
public static void SetUserInfo(string userName)
{
var dsDirectoryEntry = new DirectoryEntry("LDAP://xxxx/DC=xx,DC=xxx", "ADusername", "ADpassword");
var dsSearch = new DirectorySearcher(dsDirectoryEntry) { Filter = "(&(objectClass=user)(SAMAccountName=" + userName + "))" };
var dsResults = dsSearch.FindOne();
var myEntry = dsResults.GetDirectoryEntry();
//myEntry.Properties[property].Value = value;
myEntry.Properties["telephoneNumber"].Value = "222-222-2222";
myEntry.CommitChanges();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3687 次 |
| 最近记录: |