User-508806111 posted
Here is a sample code with comments to retrieve appropriate fields:
Dim oroot As DirectoryEntry = New DirectoryEntry("LDAP://YOURACTIVEDIRECTORY", "USERNAME-ADMIN, "PASSWORD")
Dim osearcher As DirectorySearcher = New DirectorySearcher(oroot)
Dim oresult As SearchResultCollection
Dim result As SearchResult
osearcher.Filter = "(&(objectCategory=person))" ' search filter
osearcher.PropertiesToLoad.Add("cn") ' username
osearcher.PropertiesToLoad.Add("name") ' full name
osearcher.PropertiesToLoad.Add("givenname") ' firstname
osearcher.PropertiesToLoad.Add("sn") ' lastname
osearcher.PropertiesToLoad.Add("mail") ' mail
osearcher.PropertiesToLoad.Add("initials") ' initials
osearcher.PropertiesToLoad.Add("ou") ' organizational unit
osearcher.PropertiesToLoad.Add("userPrincipalName") ' login name
osearcher.PropertiesToLoad.Add("distinguishedName") ' distinguised name
oresult = osearcher.FindAll()
For Each result In oresult
If Not result.GetDirectoryEntry.Properties("sn").Value Is Nothing Then
' writes specific values retrieved from above - this is just a sample.
response.write(result.GetDirectoryEntry.Properties("cn").Value & ":" & result.GetDirectoryEntry.Properties("userPrincipalName").Value)
End If
Next
hope this helps.
Jae.