#!/usr/bin/ksh #---------#---------#---------#---------#---------#---------#---------#--------- # Title: change entries in an LDAP database using iplanet ldapmodify utility # Creator: larg 15 dec 02 # Description: This is a wrapper for Netscape "ldapmodify" utility, allows # to add or change entries to the LDAP directory # according to provided input file in .ldif format # Notes: Configuration file must contain proper values # ldif file must be in unix format. ldapmodify does not like # PC-style cr/lf line endings. # #---------#---------#---------#---------#---------#---------#---------#--------- # check supplied options if [ $# -lt 1 ] then echo "Usage: $0 " echo "" echo "Example:" echo " $ $0 example-add.ldif" echo "" exit 1 fi if [ ! -f $LDAP_CONF ] then echo "Can't open the configuration file: $LDAP_CONF" exit 2 fi if [ ! -f "$1" ] then echo "Can't open input file: \"$1\"" exit 3 fi # read configuration file CONF_FILE=ldap.conf if [ ! -f $CONF_FILE ] then echo "Can't open the configuration file: $CONF_FILE " exit 2 fi HOST=$(cat $CONF_FILE | grep "^host" | awk -F\t '{ print $2}') USER=$(cat $CONF_FILE | grep "^user" | awk -F\t '{ print $2}') PASS=$(cat $CONF_FILE | grep "^pass" | awk -F\t '{ print $2}') BASE=$(cat $CONF_FILE | grep "^base" | awk -F\t '{ print $2}') PORT=$(cat $CONF_FILE | grep "^port" | awk -F\t '{ print $2}') if [ -z "$HOST" -o -z "$USER" -o -z "$PASS" -o -z "$BASE" ] then echo "Can't find values in the configuration file $CONF_FILE " # exit 3 fi # setup # where is the ldapsearch executable? BIN=/opt/iplanet/ids416/shared/bin # #BIN=$(pwd) export LD_LIBRARY_PATH=$BIN # this relies on the environment variable PWD existing SCRIPT=$PWD # modify cd $BIN ./ldapmodify -a -c -D "$USER" -w "$PASS" -h $HOST \ -p $PORT -f $SCRIPT/$1 # done