Mass LDAP password reset
A colleague of mine wanted to reset the passwords for 20 different users without using Directory Studio. Here are his notes in case you run into a similar situation.
- Generate a list of user’s UIDs; one per line and save it in a file called
users.list: - Create a file called
genldif.shand put the following code block in it:Note: Replacecat >> ldap_change_passwd_.ldif <<EOF dn: uid=${WHATUSER},ou=People,dc=example,dc=com changetype: modify replace: userPassword userPassword: {SSHA}hashed password EOFhashed passwordabove with your real default password hash. - Make the file executable:
chmod u+x genldif.sh - Run the script for each user in your list to generate the LDIF file:
for k in $(cat users.list); do export WHATUSER=${k} ; ./genldif.sh; done - Load the LDIF file,
ldap_change_passwd_.ldifinto your Primary LDAP server:ldapmodify -x -H ldaps://<ldap server>:636 -D "cn=Directory Manager" -f ldap_change_passwd.ldif -W