Active Directory Help

brother_x

New member
Joined
Aug 14, 2003
Messages
1
Im trying to figure out how to use the DirectoryEntry class to retrieve a list of users in a domain. I have this working for a NT server and exchange 5.5 using

LDAP://server/cn=recipients,ou=unit,o=org

Can anyone help me with something similar for a windows 2000/2003 Active Directory.

Thanks In Advance,
Bri
 
I did it like this to lookup users by parts of the first and last names:

dim strLDAP as string = LDAP://server:389

Dim rootEntry As New DirectoryEntry(strLDAP )
Dim searcher As New DirectorySearcher(rootEntry)

searcher.PropertiesToLoad.Add("cn")
searcher.PropertiesToLoad.Add("mail")
searcher.PropertiesToLoad.Add("telephoneNumber")
searcher.PropertiesToLoad.Add("department")

searcher.ServerTimeLimit = New TimeSpan(0, 1, 0)
searcher.Filter = String.Concat("(&(sn=", txtLastName.Trim, "*)(givenName=", txtFirstName.Trim, "*)(objectClass=user)(objectCategory=person))")

searcher.Sort.PropertyName = "cn"
Dim results As SearchResultCollection
results = searcher.FindAll()

Dim result As SearchResult
For Each result In results
....<<DO SOMETHING WITH THE RESULTS>>
Next
 
Back
Top