#!/bin/bash . .env user_exists() { res=$($PEOPLESEARCHCMD "(&(uid=$1)(objectClass=inetOrgPerson))" | grep uid: | cut -f2 -d' ') [ -n "$res" ] } group_exists() { res=$($GROUPSEARCHCMD "(cn=$1)" | grep cn: | cut -f2 -d' ') [ -n "$res" ] } mail_exists() { res=$($PEOPLESEARCHCMD "(|(mail=$1)(mailAlias=$1))") [ -n "$res" ] } user_is_posix() { res=$($PEOPLESEARCHCMD "(&(uid=$1)(objectClass=posixAccount))" | grep uid: | cut -f2 -d' ') [ -n "$res" ] } user_is_postfix() { res=$($PEOPLESEARCHCMD "(&(uid=$1)(objectClass=PostfixBookMailAccount))" | grep uid: | cut -f2 -d' ') [ -n "$res" ] } group_is_posix() { res=$($GROUPSEARCHCMD "(&(cn=$1)(objectClass=posixGroup))" | grep cn: | cut -f2 -d' ') [ -n "$res" ] } get_posixGroups () { $GROUPSEARCHCMD "(&(memberUid=$1)(objectClass=posixGroup))" | grep cn: | cut -f2 -d' ' } # get the list of currently used uid numbers and add 1 to get the next one # uids between 2000 and 2999 are used for users. If the need to manage # more than 1000 users arises, consider using something else than a few bash scripts # to manage your directory. get_posix_number() { echo $(( $($PEOPLESEARCHCMD "(objectClass=posixAccount)" | grep 'uidNumber: 2' | cut -d' ' -f2 | sort -u | tail -n 1) +1)) }