Wednesday, November 29, 2006

Simple Login Authentication with ASP and LDAP

I spent hours and hours looking for this. I didn't want anything complicated. I just needed to get the person's username and password and quickly authenticate them against Active Directory.

Nothing complicated.

Nothing involved.

Now, the solution I have here is modified from my specific need.

Here's my solution.

function ldapLogin( user, pass )
{
try
{
var obj = GetObject( "LDAP:" );
obj.OpenDSObject( "LDAP://yourco.local/DC=YOURCO,DC=local",
user + "@yourco.local",
pass,
1 );
return true;
}
catch( e )
{
// if it is an error - then the password or user is wrong.
}
return false;
}



www.cetuscript.com