#!/bin/bash
##  Copyright (c) 2004  Code Fusion cc
##
##  This  program is free  software; you can redistribute  it and/or
##  modify it  under the terms of the GNU  General Public License as
##  published by the  Free Software Foundation; either version 2, or
##  (at your option) any later version.
##
##  This program is  distributed in the hope that it will be useful,
##  but WITHOUT  ANY WARRANTY; without even the  implied warranty of
##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
##  General Public License for more details.
##
##  You can view the  GNU General Public License, online, at the GNU
##  Project's homepage; see <http://www.gnu.org/licenses/gpl.html>.
##
PATH=/usr/bin

if [ ".$1" = ".--help" ]; then
	echo "Display a list of mailboxes"
	exit 0
	HASHELP
fi

SERVER=127.0.0.1
BINDDN=`sed -n 's;bind_dn : ;;p' /etc/kolab/kolab.conf`
BINDPW=`sed -n 's;bind_pw : ;;p' /etc/kolab/kolab.conf`
BASEDN=`sed -n 's;base_dn : ;;p' /etc/kolab/kolab.conf`

ldapsearch -x -LLL -b "$BASEDN" -D "$BINDDN" -w $BINDPW -h $SERVER "(&(objectClass=kolabInetOrgPerson)(mail=*))" mail | sed -n "s;mail: ;;p"

