| 12345678910111213141516171819202122232425262728293031323334 |
- #!/bin/bash
- . /etc/ldap-utils.conf
- . /usr/local/lib/ldap-utils/funcs
- # Check if option -y is passed
- if [ "$1" = "-y" ]; then
- confirmed="true"
- shift
- fi
- uid=$1
- if user_exists $uid; then
- true
- else
- echo "User $uid does not exist."
- exit 1
- fi
- [ -z "$confirmed" ] && read -p "Are you sure you want to delete user $uid [y/N] " a
- case $a in
- y*|o* )
- confirmed="true";;
- *)
- confirmed="false";;
- esac
- if [ $confirmed = "true" ]; then
- if user_is_posix $uid; then
- ldapdelete $LDAPOPTS cn=$uid,$GROUPSDN
- removefromgroups $uid $(get_posixGroups $uid)
- fi
- ldapdelete $LDAPOPTS uid=$uid,$PEOPLEDN
- fi
|