Why is DirectorySearcher so slow when compared to PrincipalSearcher?

后端 未结 2 1288
星月不相逢
星月不相逢 2021-01-05 15:24

Our application has a process which fetches all users from Active Directory and updates the relevant SQL tables with their information. The process at nights and it was writ

2条回答
  •  醉梦人生
    2021-01-05 15:44

    While writing this question I was tinkering with the test code and managed to find the issue. By providing the domain address when constructing the root DirectoryEntry:

    // var root = new DirectoryEntry("LDAP://DC=mydomain,DC=com");
    var root = new DirectoryEntry("LDAP://mydomain.com/DC=mydomain,DC=com");
    

    The search with DirectorySearcher outperformed that of PrincipalSearcher. I'm not exactly sure why - perhaps it's something to do with where the searcher looks for the results - but it definitely boosted the search speed.

提交回复
热议问题