|
|
@@ -0,0 +1,30 @@
|
|
|
+#!/bin/bash -e
|
|
|
+. .env
|
|
|
+. funcs
|
|
|
+
|
|
|
+usage() {
|
|
|
+ echo "Usage : $(basename $0) -u <uid> -n <First name> -s <Last Name> [-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"
|