'The Fully qualified domain name(DomainDNSName) will be taken from Windows Registry
nSlashPos = InStr(strUserID, "\")
If nSlashPos <> 0 Then
'Get domain name
strDomain = Mid$(strUserID, 1, nSlashPos - 1)
'Get User ID
strUserID = Mid$(strUserID, nSlashPos + 1, Len(strUserID) - nSlashPos)
If LTrim(RTrim(gstrLogValidation)) <> "0" Then
ValidateLog "Given User ID: " & strUserID
End If
gstrDomain = strDomain
Else
gstrDomain = objSystemInfo.DomainDNSName
End If
'The Microsoft ADSI Provider allows ADO, read only access to active directory services
'To connect to this provider, set the Provider property of connection object as "ADSDSOObject"
Set conADSI = New ADODB.Connection
conADSI.Provider = "ADsDSOObject"
conADSI.Properties("User Id") = strUserID
conADSI.Properties("Password") = strPassword
conADSI.Properties("Encrypt Password") = True
conADSI.open "DS query"
strSearchString = "SELECT ADSpath " & " FROM 'LDAP://" & gstrDomain & "' WHERE " & _
"sAMAccountName = '" & strUserID & "'"
Set comADSI = New ADODB.Command
Set comADSI.ActiveConnection = conADSI
'This following will be executed only when User ID/Password are valid
'otherwise permission denied excetion will be arised
comADSI.CommandText = strSearchString
Set recADSI = comADSI.Execute
strTemp = recADSI("ADSPath")
|