#!/bin/bash
##########################################################
# (C) ZE CMS, Humboldt-Universitaet zu Berlin
# Written 2014 by Daniel Rohde <d.rohde@cms.hu-berlin.de>
##########################################################
# removes: 
#   LDAP user group 
#   LDAP user entry
#   user home directory

if [ $# = 0 ] ; then
        echo "Usage: $0 user [user2 [user3 ...]]"
        exit 1
fi

. $(dirname $0)/config

while (( "$#" )) ; do
	user=$1
	ldapdelete -x -h $LDAP_HOST -D $LDAP_ADMIN -w $LDAP_ADMINPW <<EOF
uid=$user,$LDAP_USERS

cn=$user,$LDAP_GROUPS

EOF
	sudo -A rm -r /home/$user
	shift
done
