Error 0x80005000 and DirectoryServices

后端 未结 13 1978

I\'m trying to run a simple LDAP query using directory services in .Net.

    DirectoryEntry directoryEntry = new DirectoryEntry(\"LDAP://someserver.contoso.c         


        
13条回答
  •  北荒
    北荒 (楼主)
    2020-11-29 05:01

    I had to change my code from this:

     DirectoryEntry entry = new DirectoryEntry(path, ldapUser, ldapPassword);
     DirectorySearcher searcher = new DirectorySearcher();
     searcher.SearchRoot = entry;
     searcher.SearchScope = SearchScope.Subtree;
    

    To this:

    DirectoryEntry entry = new DirectoryEntry(path, ldapUser, ldapPassword);
    DirectorySearcher searcher = new DirectorySearcher();
    searcher.SearchScope = SearchScope.OneLevel;
    SearchResult searchResult = searcher.FindOne();
    

提交回复
热议问题