我是nodejs的新手。我正在尝试使用activedirectory lib对Active Directory进行身份验证。但是我面临以下问题...
{"errno":"EACCES","code":"EACCES","syscall":"connect","address":"xxx.xxx.x.xx","port":389}
我不知道为什么会发生此问题。相同的代码可以在另一台服务器上正常工作。
代码
var ActiveDirectory = require('activedirectory');
var adConfig = {
url: 'ldap://xxx.xxx',
baseDN: 'dc=xxx,dc=xxx'
}
我写了一个REST API来从AD验证用户身份
app.post('/api/authenticate', authenticate);
function authenticate(req, res) {
var ad = new ActiveDirectory(adConfig);
ad.authenticate(req.body.username, req.body.password, function (err, auth) {
if (err) {
console.log('ERROR AD: ' + JSON.stringify(err));
res.send({ message: "Something went wrong", success: false, code: "5001" });
return;
}
if (auth) {
console.log('Authenticated!');
console.log(auth);
}
else {
console.log('Authentication failed!');
res.send({ message: 'Authentication failed!', success: false, code: "5001" });
}
});
}