DirectoryEntry constraint RRS feed

  • Question

  • User1453549677 posted



    Use of the DirectoryEntry line below doesn't yield a count (no results). When I use the one below it that's been commented out (without the objCategory constraint), the results are 608 - I get entries. I'm wondering why it doesn't like the constraint.





    // Bind to the users container.


    //DirectoryEntry entry = new DirectoryEntry("LDAP://s0-dc01/OU=Navmar Users & Computers,DC=navmar,DC=com WHERE objectCategory='user'");



    DirectoryEntry entry = new DirectoryEntry("LDAP://s0-dc01/OU=Navmar Users & Computers,DC=navmar,DC=com");// Create a DirectorySearcher object.


    mySearcher.Filter =


    DirectorySearcher mySearcher = new DirectorySearcher(entry);"objectCategory= 'user'";// Create a SearchResultCollection object to hold a collection of SearchResults


    // returned by the FindAll method.



    SearchResultCollection result = mySearcher.FindAll();// Get search results. For more information, see Getting Search Results.


    // ...



    // Create an Exception object. For more information, see System.Exception.

    Label1.Text = result.Count.ToString();





    Also I just tried the .Filter method below instead of the constraint in the DirectoryEntry line. This time it does produce a result, however it's 0. I've used a VBScript to do something similar and their is data out there for users. So I'm not sure why the 0 result.

    entry = new DirectoryEntry("LDAP://s0-dc01/OU=Navmar Users & Computers,DC=navmar,DC=com");


    // Create a DirectorySearcher object.


    DirectorySearcher mySearcher = new DirectorySearcher(entry);




    mySearcher.Filter = "objectCategory= 'user'";


    Thursday, October 22, 2009 1:52 PM


  • User1453549677 posted


    I got it... I used:

    mySearcher.Filter =

    "(objectCategory= user)";


    Thanks everyone for your replies. LOL.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 23, 2009 11:34 AM