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时,有什么方法可以获取详细信息,例如“密码太年轻而无法更改”?
更多回答
我是一名优秀的程序员,十分优秀!