Mon*_*yak 22 c# directoryservices active-directory
我的意思是,现在我正在使用System.DirectoryServices.AccountManagement,如果我使用UserPrincipal类,我只看到名称,中间名等
所以在我的代码中它就像
UserPrincipal myUser = new UserPrincipal(pc);
myUser.Name = "aaaaaa";
myUser.SamAccountName = "aaaaaaa";
.
.
.
.
myUser.Save();
Run Code Online (Sandbox Code Playgroud)
我怎样才能看到像手机或信息这样的属性?
mar*_*c_s 25
在这种情况下,您需要DirectoryEntry从用户主体中获取更深层次 - 返回到更大的内容:
using (DirectoryEntry de = myUser.GetUnderlyingObject() as DirectoryEntry)
{
if (de != null)
{
// Go for those attributes and do what you need to do...
var mobile = de.Properties["mobile"].Value as string;
var info = de.Properties["info"].Value as string;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25393 次 |
| 最近记录: |