#!/bin/bash . /etc/ldap-utils.conf . /usr/local/lib/ldap-utils/funcs # Check if option -p is passed, and if so prepare for a posixGroup creation if [ "$1" = "-p" ]; then posix="true" shift else posix="false" fi cn="$1" if group_exists $cn; then echo "Group $cn already exists." exit 1 fi uid="$2" if user_exists $uid; then true else echo "User $uid does not exist." exit 1 fi group="dn: cn=$cn,$GROUPSDN objectClass: top objectClass: groupOfNames cn: $cn" if [ $posix = "true" ] ; then group=$(echo "$group gidNumber: $(get_posix_number)") group=$(echo "$group memberUid: uid=$uid,$PEOPLEDN") else group=$(echo "$group member: uid=$uid,$PEOPLEDN") fi echo "$group" | ldapadd $LDAPOPTS