Last active
January 3, 2016 10:09
-
-
Save alexclifford/8447397 to your computer and use it in GitHub Desktop.
Change an LDAP user's password - not tested.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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