无法取得' mobile' Active目录中的属性

时间:2015-07-14 03:59:33

标签: c# active-directory

以下代码工作正常。但它没有回归'移动'来自AD的属性。没有得到问题。它返回HomePhone和telephonenumber但不是' mobile'属性。但是当我通过代码更新它时它会得到更新。但无法阅读。

    DirectoryEntry de = createDirectoryEntry();

   DirectorySearcher deSearch = new DirectorySearcher(de);
   deSearch.PropertiesToLoad.Add("telephoneNumber");
   deSearch.PropertiesToLoad.Add("homePhone");
   deSearch.PropertiesToLoad.Add("mobile");

    //"userPrincipalName", "cn", "homePhone", "mobile", "telephoneNumber", "givenName", "sn"

    deSearch.SearchScope = SearchScope.Subtree;
    deSearch.Filter = "(&(objectCategory=User)(userPrincipalName=" + username + "))";
    SearchResultCollection results = deSearch.FindAll();

    foreach (SearchResult result in results)
    {
        ResultPropertyCollection props = result.Properties;
        foreach (string propName in props.PropertyNames)
        {
           //Loop properties and pick out company,department
           string tmp = (string)props[propName][0];
        }
    }

0 个答案:

没有答案