Loading jpegs with ldapmodify

Just a quick note on how to do this. The man page, as usual, is not a literary masterpiece.

First, very important. If you’ve converted your image file from another format do yourself a favor and pass the resulting jpeg through a good image manipulation tool like the GIMP. Badly executed conversion will result in encoding errors during the import process.

Here’s what your sample LDIF will look like:

# File loadphotos.ldif
dn: uid=rkimball,ou=people,dc=example,dc=com
changetype: modify
add: jpegphoto
jpegphoto:< file:///data/tmp/rkimball.jpeg

dn: uid=crood,ou=people,dc=example,dc=com
changetype: modify
add: jpegphoto
jpegphoto:< file:///data/tmp/crood.jpeg

Here’s the command line:

ldapmodify -h ldap.example.com -D "cn=directory manager" -w xxxxx 
-f loadphotos.ldif

That’s pretty much it, except remember to keep your images as small as possible (that means lower res than most people are going to like) because LDAP entry size will affect search performance (most web applications actually store the photo on the file system and use a custom attribute in each entry to store a link to the location that photo can be found).