In Nodejs how to reset active directory password without knowing the current password?
I use the below 2 libraries at the moment.
https://www.npmjs.com/package/activedirectory
I have the below code which works perfectly if I know the current password. But I also want to reset password, if I dont know the current password.
function modifyPassword() {
return new Promise((resolve, reject) => {
try {
//ldapClient.bind(userDN, oldPassword, err => {
ldapClient.bind(service_acc_user, service_acc_pwd, err => {
if (err) {
reject(err);
}
ldapClient.modify(userDN, [
new ldap.Change({
operation: 'delete',
modification: {
unicodePwd: encodePassword(oldPassword)
}
}),
new ldap.Change({
operation: 'add',
modification: {
unicodePwd: encodePassword(newPassword)
}
})
], (error) => {
if (error) {
reject(error);
} else {
resolve('Successfully password modified.');
}
});
})
} catch (error) {
console.error(error);
reject(error);
}
})
}
I tried to use the above code by passing a dummy current password but got the below error.
'00000056: AtrErr: DSID-03190F80, #1:\n\t0: 00000056: DSID-03190F80, problem 1005 (CONSTRAINT_ATT_TYPE), data 0, Att 9005a (unicodePwd)\n\u0000'