Dim oRoot As DirectoryEntry = New DirectoryEntry()
oRoot.Path = "LDAP://XXX.XXX.com/uid=XXX,ou=XXX,dc=XXXXX,dc=com"
oRoot.Password = "XXXXXXXXXXXXXX"
Dim oSearcher As DirectorySearcher = New DirectorySearcher(oRoot)
Dim oResults As SearchResultCollection
Dim oResult As SearchResult
Dim RetArray As New Hashtable()
Try
oSearcher.PropertiesToLoad.Add("uid")
oSearcher.PropertiesToLoad.Add("givenname")
oSearcher.PropertiesToLoad.Add("cn")
oResults = oSearcher.FindAll()
For Each oResult In oResults
If Not oResult.GetDirectoryEntry().Properties("cn").Value = "" Then
RetArray.Add(oResult.GetDirectoryEntry().Properties("uid").Value, _
oResult.GetDirectoryEntry().Properties("cn").Value)
End If
Next
Catch ex As Exception
MsgBox(ex.ToString)
End Try
|