She*_*wzy 4 .net active-directory account-management
我是新手访问Active Directory,我被建议使用,System.DirectoryServices.AccountManagement但我找不到initials变量任何帮助?
你可以做其中一件事:
1)您可以扩展普通UserPrincipal类以包含您经常需要的其他项目.这确实是最干净的解决方案.有关如何使用其他属性扩展类的示例,请参阅有关扩展用户主体的MSDN文档,或回答此SO问题UserPrincipal
2)您可以"深入"到底层的深处DirectoryEntry并从那里获取数据:
DirectoryEntry de = YourUserPrincipal.GetUnderlyingObject() as DirectoryEntry;
if(de != null)
{
var initials = de.Properties["initials"];
if(initials != null && initials.Count > 0)
{
string theInitials = de.Properties["initials"][0].ToString();
}
}
Run Code Online (Sandbox Code Playgroud)