From efea32e53c9d4e90cf67caa5b8d83182bcb41f39 Mon Sep 17 00:00:00 2001 From: Gilles Mouchet Date: Tue, 31 Dec 2024 07:54:33 +0100 Subject: [PATCH] add conformation to delete an user --- manage_user.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/manage_user.sh b/manage_user.sh index 14ffbc1..ab9b1e9 100755 --- a/manage_user.sh +++ b/manage_user.sh @@ -90,12 +90,18 @@ EOF #------------------------------------------------------------------------------ # delUser function delUser { - #echo $user_to_del - ldapdelete -x -H $LDAP_SRV -D "$LDAP_MANAGER_USER" -w $LDAP_MANAGER_PASS \ - "cn=$user_to_del,ou=people,$LDAP_BASE" - if [ "$?" == "0" ]; then - echo "$user_to_del successfully deleted from directory" - fi + #echo $user_to_del + # request confirmation + echo -e "\nYou will DELETE 'cn=$user_to_del,ou=people,$LDAP_BASE' from the directory" + read -p "Are you sure? " -n 1 -r + echo -e "\n" + if [[ $REPLY =~ ^[Yy]$ ]]; then + ldapdelete -x -H $LDAP_SRV -D "$LDAP_MANAGER_USER" -w $LDAP_MANAGER_PASS \ + "cn=$user_to_del,ou=people,$LDAP_BASE" + if [ "$?" == "0" ]; then + echo "$user_to_del successfully deleted from directory" + fi + fi } #------------------------------------------------------------------------------ # main