ldapauth-fork InvalidCredentialsError

2019-08-01 06:43发布

问题:

am trying to authenticate user against LDAP by using ldapauth-fork. am having a problem with LDAP Admin account, while i know that is right and works fine with ldap browser am not able to make it work with ldapauth-fork.

var basicAuth = require('basic-auth');
  var LdapAuth = require('ldapauth-fork');
  var username= 'usernameToSearch';
  var password= 'userPassword';

  var ldap = new LdapAuth({
    url: 'ldap://......',
    bindDN: 'sAMAccountName=AdminName,OU=Domian,DC=domain,DC=local',
   bindCredentials: 'AdminPassword',
    searchBase: 'OU=Domain,DC=domian,DC=local',
    searchFilter: '(sAMAccountName={{' + username + '}})',
    reconnect: true
  });

  ldap.authenticate(username, password, function (err, user) {
    if (err) {
      console.log(err);
      res.send({
        success: false,
        message: 'authentication failed'
      });
    } else if (!user.uid) {
      console.log("user not found Error");
      res.send({
        success: false,
        message: 'authentication failed'
      });
    } else if (user.uid) {
      console.log("success : user " + user.uid + " found ");
    }
  });

and here is the error that am getting

InvalidCredentialsError: 80090308: LdapErr: DSID-0C09042F, comment: AcceptSecurityContext error, data 52e, v2580

lde_message: '80090308: LdapErr: DSID-0C09042F, comment: AcceptSecurityContext error, data 52e, v2580\u0000', lde_dn: null

Any help is appreciated.