Derek Hatchard blogs on
Church Radius Blog


Feed Yourself:


Subscribe in Bloglines

Add to Google

Subscribe by Email:


.NET Experts on Tap
About ArdentDev.com
Ardent Sites
Ask the Experts
Careers
Consulting and Mentoring
Contact Ardent
News & Noteworthy
Portfolio
Writing


On this page....
Using ADSI to Authenticate Against Active Directory

Send mail to the authors Email Us

Archives

Navigation

Categories
 Code
 Tools

Disclaimer
The opinions expressed in this site are those of the individual authors and do not necessarily represent the official view of Ardent Development nor its employees, subsidiaries, partners, or customers.

© Copyright 2009, Ardent Development

Powered by: newtelligence dasBlog 1.8.5223.1



 Tuesday, April 25, 2006

   
     

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)
#   Disclaimer  |  Comments [0]  | 
 
© 2005 Ardent Development Solutions