Skip to content

Instantly share code, notes, and snippets.

@alexclifford
Last active January 3, 2016 10:09
Show Gist options
  • Save alexclifford/8447397 to your computer and use it in GitHub Desktop.
Save alexclifford/8447397 to your computer and use it in GitHub Desktop.
Change an LDAP user's password - not tested.
#!/bin/bash
LOGDIR="/var/logs"
LOGFILE="change-ldap-password-"$(date +"%F_%H%M")".txt"
LOGPATH=$LOGDIR'/'$LOGFILE
if [ $# -ne 3 ]; then
echo "Usage: change_ldap_password.sh username oldpassword newpassword"
exit 0
fi
USERNAME=$1
OLDPASSWORD=$2
NEWPASSWORD=$3
echo "Changing LDAP password for $USERNAME..." 2>&1 | tee -a $LOGPATH
ldappasswd -D cn=admin,dc=example,dc=com -y /etc/ldapscripts/ldapscripts.passwd -a $OLDPASSWORD -s $NEWPASSWORD uid=$USERNAME,ou=Staff,dc=example,dc=com 2>&1 | tee -a $LOGPATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment