Link to home
Start Free TrialLog in
Avatar of LordOfPorts
LordOfPortsFlag for United States of America

asked on

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

ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LordOfPorts

ASKER

Most excellent. Thank you very much!