gpt4 book ai didi

How can I retrieve detailed error information from ldapjs?(如何从ldapjs检索详细的错误信息?)

转载 作者:bug小助手 更新时间:2023-10-25 22:23:34 24 4
gpt4 key购买 nike



I'm working in the Ubuntu 20.04 and openLDAP 2.4.49 environment.

我在Ubuntu 20.04和OpenLDAP2.4.49环境中工作。


How can I retrieve detailed error information from ldapjs?
(ldapjs version is 3.0.5)

如何从ldapjs检索详细的错误信息?(ldapjs版本为3.0.5)


For example, if I change the password immediately after changing it once, and then execute the following command:

例如,如果我在更改密码一次后立即更改密码,然后执行以下命令:


ldappasswd -H ldapi:/// -x -D <myDN> -W -S

The result displays detailed information like:

结果显示详细信息,如:


Result: Constraint violation (19)
Additional info: Password is too young to change

However, when I perform the following code using ldapjs, the result only shows the ConstraintViolationError value without detailed information.

然而,当我使用ldapjs执行以下代码时,结果只显示ConstraintViolationError值,没有详细信息。


'use strict';

const ldap = require('ldapjs');

const client = ldap.createClient({
socketPath: '/run/ldapi',
});

function changePassword() {
const userDN = <user_DN>;
const userPassword = <userPassword>;

return new Promise((resolve, reject) => {
client.bind(userDN, userPassword, (err) => {
if (err) {
return reject(err);
} else {
const change = new ldap.Change({
operation: 'replace',
modification: {
type: 'userPassword',
values: ['NewPassword'],
}
});

client.modify(userDN, change, err => {
if (err) {
return reject(err);
}

return resolve();
});
}
})
});
}

(async () => {
try {
await changePassword();
} catch (e) {
console.log(`${JSON.stringify(e)}`);
}


client.unbind();
})();

What is the method to obtain detailed information, such as "Password is too young to change," when using ldapjs?

在使用ldapjs时,有什么方法可以获取详细信息,例如“密码太年轻而无法更改”?


更多回答
优秀答案推荐
更多回答

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com