4
我是新來訪問Active Directory,我被建議使用System.DirectoryServices.AccountManagement
,但我找不到initials
變量的任何幫助?訪問使用DirectoryServices.AccountManagement的縮寫字段
我是新來訪問Active Directory,我被建議使用System.DirectoryServices.AccountManagement
,但我找不到initials
變量的任何幫助?訪問使用DirectoryServices.AccountManagement的縮寫字段
你可以做的事情之一:
1)你可以延長正常UserPrincipal
類,包括您經常需要額外的物品。這真的是最乾淨的解決方案。見MSDN docs on extending the user principal,或answer to this SO question對於如何擴展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();
}
}
謝謝你的回覆,我希望我可以投你的答案,但我沒有足夠的聲望呢:( –
沒有注意到,做:) –
@ShehabFawzy:謝謝!這也給了你兩個額外的聲望點:-) –