error on query of nested folder RRS feed

  • Question

  • User1559438460 posted

    I can query a folder nested 1 deep for example, this works fine

    Dim searchRoot As New DirectoryEntry(LDAP:///OU=DistributionGroups,dc=x,dc=y,dc=z, "admin", "pass", AuthenticationTypes.Secure)

    But if i change the OU to a folder nested two deep it errors

    Dim searchRoot As New DirectoryEntry(LDAP:///OU=DistributionGroups/Group-1,dc=x,dc=y,dc=z, "admin", "pass", AuthenticationTypes.Secure.

    And the folder does exist, the error i get is meaningless

    is this the proper syntax for a nested folder?

    Monday, June 19, 2006 7:06 AM

All replies

  • User1354132231 posted
    You just have your syntax wrong.  Think of LDAP paths as going from deepest to shallowest always (the reverse of a C:\ file structure).  Hence, it would be:

    OU=Child,OU=Parent,OU=Parent Parent Etc,DC=domain,DC=com
    Monday, June 19, 2006 1:41 PM
  • User1559438460 posted

    Thank you for your reply but I'm still lost

    So if i have LDAP working with this query

    Dim searchRoot As New DirectoryEntry(LDAP://111.111.111/OU=DistributionGroups,dc=x,dc=y,dc=z, "username", "pass", AuthenticationTypes.Secure)


    now in AD there is a sub folder within DistributionGroups called "group1" now how do i search just that folder for records, my problem is with specifing the subfolder to search


    my full code is below

    Dim searchRoot As New DirectoryEntry(LDAP://111.111.111/OU=DistributionGroups,dc=x,dc=y,dc=z, "username", "pass", AuthenticationTypes.Secure)

    Dim ds As New DirectorySearcher(searchRoot)

    ds.PageSize = 1000 'enable paging for large queries

    Dim sr As SearchResult

    Dim ResultFields() As String = {"name"}


    Dim src As SearchResultCollection = ds.FindAll()

    Dim srccount = src.Count

    Dim groups As New DataSet

    Dim dt As New DataTable

    dt.Columns.Add(New DataColumn("name"))

    Dim dr As DataRow

    Dim k As String

    If srccount > 0 Then

    For Each sr In src

    dr = dt.NewRow()

    If Not sr Is Nothing Then

    dr("name") = sr.Properties("name")(0)


    End If


    End If



    Thanks a mil in advance

    Friday, June 23, 2006 6:15 AM
  • User1354132231 posted
    Be careful of your terms here.  Is 'group1' a container or a group object in AD?  If it is a container or organizationalUnit, you can specify it as your search root the way I mentioned before.  Simply add it to the left-most portion of the string:


    The reason I put the 'or' there is because you might be mixing your terminology.  We have container in AD from a 'container' class that start with CN={nameofcontainer} and we have another type of container from an organizationalUnit class that starts with OU={nameofcontainer}

    Now, if 'group1' is actually a group object and you are looking to search within the object for its members, we are talking about something completely different here and you are looking in the wrong direction.
    Friday, June 23, 2006 9:23 AM
  • User1559438460 posted

    That clears everything up dunnry thank you for your quick response and examples on the form


    Friday, June 23, 2006 10:22 AM