Linux

Offline slapd cn=config editing

So, the olc config method of slapd is pretty nice, but sometimes it’s just easier to quickly edit the files directly in the slapd.d directory. Nasty side effect is that slapd will ignore files that fail the crc32 check.

Here is a simple script you can use to edit the file and recalculates the crc32 for you so slapd will read the file. Let me remind you that this method is not preferred (you should learn how to use ldapmodify)!

You also need the tool “crc32”.
Ubuntu / Debian:

apt-get install libarchive-zip-perl

CentOS:

wget http://www.csbruce.com/~csbruce/software/crc32.c && gcc -Wall -O3 -o /usr/local/bin/crc32 crc32.c

Now create this script (put it in /usr/local/bin) and name it ldapedit or something:

#!/bin/bash
basedir=`dirname "$1"`
tmpfile=`mktemp --tmpdir="$basedir"` || exit 1
tail -n +3 "$1" > "$tmpfile"
${EDITOR:-vim} "$tmpfile"
echo -en "# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.\n# CRC32 " > "$1"
crc32 "$tmpfile" >> "$1"
cat "$tmpfile" >> "$1"
rm -fv "$tmpfile"

(Script by gurubert over at http://gurubert.de/node/246)

Now you just open the file with this script, edit, save and close, voila.

Leave a Reply

Your email address will not be published.

*