我的 JavaScript 中有以下代码:
var ad = new ActiveDirectory(adConfig);
ad.authenticate(username, password, function (err, auth) {
if (err) {
console.error("ERROR : " + JSON.stringify(err));
res.send(false);
return;
}
if (auth) {
console.log("User " + username.split('\\')[1] + " authenticated");
ad.findUser(username.split('\\')[1], function (err, user) {
//More code here
}
我的程序到达 ad.findUser 行,但在那里,我收到以下错误:
activedirectory.js:416 delete result.controls; // Remove the controls array returned as part of the SearchEntry ^ TypeError: Cannot convert undefined or null to object
文件 activedirectory.js 的第 416 行是此处以“delete”开头的行:
function onSearchEntry(entry) {
log.trace('onSearchEntry(%j)', entry);
console.log('entry', entry);
var result = entry.object;
delete result.controls; // Remove the controls array returned as part of the SearchEntry
...
我的“entry”对象的类型为 SearchResultEntry [LdapMessage] {...}
,其 effectivement 没有“object”属性,因此“result”未定义。这就是为什么我的代码不起作用。但是,我不明白为什么我会陷入这种境地。
有什么线索吗?
最佳答案
根据this GitHub issue ,看来 activedirectory 库不适用于 ldapjs 3.0.0,因此您可能需要在 package.json 中添加覆盖:
"overrides": {
"activedirectory": {
"ldapjs": "2.3.3"
}
}
关于node.js - findUser 函数中的 Active Directory 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75801286/