#!/usr/bin/env bash

eval `ultrapossum-config init`

tmp=`tempfile`
trap "/bin/rm -f $tmp; eval `ultrapossum-config term`" 0

base=$SUFFIX
if test "x$1" != "x"; then
  base=$1,$SUFFIX
fi

ldapsearch -LLL -x -s one -h $MASTER -b $base 'objectClass=*' dn  | egrep -v "^$" > $tmp
if test "x`wc -l $tmp | cut -d' ' -f1`" = "x0"; then
  ldapsearch -LLL -x -s base -h $MASTER -b $base
else
  cat $tmp
fi
