Solved

VBScript to validate a password with Active Directory

Posted on 2010-11-12
6
2,045 Views
Last Modified: 2012-05-10
I have an internal website that specified users will be able to work in.  I also have an SQL server that stores the usernames in a table of the people that are authorized to use the site.

I want the users to be able to use their Windows password, which is controlled by Active Directory on our domain controller (server2.mydomain.com).

Here's how I need this to go:

1.  User enters a username and password.
2.  Username is checked against the SQL server to ensure the user is authorized to use the site.
3.  Username and Password are validated against Active Directory 2003 to ensure sure they match the user's actual username and password.  If so, the script will return True
4.  If the validation script returns true, a session is created which will last for one hour and extended each time the user accesses a page in the website.
5.  If the session expires, the user will be prompted to login again.

I have no idea how to simply check whether the user entered the correct password.  Can someone help me with the simple script necessary for step 3?

Thanks,
0
Comment
Question by:jamesbcox1980
  • 3
  • 3
6 Comments
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Hi, for this problem, it sounds like you would be better off using Windows Authentication for you ASP pages, which would authenticate any AD user, and *then* you could check if that user was in your SQL database.  If the user was listed, create the session, if not, log them off.

Regards,

Rob.
0
 
LVL 4

Author Comment

by:jamesbcox1980
Comment Utility
Is there no way to simply verify a password with AD?
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
Comment Utility
Well you can try this function in your code, and see how you go.

Regards,

Rob.
strUser = txtUser.Value

strPW = txtPW.Value

boolAuthenticated = AuthenticateUser(strUser, strPW)

If boolAuthenticated = True Then

	' Check against SQL database

Else

	' User was not authenticated

End If



Function AuthenticateUser(ByVal strUser, ByVal strPW)

	Const ADS_SECURE_AUTHENTICATION = &H1

	Const ADS_SERVER_BIND = &H200



	strPath = "LDAP://RootDSE"



	Set LDAP = GetObject(strPath)

	Set strAuth = LDAP.OpenDSObject(strPath, strUser, strPW, ADS_SECURE_AUTHENTICATION Or ADS_SERVER_BIND)

	If Err.Number <> 0 Then

		boolAuth = False

	Else

		boolAuth = True

	End If

	AuthenticateUser = boolAuth

End Function

Open in new window

0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 4

Author Comment

by:jamesbcox1980
Comment Utility
Sorry I've been out of town. I'll answer a soon as I get back and have a chance to try it.
0
 
LVL 4

Author Closing Comment

by:jamesbcox1980
Comment Utility
Thanks, worked like a charm
0
 
LVL 65

Expert Comment

by:RobSampson
Comment Utility
Great.  Thanks for the grade.

Regards,

Rob.
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Scenerio: You have a server running Server 2003 and have applied a retail pack of Terminal Server Licenses.  You want to change servers or your server has crashed and you need to reapply the Terminal Server Licenses. When you enter the 16-digit lic…
I've always wanted to allow a user to have a printer no matter where they login. The steps below will show you how to achieve just that. In this Article I'll show how to deploy printers automatically with group policy and then using security fil…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now