Here is the code I took from Xojo forum to verify if a user and password works on a LDAP server:
Dim strUser, strPassword, strServer, strQuery As String
strUser = “ml6g\utiltest”
strPassword = “$wrongpassword$” // a wrong password
dim LogonServer as string
LogonServer = “my server”
Dim adoConnection, adoCommand,adoRecordset As OleObject
strQuery = “SELECT cn FROM 'LDAP://” + LogonServer + "’ WHERE ObjectClass=’*’ "
adoConnection = new OLEOBJECT(“ADODB.Connection”)
adoConnection.Provider = “ADsDSOOBJECT”
adoConnection.Properties(“User ID”) = strUser
adoConnection.Properties(“Password”) = strPassword
adoConnection.Properties(“Encrypt Password”) = false
adoConnection.open (“DS Query”, strUser, strPassword)
adoCommand = New OleObject(“ADODB.Command”)
adoCommand.ActiveConnection = adoConnection
adoCommand.CommandText = strQuery
adoCommand.Properties(“Size Limit”) = 1
adoRecordset = New OLEObject(“ADODB.Recordset”)
try
adoRecordset = adoCommand.Execute()
Catch ExecuteError As OLEException
// User did not manage to login
msgbox ExecuteError.message
adoConnection.close
adoConnection = Nil
adoCommand = Nil
adoRecordset = Nil
exit
End Try
The instruction
adoRecordset = adoCommand.Execute()
crashes in debug mode.
The Catch subroutine is not run. So, I am wondering if I missed something.
Thanks.