#!/bin/sh
# 
BASEDN=`grep "^base" /etc/ldap.conf | awk ' { print $2 } '`

case $1 in
-h)
	HOST=$2
	shift; shift
	ldapsearch -x -h $HOST -b "${BASEDN}" cn=*${1}* cn homeDirectory uidNumber gidNumber $*
;;
-g)
	ldapsearch -x -h localhost -b ${BASEDN} "(&(objectClass=posixGroup)(cn=$2))"
;;
-n)
	ldapsearch -x -h localhost -b ${BASEDN} "(&(objectClass=nisNetgroup)(cn=$2))"
;;
*)
	HOST=localhost
	ldapsearch -x -h $HOST -b "${BASEDN}" cn=*${1}* cn homeDirectory uidNumber gidNumber $*
;;
esac
