#!/bin/bash -e . /etc/ldap-utils.conf . /usr/local/lib/ldap-utils/funcs usage() { echo "Usage : $(basename $0) -u -n -s [-p] [-g group1,group2,...]" } trap usage ERR clearpw=$(pwgen 50 1) pw=$(/usr/sbin/slappasswd -o module-load=pw-sha2 -h '{SSHA512}' -s "$clearpw") uid=$1 if user_exists $uid; then true else echo "User $uid does not exists." exit 1 fi ldif="dn: uid=$uid,$PEOPLEDN changetype: modify replace: userPassword userPassword: $pw" echo "$ldif" | ldapmodify $LDAPOPTS echo "Password changed, here is the new one" echo "$clearpw"