On Jun 28, 3:41 pm, oaksong wrote:
> I'm trying to build a query to pull some information from my LDAP
> based on a user ID.
>
> Dim conLDAP As ADODB.Connection
> Dim strSQL As String
> Dim strLDAPConn As String
> Dim rsUser As ADODB.Recordset
> Set conLDAP = New ADODB.Connection
> conLDAP.Provider = "ADSDSOOBject"
> strSQL = "SELECT givenName, sn FROM LDAP://" & gstrLDAPURL & "
> where sAMAccountName = '" & strUserName & "'"
> conLDAP.Provider = "ADsDSOObject"
> 'open connection
> conLDAP.Open "DSQuery"
> 'execute LDAP query
> err.Clear
> Set rsUser = conLDAP.Execute(strSQL)
>
> I'm getting an error 2147217900, "One or more errors occurred during
> processing of command."
>
> gstrLDAPURL is a string of dc='s items, ie. dc=po1,dc=po2,dc=etc.
>
> Any suggestions??
I've simplified this quite a bit....
---------------------------------------------------------------------------------------------------------------------
objConn.Open "Provider=ADsDSOObject;"
objComm.ActiveConnection = objConn
If InStr(UCase(dom), "AA") > 0 Then
dom = "dc=" & dom & ",dc=dvx,"
ElseIf InStr(UCase(dom), "V") > 0 Then
dom = "dc=" & dom & ",dc=mex,"
End If
ldStr = "<LDAP://" & dom & "dc=vx,dc=com>;" _
& "(&(objectCategory=person)(objectClass=user)
(sAMAccountName=" & strUserName & "));name, sAMAccountName;subtree"
objComm.CommandText = ldStr
'(sAMAccountName=" & strUserName & ")
Set ObjRS = objComm.Execute
While Not ObjRS.EOF
MsgBox ObjRS.Fields("name") & ": " &
ObjRS.Fields("sAMAccountName").value & " is valid."
ObjRS.MoveNext
Wend
--------------------------------------------------------------------------------------------------------------------
In one instance it works as it should. In that instance the dom value
includes a local server. In the other instance the dom contains a
remote server.
Using the MMC plugin, Active Directory Users and Computers, I can
'connect' to the remote server, create a query, and get the
appropriate result. However trying essentially the same thing at my
workstation yields no error and no result.
I'm fairly stymied at this point as to what might be happening
remotely, and why the MMC produces a result while the application does
not.