From Notes
#!/bin/bash
#
# Author: Josh Miller
# Date: 06/30/2006
# Purpose: To update an OpenLDAP DIT, replacing an attribute with a value.
#
# Inputs: -d : distinguished name
# -a : attribute to change
# -t : value to change the preceding attribute to
# -v : verbose - show resulting record
#
BINDDN='cn=Manager,dc=example,dc=org'
BINDPW='ldaptest'
usage () {
echo
echo -e "\t$0 -d \"<distinguishedName>\" -a <attribute> -t <value>"
echo
exit 1
}
if [[ $# -lt 6 || $# -gt 7 ]]
then
usage
fi
while getopts a:d:t:v input
do
case $input in
a) ATTRIBUTE="$OPTARG"
;;
d) DN="$OPTARG"
;;
t) VALUE="$OPTARG"
;;
v) VERBOSE=1
;;
esac
done
ldapmodify -D $BINDDN -x -w $BINDPW <<EOF
dn: $DN
changetype: modify
replace: $ATTRIBUTE
loginShell: $VALUE
EOF
if [[ $VERBOSE -gt 0 ]]
then
ldapsearch -b "$DN" -D $BINDDN -x -w $BINDPW -LLL
fi
exit 0