Active Directory password change
See original GitHub issueI’m trying to write a script which will allow users to change their own passwords on Active Directory. After a successful bind as the user with their ‘old’ password, I’m using:
client.modify(userDN, [
new ldap.Change({
operation: 'delete',
modification: {
unicodePwd: encodePassword(oldPassword)
}
}),
new ldap.Change({
operation: 'add',
modification: {
unicodePwd: encodePassword(newPassword)
}
})
], function(err) {
if (err) {
console.log(err.dn);
console.log(err.code);
console.log(err.name);
console.log(err.message);
client.unbind();
}
else {
console.log('Password changed!');
}
});
Where encodePassword
is defined as
function encodePassword(password) {
var newPassword = '';
password = '"' + password + '"';
for (var i = 0; i < password.length; i++) {
newPassword += password[i] + "\000";
}
return new Buffer(newPassword).toString('base64');
}
which was taken from http://www.cs.bham.ac.uk/~smp/resources/ad-passwds/
The PHP script + ldapmodify works fine but the Node.js script gives a ConstraintViolationError with the message
0000216C: AtrErr: DSID-03190EB0, #1:
0: 0000216C: DSID-03190EB0, problem 1005 (CONSTRAINT_ATT_TYPE), data 0, Att 9005a (unicodePwd)
The new password meets the constraints applied by the server (complexity etc) so I’m not sure what’s going wrong. As the password change can only be done over ldaps I can’t provide a Wireshark capture and I’m out of ideas. Any suggestions?
Issue Analytics
- State:
- Created 11 years ago
- Comments:23 (6 by maintainers)
Top Results From Across the Web
How to Reset A User Password in Active Directory?
Right-click the domain user account you want to reset the password for in the right pane, and select Reset Password. Type a new...
Read more >Change Windows Active Directory and LDS user password ...
This article describes how to change a Windows Active Directory and LDS user password through LDAP.
Read more >How to Change or Update Your Active Directory Password
Connect to your company's network: In the office. Or, by connecting to a VPN when outside of the office. · Press Control +...
Read more >How to Change User Passwords in Active Directory
Active Directory Users and Computers – A nice GUI that's been around since the dawn of AD is the most commonly used tool....
Read more >Changing Your Active Directory Password
Changing Your Active Directory Password. Content Summary: Password Change: Android Update for District Mail, Contacts & Calendar.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
To change the password of an ActiveDirectory user you’ll need the following things:
I’m using the following function to get the encoded password.
This works.