|
I dusted off my modest ADSI skills yesterday to help some folks figure out how to authenticate against Active Directory by binding to it using LDAP. Here's a VBScript version using ADSI (run at command line using cscript.exe).
Const ADS_SECURE_AUTHENTICATION = 1
Dim uid, pwd
WScript.StdOut.Write "User name (with domain prefix): " uid = WScript.StdIn.ReadLine
WScript.StdOut.Write "Please enter your password:" Set objPassword = CreateObject("ScriptPW.Password") pwd = objPassword.GetPassword() WScript.Echo
' Get just the username (samAccountName) Dim username tmp = Split(uid, "\") username = tmp(1)
Dim LDAP 'As IADsOpenDSObject Dim LDAPString LDAPString = "LDAP://cn=Users,dc=yourdomain,dc=local"
''' ''' Important Lines Right Here ''' Set LDAP = GetObject("LDAP:") Set obj = LDAP.OpenDSObject(LDAPString, uid, pwd, ADS_SECURE_AUTHENTICATION) ''' ''' '''
For Each o in obj If o.Class = "user" Then If o.Get("samAccountName") = username Then WScript.Echo "Found " & o.Get("cn") End If End If Next
Posted by Derek Hatchard 4/25/2006 7:10:06 PM (Atlantic Standard Time, UTC-04:00)
|