首页 > 解决方案 > 这是否可以在nodejs中验证远程用户和密码存在检查?

问题描述

如何针对 Active Directory 验证用户名和密码?我只是想检查 nodejs 代码中的用户名和密码是否正确。

我用过活动目录 npm

但显示错误为

ERROR: {"code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect","address":"96.45.82.8","port":389} 

这是我的代码

    var ActiveDirectory = require('activedirectory');
    var config = { url: 'ldap://npsc.co.in',
                   baseDN: 'dc=npsc,dc=in',
                   username: 'user@npsc.co.in',
                   password: 'password' }

    var ad = new ActiveDirectory(config);
    var username = 'user@npsc.co.in';
    var password = 'password';

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

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

标签: node.jsactive-directoryldap

解决方案


推荐阅读