The following function will test a username/password against the given domain:
function fnCheckAccess(strDomain, strUserID, strUserPWD)
const ADS_SECURE_AUTHENTICATION = &h0001
const ADS_CHASE_REFERRALS_ALWAYS = &H60
dim objDSO
dim objUser
dim strPath
strPath = "LDAP://" & strDomain & "/OU=Users,DC=" & strDomain
On Error Resume Next
set objDSO = GetObject("LDAP:")
set objUser = objDSO.OpenDSObject (strPath, strUserID, strUserPWD, ADS_SECURE_AUTHENTICATION OR ADS_CHASE_REFERRALS_ALWAYS)
if Err.Number <> 0 then
MsgBox "Incorrect Password for " & g_strDomain & "\" & g_strUserID & "." & vbCRLF & vbCRLF & "Error " & Err.Number & ": " & Err.Description, 16, "Access Denied"
fnCheckAccess = False
else
fnCheckAccess = True
end if
Err.Clear
On Error Goto 0
set objDSO = Nothing
set objUser = Nothing
end function