Hi,
I need to do authentication via Active Directory.The VB6 program should only allow user to log in to the system if and only if user has key in correctly his AD login (samAccountName) and password.

However, i only manage to do authentication with samAccountName only. I find no way to check if user has key in correctly their password.
My Code is as below:

Code:
On Error Resume Next

    Dim conLDAP As ADODB.Connection
    Dim strSQL As String
    Dim strLDAPConn As String
    Dim rsUser As ADODB.Recordset
    Set conLDAP = New ADODB.Connection
    
    Dim strUserName As String
    Dim strPassword As String
    Dim a As String
    
   strUserName = "USerId"
   strPassword = "PASSWORD"
   
    conLDAP.Provider = "ADSDSOOBject"
    strSQL = "Select AdsPath,samAccountName, employeeID, Name, cn From 'LDAP://XXX.ad.ZZZZZ.com" _
    & "' where objectClass='user'" _
    & " and objectcategory='person' and" _
   & " SamAccountName='" & strUserName & "'"
    


    'open connection + password
    'conLDAP.Open "DS Query", strUserName, strPassword
    
   conLDAP.Open "Data Source=Active Directory Provider;Provider=ADsDSOObject"


    'execute LDAP query
    Err.Clear
    Set rsUser = conLDAP.Execute(strSQL)
    
    'rs will be empty if authentication fail
 
    If Err.Number = 0 Then
    
    If Not (rsUser Is Nothing) Then
    
    If Not (rsUser.EOF And rsUser.BOF) Then
      a = rsUser("AdsPath")
      a = rsUser("Name")
      a = rsUser("employeeID")
      a = rsUser("samAccountName")
       a = rsUser("cn")
      
    End If
    End If
    
    ElseIf Err.Number = -2147217865 Then
    
    MsgBox "Error in LDAP settings" & vbCrLf & "Call Admin"

End If
Does anyone has idea on how to do Active Directory authentication with samAccountName and password?