开发者

Odd result by using DirectorySearcher

I am using DirectorySearcher to get all AD users' display name from company AD server, we have around 100k records and most of results are correct.

But we got near 100 users' display name are "$CimsUserVersion2", it's really a odd result, I checked in outlook which also sync display name from AD, the name is correct

Have u facing same issue?

Thanks a lot

using (var de = new DirectoryEntry("LDAP://" + domain))
{
   using (var search = new DirectorySearcher(de))
   {
       search.Filter = "CN=" + userName;
       var results = search.FindAll();
       string temp = results[0].Properties["displayname"][0].ToString();

       if (string.IsNullOrEmpty(temp))
       {
          return string.Empty;
       }
       开发者_运维百科else
       {
          return temp;
       }
    }
}


Not sure if that's the problem - but I think you'd need to tell your searcher that you want the displayName attribute to be loaded:

using (var de = new DirectoryEntry("LDAP://" + domain))
{
   using (var search = new DirectorySearcher(de))
   {
       search.Filter = "CN=" + userName;
       search.PropertiesToLoad.Add("displayName");  // specify "displayname" to be returned from search

       var results = search.FindAll();

       string temp = results[0].Properties["displayname"][0].ToString();

       if (string.IsNullOrEmpty(temp))
       {
          return string.Empty;
       }
       else
       {
          return temp;
       }
    }
}


Don't you automate the provisioning of UNIX users and groups into Microsoft Active Directory with "Centrify DirectControl".

This tool uses a simple object model to manage the UNIX-specific properties for users, groups, computers, and zones, as well as UNIX NIS services.

As far as I understand it uses Active-Directory attributes to register some special informations.

UserVersion is map to displayName :

UserVersion determines compatibility between a user profile object and the Centrify DirectControl Administrator Console. The only valid value for this attribute is $CimsUserVersion2.

For example:

displayName: $CimsUserVersion2

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜