ADO and LDAP not working!!!!
hi,
i'm creating a simple routine that given a name will check if it exist
as user in an Exchange server.
According to MS Exchange Developer kit I've wrote this:
Public Sub Command1_Click()
Dim strADOQueryString As String 'ADO query String
Dim objADOconn As New ADODB.Connection 'ADO connection object
Dim objRS As New ADODB.Recordset 'Recordset object
Dim strCriteria As String ' value for the search
On Error GoTo Cacata
strDisplayName = "Recipients"
strAliasName = "Recipients"
strDirectoryName = "Recipients"
strUserName = "cn=Administrator"
'strUserName = "Administrator"
strPassword = "admin"
strServer = "FAXSRVDIR"
strCriteria = "450"
Set objADOconn = CreateObject("ADODB.Connection")
objADOconn.Provider = "ADSDSOObject"
objADOconn.Open "Active Directory Provider", strUserName, strPassword
If objADOconn.State = adStateOpen Then
MsgBox ("Connection open")
Else
MsgBox ("Connection Failed")
End If
strADOQueryString = "<LDAP://" + strServer +
">;(&(objectClass=organizationalPerson)(sn=" + strCriteria +
"));cn,adspath;subtree"
Set objRS = objADOconn.Execute(strADOQueryString)
If Not objRS.EOF Then
MsgBox ("exist!!")
Else
MsgBox ("not exist")
End If
objRS.Close
Exit Sub
Cacata:
MsgBox ("ERRORE!!")
End Sub
I've tried with both VB5 and 6(since i wasn't sure that Exchange 5.5 was
"compatible with VB6)
With VB6 i got the objADOconn opened but then the query won't work, while
with VB5 I don't have even the objADOconn!! (it jump directly on the error
label!!).. could anybody tell me what I'm doing wrong?????
thx
Briz