LDAP Directory Entry in .Net - not working with OU=Users

后端 未结 3 1138
庸人自扰
庸人自扰 2020-12-10 07:54

I have the following code (C#):

(Tweaked from: http://www.eggheadcafe.com/conversation.aspx?messageid=31766061&threadid=31766050)

DirectorySearcher         


        
3条回答
  •  心在旅途
    2020-12-10 08:20

    As geoffc mentioned correctly, in Active Directory the "Users" under the domain is a container object rather than organizational unit object. This results in a totally different LDAP path which is why you get the error message.

    Try the following code and post if it fixes your issue:

    // Replace the "company" and "com" with actual domain values...
    DirectoryEntry de = new DirectoryEntry("LDAP://CN=Users,DC=company,DC=com");
    DirectorySearcher deSearch = new DirectorySearcher();
    deSearch.SearchRoot = de;
    
    // Set your other search params here
    

提交回复
热议问题