node.js - Node js 中的 LDAP 身份验证支持

标签 node.js ldapconnection

我已经使用 npm install ldapauth 安装了 ldapauth 并且安装了 ldapjs。 我尝试使用以下代码:


var sys   = require('sys'),
ldapauth  = require('./ldapauth');

var scheme    = 'ldap',
    ldap_host = 'abc.com',
    ldap_port = 369,
    username  = 'xxx',
    password  = 'xxx'
    base      = "DC=abc,DC=xyz,DC=com";
    filter    = "(&(objectclass=user)(sAMAccountName= 3025141))";

console.log("Authentication Check");

ldapauth.authenticate(scheme, ldap_host, ldap_port, username, password,
  function(err, result) {
      if (err) {
          console.log(err);
      } else {  
          console.log('Authenticated ! ! ! ! ! : ' + result);
      }
  });

//ldap authentication Search
ldapauth.search(ldap_host, ldap_port, username, password, base, filter,
  function(err, result) {
      if (err) {
        sys.puts(err);
      } else {
        sys.puts('Search: ' + JSON.stringify(result));
      }
  });

我在 mac 中尝试过,但出现了 Segmentation fault: 11 错误。我该如何解决这个问题?

最佳答案

var ldap = require('ldapjs');
var client = ldap.createClient({
  url: 'ldap://127.0.0.1:1389'
});

client.bind('cn=root', 'secret', function(err) {
  if(err) {
    console.log(err);
  } else {
    console.log('authenticated');
  }
});

client.unbind(function(err) {
});

我使用 ldapjs 客户端进行身份验证。这应该不是问题。
here is the link to ldapjs client doc

关于node.js - Node js 中的 LDAP 身份验证支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13118963/

相关文章:

javascript - SvelteKit 开发服务器未启动

php - 从 php 服务器重新启动我的 Nodejs 应用程序(使用 pm2)

javascript - 使用 Node 搜索 JSON 数组中的项目(最好不进行迭代)

javascript - 使用 grunt 加载 grunt-configs 和 Bower.install()

c - 通过 SSL 和 TLS 绑定(bind)并验证到 LDAP 服务器

javascript - 在 NodeJS 中将数据从一个 js 文件同步传递到另一个文件

.net - c# 通过 ssl 连接到 Active Directory 使 ldap 服务器不可用

ldapconnection - phabricator LDAP 连接失败

java - 与 Active Directory 中未列出的用户建立 LDAP 连接

ssl - 无法使用 DirectoryServices.Protocols.LdapConnection 打开 SecureSocketLayer