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

@ -91,11 +91,17 @@ EOF
# delUser # delUser
function delUser { function delUser {
#echo $user_to_del #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 \ ldapdelete -x -H $LDAP_SRV -D "$LDAP_MANAGER_USER" -w $LDAP_MANAGER_PASS \
"cn=$user_to_del,ou=people,$LDAP_BASE" "cn=$user_to_del,ou=people,$LDAP_BASE"
if [ "$?" == "0" ]; then if [ "$?" == "0" ]; then
echo "$user_to_del successfully deleted from directory" echo "$user_to_del successfully deleted from directory"
fi fi
fi
} }
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# main # main