Skip to content

Instantly share code, notes, and snippets.

@dnozay
Created February 18, 2015 19:30
Show Gist options
  • Save dnozay/d28dff75c390ebba7ded to your computer and use it in GitHub Desktop.
Save dnozay/d28dff75c390ebba7ded to your computer and use it in GitHub Desktop.
change slapd manager password.
#!/bin/bash
# License: MIT
# You can find a copy of the license here: http://opensource.org/licenses/MIT
# This simple script lets you change the LDAP admin password from
# a console on the LDAP server.
cd /tmp
set -o errexit
PASSWORD=$(slappasswd -h {SSHA})
echo "New hashed password is $PASSWORD"
cat > ./new-password.ldif <<EOFLDIF
dn: olcDatabase={1}hdb,cn=config
changetype: modify
replace: olcRootPW
olcRootPW: ${PASSWORD}
EOFLDIF
echo "New password LDIF is:"
cat ./new-password.ldif
echo ""
read -p "Proceed to change password [y/N] " -N 1 -s
echo ""
if test "${REPLY}" == "y"; then
echo Performing change...
ldapmodify -Y EXTERNAL -H ldapi:/// -f ./new-password.ldif
else
echo Not performing change...
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment