Let me start by saying I am not trying to query AD, but a cisco call manager, which should still use regular LDAP.
It took me a long time to finally connect, but my problem is if I specify any field name, it gives me an unspecified error, if I select * then it only returns one field, the cn field.
Can someone please enlighten me. Below is my code.
Set oConn = New ADODB.Connection
oConn.Provider = "ADSDSOOBject"
oQuery = "Select * From 'LDAP://" & i.l_server & "'"
oConn.Provider = "ADsDSOObject"
oConn.Properties("User ID") = i.l_user
oConn.Properties("Password") = i.l_pass
oConn.Properties("Encrypt Password") = True
oConn.Open "DS Query", i.l_user, i.l_pass
Err.Clear
Set rs = oConn.Execute(oQuery)
If Err.Number <> 0 Then
MsgBox Err.Description, vbCritical, Err.Number
Else
xRid i.txt_File
End If
While Not rs.EOF
If Trim(rs.Fields("sn").Value) <> "" And Trim(rs.Fields("telephonenumber")) <> "" Then mt Trim(rs.Fields("sn").Value) & ", " & Trim(rs.Fields("givenname").Value) & ", " & Trim(rs.Fields("telephonenumber")) & ", ", i.txt_File
rs.MoveNext
Wend
Unload Me
End
Exit Sub
It took me a long time to finally connect, but my problem is if I specify any field name, it gives me an unspecified error, if I select * then it only returns one field, the cn field.
Can someone please enlighten me. Below is my code.
Set oConn = New ADODB.Connection
oConn.Provider = "ADSDSOOBject"
oQuery = "Select * From 'LDAP://" & i.l_server & "'"
oConn.Provider = "ADsDSOObject"
oConn.Properties("User ID") = i.l_user
oConn.Properties("Password") = i.l_pass
oConn.Properties("Encrypt Password") = True
oConn.Open "DS Query", i.l_user, i.l_pass
Err.Clear
Set rs = oConn.Execute(oQuery)
If Err.Number <> 0 Then
MsgBox Err.Description, vbCritical, Err.Number
Else
xRid i.txt_File
End If
While Not rs.EOF
If Trim(rs.Fields("sn").Value) <> "" And Trim(rs.Fields("telephonenumber")) <> "" Then mt Trim(rs.Fields("sn").Value) & ", " & Trim(rs.Fields("givenname").Value) & ", " & Trim(rs.Fields("telephonenumber")) & ", ", i.txt_File
rs.MoveNext
Wend
Unload Me
End
Exit Sub