LDAP Query

Aspnot

Active member
Joined
Feb 24, 2004
Messages
37
I am writing a utility that needs to query AD and return back to me all sub-OUs of the OU passed in. However, I would like to be able to load this information into a Treeview with the results of only one query. (The DC I will be querying is across my WAN connection.)

I can use the following code:

Code:
    Dim adsRoot As New DirectoryEntry("LDAP://OU=SourceOU,DC=myDomain,DC=com")
    Dim adsSearch As New DirectorySearcher(adsRoot, "(&(objectClass=organizationalUnit))")
    Dim result As SearchResult

    Try
      For Each result In adsSearch.FindAll()
        ????????
      Next
    Catch ex As Exception
      Debug.WriteLine(ex.Message)
    End Try

The problem I have here is that I cannot see the Children of a given result object. I can use result.GetDirectoryEntry().Children to return back access to a DirectoryEntries collection. But, from what I can tell, this makes another query back to the DC.

The only solution I can see is to parse out the result.Path. That would be painful and there has to be a better way.

Any assistance would be greatly appreciated!!
 
Back
Top