我有在两个不同系统上执行LDAP查询的相同方法。方法很简单:
Public Function AutenticaDominio(ByVal user As String, ByVal ambiente As String) As String
Dim Comm As New ADODB.Command
Dim conn As New ADODB.connection
Dim rs As New ADODB.Recordset
Dim codiceBanca As String
Dim currentAmbiente As String
Dim currentName As String
Dim trovato As Boolean
Dim UserName As String
Set conn = CreateObject("ADODB.Connection")
conn.Provider = "ADsDSOObject"
conn.Properties("User ID") = "XXX"
conn.Properties("Password") = "XXX"
conn.Open "DS Query", "XXX", "XXX"
Set Comm = CreateObject("ADODB.Command")
Set Comm.ActiveConnection = conn
Comm.CommandText = "SELECT SBAcodicebanca FROM 'LDAP://abc.cde.fgh.it/ou=bank,dc=cde,dc=it' WHERE uid = '" & user & "' and SBAelencoambienti = 'sbacodicesottoambiente=GEST,sbacodiceambiente=PROT,ou=applicazioni,dc=cde,dc=it'"
rs.CursorLocation = adUseClient
Set rs = Comm.Execute
If rs.EOF = False Then
If rs.Fields.Item(0) = "099" Then
Autentica = rs.Fields.Item(0)
Exit Function
Else
Autentica = ""
End If
Else
Autentica = ""
End If
End Function
rs.execute语句,返回一个“未指定的错误”,我在Windows XP上运行该方法。该方法适用于Windows 7。
项目是相同的,具有相同的参考和组件。
有谁知道错误在哪里?