Added check if admin user exists in reset-adminpassword
This commit is contained in:
parent
2d026cba97
commit
753e2be7ed
@ -23,13 +23,18 @@ get_ldapdomain
|
|||||||
[ ! -d "/federated/apps/ldap" ] && echo "* ldap is not installed." && exit 2
|
[ ! -d "/federated/apps/ldap" ] && echo "* ldap is not installed." && exit 2
|
||||||
LDAP_BIND_PASSWORD=$(cat /federated/apps/ldap/.ldap.secret)
|
LDAP_BIND_PASSWORD=$(cat /federated/apps/ldap/.ldap.secret)
|
||||||
|
|
||||||
|
|
||||||
if [[ $LDAP_DOMIAN_MIDDLE ]]; then
|
if [[ $LDAP_DOMIAN_MIDDLE ]]; then
|
||||||
|
# Check if admin user exists first
|
||||||
|
[[ ! $(docker exec ldap ldapsearch -x -LLL -H ldap://localhost -b dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_MIDDLE,dc=$LDAP_DOMAIN_LAST -w $LDAP_BIND_PASSWORD -D cn=admin,dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_MIDDLE,dc=$LDAP_DOMAIN_LAST uid=admin) ]] && echo "* admin user doesn't exist." && exit 2
|
||||||
|
|
||||||
echo -ne "* Resetting the LDAP admin@$LDAP_DOMAIN_FIRST.$LDAP_DOMAIN_MIDDLE.$LDAP_DOMAIN_LAST password.."
|
echo -ne "* Resetting the LDAP admin@$LDAP_DOMAIN_FIRST.$LDAP_DOMAIN_MIDDLE.$LDAP_DOMAIN_LAST password.."
|
||||||
docker exec ldap ldappasswd -H ldap://localhost -D "cn=admin,dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_MIDDLE,dc=$LDAP_DOMAIN_LAST" -x -w $LDAP_BIND_PASSWORD -s $PASSWORD uid=admin,ou=people,dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_MIDDLE,dc=$LDAP_DOMAIN_LAST -Z
|
docker exec ldap ldappasswd -H ldap://localhost -D "cn=admin,dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_MIDDLE,dc=$LDAP_DOMAIN_LAST" -x -w $LDAP_BIND_PASSWORD -s $PASSWORD uid=admin,ou=people,dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_MIDDLE,dc=$LDAP_DOMAIN_LAST -Z
|
||||||
[ $? -ne 0 ] && failcheck "* Couldn't run ldappasswd inside ldap container"
|
[ $? -ne 0 ] && failcheck "* Couldn't run ldappasswd inside ldap container"
|
||||||
echo -ne "done.\n"
|
echo -ne "done.\n"
|
||||||
else
|
else
|
||||||
|
# Check if admin user exists first
|
||||||
|
[[ ! $(docker exec ldap ldapsearch -x -LLL -H ldap://localhost -b dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_LAST -w $LDAP_BIND_PASSWORD -D cn=admin,dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_LAST uid=admin) ]] && echo "* admin user doesn't exist." && exit 2
|
||||||
|
|
||||||
echo -ne "* Resetting the LDAP admin@$LDAP_DOMAIN_FIRST.$LDAP_DOMAIN_LAST password.."
|
echo -ne "* Resetting the LDAP admin@$LDAP_DOMAIN_FIRST.$LDAP_DOMAIN_LAST password.."
|
||||||
docker exec ldap ldappasswd -H ldap://localhost -D "cn=admin,dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_LAST" -x -w $LDAP_BIND_PASSWORD -s $PASSWORD uid=admin,ou=people,dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_LAST -Z
|
docker exec ldap ldappasswd -H ldap://localhost -D "cn=admin,dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_LAST" -x -w $LDAP_BIND_PASSWORD -s $PASSWORD uid=admin,ou=people,dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_LAST -Z
|
||||||
[ $? -ne 0 ] && failcheck "* Couldn't run ldappasswd inside ldap container"
|
[ $? -ne 0 ] && failcheck "* Couldn't run ldappasswd inside ldap container"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user