Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// AD will search and delay an error till later if no password is given
if (password === '') {
return callback(new WrongPassword(profile));
}
log('Change password for DN "' + profile.dn.green + '"');
var modification = {};
if(nconf.get('ENABLE_ACTIVE_DIRECTORY_UNICODE_PASSWORD') === true){
modification.unicodePwd = Buffer.from('"'+password+'"',"utf16le").toString();
}else{
modification.userPassword = password;
}
var passwordResetChange = new ldap.Change({
operation: 'replace',
modification: modification
});
var changeSet = [passwordResetChange];
if (nconf.get('AUTO_UNLOCK_ON_PASSWORD_CHANGE') === true) {
var unlockAccountChange = {
operation: 'replace',
modification: { lockoutTime: 0 }
};
changeSet.push(unlockAccountChange);
}
self._client.modify(profile.dn, changeSet, function (err) {
if (err) {
const args = params.map(name => {
if (fn === 'modify' && name === 'change') {
return new ldapJS.Change(input[name]);
}
return input[name]
});
return getClient(context).then(client => {
tmp[name] = addedValues
values.push(
new ldap.Change({
operation: 'add',
modification: tmp
})
)
}
if (removedValues.length > 0) {
tmp = {}
tmp[name] = removedValues
values.push(
new ldap.Change({
operation: 'delete',
modification: tmp
})
)
}
} else {
tmp = {}
var operation = 'replace'
if (value === null || value === '') {
if (oldValue === null || oldValue === '') {
operation = null
} else {
operation = 'delete'
tmp[name] = oldValue
}