


Hi All,
Here's the 21st tip in the "OpenLDAP Quick Tips" series kindly contributed by Vincent van Gelder.
"You need to carry out LDAP
[?] operations using shell scripts".
The following is an example sent in by Vincent van Gelder (you can
e-mail your tip to us too):
------------------------
The following script I use when interacting with ldap
[?] from shell scripts:
http://members.tripod.com/vgoenka/unixscripts/unldif.sed.txt
Sample script:
CODE:
######################################
#!/bin/bash
PHOTO=/tmp/tux.jpg
IFS=$'\n'
for dn in $(ldapsearch -ZZ -LLL -A -b
'ou=Users,ou=Intranet,o=Company,c=NL' -s one
'(&(!(jpegPhoto=*))(objectClass=inetOrgPerson))' jpegPhoto \
| unldif | grep '^dn' )
do
echo $dn
echo "changetype: modify"
echo "add: jpegPhoto"
echo "jpegPhoto::$(openssl base64 -in $PHOTO | sed 's/^/ /')"
echo
done
######################################
The sample script fetches users from ldap whithout a photo and adds a
default photo. Output is a ldif.
It also demonstrates how to add binary attributes from shell using
openssl tool.
The unldif script makes sure the dn is always just one line.
--
Met vriendelijke groet,
Vincent van Gelder
------------------------
Thanks,
Gavin.
If you have an entry for our "OpenLDAP Quick Tips" series, why not e-mail your tip to us.
P.S. For direct access to this section, you can click
OpenLDAP Quick Tips.