Populate ComboBox from AD Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to populate a ComboBox on Form.load with a list of the OU's pulled
from AD. Here is the code that does not work:

Dim rootdir As New System.DirectoryServices.DirectoryEntry _
("LDAP://dc=corp,dc=abc,dc=com")
Dim rootsearch As New
System.DirectoryServices.DirectorySearcher(rootdir)
Dim result As System.DirectoryServices.SearchResult
rootsearch.SearchScope = DirectoryServices.SearchScope.Subtree
rootsearch.Filter = ("(objectClass = organizational Unit)")
For Each result In rootsearch.FindAll()
ComboBox2.Items.Add(result.GetDirectoryEntry)
Next

Any help would be greatly appreciated.....

Thanks
 
Did you try with objectClass=organizationalUnit (no space between
organizational and Unit)?

I'm trying to populate a ComboBox on Form.load with a list of the OU's
pulled
from AD. Here is the code that does not work:

Dim rootdir As New System.DirectoryServices.DirectoryEntry _
("LDAP://dc=corp,dc=abc,dc=com")
Dim rootsearch As New
System.DirectoryServices.DirectorySearcher(rootdir)
Dim result As System.DirectoryServices.SearchResult
rootsearch.SearchScope = DirectoryServices.SearchScope.Subtree
rootsearch.Filter = ("(objectClass = organizational Unit)")
For Each result In rootsearch.FindAll()
ComboBox2.Items.Add(result.GetDirectoryEntry)
Next

Any help would be greatly appreciated.....

Thanks
 
Back
Top