LDAP Based Authentication Through Jscript

I am attempting to authenticate users through JScript (server side) code and Active Directory. In its current behavior the code below throws an empty exception (e.description == "") if the username and password are invalid and if they are valid the exception "Class doesn't support Automation" is thrown. Thank you very much for your advice!
function AuthenticateUser(sUsername, sPassword)
{
   try {
      var ADS_SECURE_AUTHENTICATION = 1;
      var ADS_USE_ENCRYPTION = 2;
      var objLDAP = GetObject("LDAP:");
      if(objLDAP) {
         var sResult = objLDAP.OpenDSObject("LDAP://xxxxxxx.xxxx.xxx/cn=users,dc=xxxxxx,dc=xxxx,dc=xxx", sUsername + "@XXXXXXX", sPassword, ADS_SECURE_AUTHENTICATION || ADS_USE_ENCRYPTION);
      }
   }
   catch (e) {
      log("Exception in AuthenticateUser: " + e.description);
      throw(e);
   }
}

Open in new window

LVL 19
LordOfPortsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
Source: http://community.installshield.com/showthread.php?t=115480
"Hi All, The following jscript(WSH) for Ldap access, works fine on my Win2k system..."
---------------------------------------------------------------------------
Ldap Jscript:
---------------------------------------------------------------------------
// cscript chkLdapAcc.js
//
// The following is the OpForce install parameters for LDAP.
// Provider: -> LDAP://192.168.6.20/dc=qa,dc=com
// User DN : => cn=Admin,cn=Users,dc=qa,dc=com
// Password: -> Admin
//
ADS_SECURE_AUTHENTICATION = 0x1
var user;
var provLdap;
var gblError= false;
var Container = "DC=qajareva,DC=COM";
// Create LDAP obj
try{
provLdap = GetObject("LDAP:") ;
WScript.Echo("Success: LDAP Object created");
}
catch(err)
{
WScript.Echo('LDAP Connection Error: '+err.description);
gblError = true;
}
if(!gblError)
{
// Login
try{
user = provLdap.OpenDSObject("LDAP://company.com/"
+ Container
, "Admin@qa.com"
,"Admin", ADS_SECURE_AUTHENTICATION);
}
catch(err)
{
WScript.Echo('LDAP Login Error: '+err.description);
gblError = true;
}
}
if(!gblError)
{
//Work with the object
WScript.Echo('UserName : ' +user.Name)
WScript.Echo('UserClass: ' +user.Class)
WScript.Echo('USerGUID : ' +user.GUID)
WScript.Echo("")
}

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LordOfPortsAuthor Commented:
Most excellent. Thank you very much!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JScript

From novice to tech pro — start learning today.