【问题标题】:ldapauth-fork InvalidCredentialsErrorldapauth-fork InvalidCredentialsError
【发布时间】:2019-01-16 17:00:39
【问题描述】:

我正在尝试使用 ldapauth-fork 对 LDAP 用户进行身份验证。我的 LDAP 管理员帐户有问题,虽然我知道它是正确的并且可以在 LDAP 浏览器中正常工作,但我无法使其与 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 ");
    }
  });

这是出现的错误

InvalidCredentialsError:80090308:LdapErr:DSID-0C09042F,注释: AcceptSecurityContext 错误,数据 52e,v2580

lde_message: '80090308: LdapErr: DSID-0C09042F,评论: AcceptSecurityContext 错误,数据 52e,v2580\u0000',lde_dn: null

感谢任何帮助。

【问题讨论】:

  • 您找到解决方案了吗?如果是这样,请将其发布为答案
  • 抱歉来晚了。明天分享一下
  • 能否提供解决方案

标签: node.js ldap ldapauth


【解决方案1】:

尝试在 npm 上使用 activedirectory2 库,我尝试使用 ldapauth-form 但可以获得成功的结果

它有许多功能可以完成工作,例如

  • 认证
  • 查找用户

配置代码

const AD = require('activedirectory2').promiseWrapper;
const config = { url: 'ldap://dc.domain.com',
           baseDN: 'dc=domain,dc=com',
           username: 'username@domain.com',
           password: 'password' }
const ad = new AD(config);

#authenticate

var ad = new ActiveDirectory(config);
var username = 'john.smith@domain.com';
var password = 'password';

ad.authenticate(username, password, function(err, auth) {
 if (err) {
   console.log('ERROR: '+JSON.stringify(err));
   return;
 }

if (auth) {
 console.log('Authenticated!');
}
else {
 console.log('Authentication failed!');
}
});

#finduser 也是如此

// Any of the following username types can be searched on
var sAMAccountName = 'username';
var userPrincipalName = 'username@domain.com';
var dn = 'CN=Smith\\, John,OU=Users,DC=domain,DC=com';

// Find user by a sAMAccountName
var ad = new ActiveDirectory(config);
ad.findUser(sAMAccountName, function(err, user) {
if (err) {
 console.log('ERROR: ' +JSON.stringify(err));
 return;
}

if (! user) console.log('User: ' + sAMAccountName + ' not found.');
 else console.log(JSON.stringify(user));
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-31
    • 2019-03-02
    • 1970-01-01
    • 1970-01-01
    • 2016-10-11
    • 2015-07-16
    • 2015-08-22
    • 1970-01-01
    相关资源
    最近更新 更多