Files
Kapisi/roles/Password/package/ldap-resetpass

41 lines
870 B
Plaintext
Raw Normal View History

#!/bin/bash
2025-10-21 14:04:09 -05:00
uid="$1"
if [ -z "$uid" ]; then
echo "Need a user ID (uid)!"
exit 1
fi
2025-10-21 14:04:09 -05:00
# Get the bind password
2024-09-02 23:54:57 -05:00
read -sp 'cn=root,dc=aninix,dc=net Password: ' rootdnpw
2025-10-21 14:04:09 -05:00
printf "\n\n"
# Update the user password
tput setaf 1 1>&2; tput bold 1>&2;
/usr/bin/ldappasswd -D 'cn=root,dc=aninix,dc=net' -w "$rootdnpw" -H ldap://127.0.0.1 "uid=$uid,ou=People,dc=aninix,dc=net"
tput sgr0
2025-10-21 14:04:09 -05:00
# Ensure pwdReset is present
/usr/bin/ldapmodify -D 'cn=root,dc=aninix,dc=net' -w "$rootdnpw" -H ldap://127.0.0.1 -f <(cat <<EOM
2024-09-02 23:54:57 -05:00
dn: uid=$uid,ou=People,dc=aninix,dc=net
changetype: modify
add: pwdReset
pwdReset: TRUE
2024-09-02 23:54:57 -05:00
EOM
)
2025-10-21 14:04:09 -05:00
# Remove pwdChangedTime for immediate update
/usr/bin/ldapmodify -e relax -D 'cn=root,dc=aninix,dc=net' -w "$rootdnpw" -H ldap://127.0.0.1 -f <(cat <<EOM
2024-09-02 23:54:57 -05:00
dn: uid=$uid,ou=People,dc=aninix,dc=net
changetype: modify
delete: pwdChangedTime
EOM
)
2025-10-21 14:04:09 -05:00
# Exit
exit $?