add conformation to delete an user

This commit is contained in:
Gilles Mouchet 2024-12-31 07:54:33 +01:00
parent a1597fa7a8
commit efea32e53c

View File

@ -90,12 +90,18 @@ EOF
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# delUser # delUser
function delUser { function delUser {
#echo $user_to_del #echo $user_to_del
ldapdelete -x -H $LDAP_SRV -D "$LDAP_MANAGER_USER" -w $LDAP_MANAGER_PASS \ # request confirmation
"cn=$user_to_del,ou=people,$LDAP_BASE" echo -e "\nYou will DELETE 'cn=$user_to_del,ou=people,$LDAP_BASE' from the directory"
if [ "$?" == "0" ]; then read -p "Are you sure? " -n 1 -r
echo "$user_to_del successfully deleted from directory" echo -e "\n"
fi 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 # main