I designed a tool getting information from active directory and wanted to extend its use to users from another country located in another AD Domain.
When I connect myself to the other AD domain in ADExplorer it works well but when I request it from VBA code I get the annoying error 80040E37 - A referral was returned from the server
Here is my code:
Dim adoCommand, ADOConnection, adoRecordset, Liste_noms, Liste_noms_split
Dim strQuery, strReturnVal, temp As String
Dim nb, i, j As Long
' Setup ADO objects.
Set adoCommand = CreateObject("ADODB.Command")
Set ADOConnection = CreateObject("ADODB.Connection")
ADOConnection.Provider = "ADsDSOObject"
ADOConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = ADOConnection
' Construct the LDAP syntax query.
strQuery = "SELECT givenName, sn FROM 'LDAP://DC=Mydomain, DC=Myserver, DC=lan'"
adoCommand.CommandText = strQuery
' Define the maximum records to return
adoCommand.Properties("Page Size") = 100
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = False
' Run the query.
Set adoRecordset = adoCommand.Execute
' Enumerate the resulting recordset.
strReturnVal = ""
Do Until adoRecordset.EOF = True
' Retrieve values and display.
If strReturnVal = "" Then
strReturnVal = adoRecordset.Fields(0).Value & "/" & adoRecordset.Fields(1).Value
Else
strReturnVal = strReturnVal & "//" & adoRecordset.Fields(0).Value & "/" & adoRecordset.Fields(1).Value
End If
' Move to the next record in the recordset.
adoRecordset.MoveNext
Loop
' Clean up.
adoRecordset.Close
ADOConnection.Close
Do you know how I can solve this issue? It will help me a lot!
Thank you!!
question from:
https://stackoverflow.com/questions/65886040/query-on-ldap-non-default-domain-returns-error-80040e37 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…