Solved

VBScript to validate a password with Active Directory

Posted on 2010-11-12
6
2,208 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 34133647
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
ID: 34136173
Is there no way to simply verify a password with AD?
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 34141448
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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 4

Author Comment

by:jamesbcox1980
ID: 34176574
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
ID: 34192349
Thanks, worked like a charm
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 34192897
Great.  Thanks for the grade.

Regards,

Rob.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Learn about cloud computing and its benefits for small business owners.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 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