簡體   English   中英

使用DirectoryServices.AccountManagement訪問initials字段

[英]accessing the initials field using the DirectoryServices.AccountManagement

我是新手訪問Active Directory,我被建議使用System.DirectoryServices.AccountManagement但我找不到任何幫助的initials變量?

你可以做其中一件事:

1)您可以擴展正常的UserPrincipal類以包含您經常需要的其他項目。 這確實是最干凈的解決方案。 有關如何使用其他屬性擴展UserPrincipal類的示例,請參閱有關擴展用戶主體MSDN文檔 ,或回答此SO問題

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();
       }
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM