removeperson 619 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. . /etc/ldap-utils.conf
  3. . /usr/local/lib/ldap-utils/funcs
  4. # Check if option -y is passed
  5. if [ "$1" = "-y" ]; then
  6. confirmed="true"
  7. shift
  8. fi
  9. uid=$1
  10. if user_exists $uid; then
  11. true
  12. else
  13. echo "User $uid does not exist."
  14. exit 1
  15. fi
  16. [ -z "$confirmed" ] && read -p "Are you sure you want to delete user $uid [y/N] " a
  17. case $a in
  18. y*|o* )
  19. confirmed="true";;
  20. *)
  21. confirmed="false";;
  22. esac
  23. if [ $confirmed = "true" ]; then
  24. if user_is_posix $uid; then
  25. ldapdelete $LDAPOPTS cn=$uid,$GROUPSDN
  26. ./removefromgroups $uid $(get_posixGroups $uid)
  27. fi
  28. ldapdelete $LDAPOPTS uid=$uid,$PEOPLEDN
  29. fi