#!/bin/bash
# Samba-TNG                                          delete_unix_group
# --------------------------------------------------------------------

# --------------------------------------------------------------------
# config here

. ./prefs

# --------------------------------------------------------------------
# print usage

if [ "$1" == "" ]; then
        echo "Usage: $(basename $0) <group>"
        exit 0
fi

# --------------------------------------------------------------------
# begin

mygroup=`$ldapsearch -D $binddn -w $bindpassword -b $groupsuffix cn="$1" -LLL|grep dn:|awk '{print $2" " $3" " $4" " $5" "$6}'`
if [ "$mygroup" == "" ]; then
        echo "Group not known!"
        exit 1
fi

echo $mygroup

$ldapdelete \
	    -D $binddn \
	    -w $bindpassword \
	    "$mygroup"

echo "Group deleted"

exit 0

# --------------------------------------------------------------------
