Nodejs应用中的activedirectory finduser方法问题



我使用activedirectory npm包与Nodejs v16.18.1,我使用以下代码首先进行身份验证,然后finduser获取其详细信息:

你能帮我一下吗?

async  authUserActiveDirectory(usernameAD: string, pass: string) {
const config = {
url: 'ldap://192.168.136.136',
baseDN: 'DC=octopusadlocal,DC=com',
username: usernameAD+'@octopusadlocal.com',
password: pass,
};

const ad = new ActiveDirectory(config);    
const userName = usernameAD+'@octopusadlocal.com';
ad.authenticate(userName, pass, function(err, auth) {
if (err) {
console.log('Error authenticating user:', userName);
}
if (auth) {
console.log('Usernames', userName, 'authenticated successfully');               
const sAMAccountName = userName;
ad.findUser(sAMAccountName, function(err, user) {
if (err) {                
console.log(err)
}
if(!user) {
console.log('no user exists')
} else {
console.log(user)
}
})  
} else {
console.log('User', userName, 'not authenticated');
}
});
}

输出:

使用广告。activedirectory包的Finduser,它会产生以下问题:用户名oct1@octopusadlocal.com authenticated successfully

/验证/node_modules/activedirectory/lib/activedirectory.js: 416删除result.controls;//删除作为SearchEntry的一部分返回的控件数组^类型错误:无法将未定义或null转换为对象在CorkedEmitter。onSearchEntry(/验证/node_modules/activedirectory/lib/activedirectory.js: 416:5)在CorkedEmitter。发出(节点:事件:513:28)在CorkedEmitter。发出(/验证/node_modules/ldapjs/lib/corked_emitter.js: 44:33)/validation/node_modules/ldapjs/lib/client/client.js:1233:22在message ecallback (/validation/node_modules/ldapjs/lib/client/client.js:1253:14)在解析器。onMessage(/验证/node_modules/ldapjs/lib/客户/client.js: 919:14)在解析器。发出(节点:事件:513:28)在解析器。写(/验证/node_modules/ldapjs/lib/信息/parser.js: 135:8)在套接字。数据(/验证/node_modules ldapjs/lib/客户/client.js: 875:22)在套接字。发出(节点:事件:513:28)

使用ldapjs 2.3.3没有问题。看起来和ldapjs 3.0.0不兼容

在这里我找到了解决方案链接

相关内容

最新更新