Here is what I have come up with so far and it isnt working. I noted the location if fails. any ideas?
Code:
Public Function AccessLDAP()
Dim con As ADODB.Connection
Dim cmd As ADODB.Command
Dim rs As ADODB.Recordset
Dim txtMsg As String
Dim ADsPath As String
ADsPath = "LDAP://CN= XXXXX,CN=users,DC=XXXXXX,DC=XXX"
'set the connection
Set con = New ADODB.Connection
With con
.Provider = "ADsDSOObject"
'.Properties("ADSI Flag") = 0
.Open "ADSI", , 0
End With
'set the command object
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = con
.CommandText = "<" & ADsPath & ">;(&(userreferencedn= xxxxxx)(auid=xxxxx));ADsPath;Subtree"
.Properties("Page Size") = 1000
.Properties("Timeout") = 30
.Properties("Cache Results") = True
End With
Set rs = cmd.Execute 'THIS IS WHERE RCVD ERROR TABLE DOES NOT EXISIT
If Not (rs.BOF And rs.EOF) Then
rs.MoveLast
rs.MoveFirst
Debug.Print "Record Count: " & rs.RecordCount
While Not rs.EOF
Debug.Print rs.Fields(0)
rs.MoveNext
Wend
End If
'close and clean up
rs.Close
Set rs = Nothing
cmd.Cancel
Set cmd = Nothing
con.Close
Set con = Nothing
End Function