LDAP and Claws Mail HOWTO based on Kubuntu (7.10)

Exaple describes installation and configuration on Ubuntu 7.10 but should be valid for other distributions also.
It covers:

openldap installation and configuration

claws-mail configuration to use with LDAP

REMOVING OLD INSTALLATION

In case slapd is already installed, either go to point 4 or reinstall it with commands:

sudo apt-get purge slapd

sudo rm -rf /etc/ldap

(in case your LDAP configuration is not yet in use)

sudo rm -rf /var/run/slapd

(in case your LDAP database is not yet filled)

INSTALLATION

Install slapd:

sudo apt-get install slapd

during installation ubuntu usually asks you for ldap admin password - use any - even empty - later we can change it anyway

CONFIGURATION

make sure to shut down LDAP server after installation:

sudo /etc/init.d/slapd stop

folder for storing data:

make directory where you LDAP will store data - by default it is /var/run/slapd bud I don't recommend it for backup purposes (in case your root partition is to be reinstalled - OS crashed or whatever - then LDAP db is also vanished - my proposal is to use i.e. directory /home/ldap

sudo mkdir /home/ldap

Because Ubuntu by default runs slapd daemon as user openldap (created automatically during slapd installation), then we must change the ownership of this directory:

sudo chown -R openldap:openldap /home/ldap

as an alternative is to change default behaviour of slapd in file /etc/default/slapd the line:

SLAPD_USER="openldap"

should be changed to:

SLAPD_USER=

and in this case slapd runs as root and changing ownership is not needed - in this HOWTO we change the ownership to avoid the mismatch with Ubuntu default settings

ok, claws should be ready to cooperate with LDAP
in addressbook you should see now "Myserver" under LDAP Servers
go to field "Lookup name" and type i.e. homonto and press Find
you should see my name there

AUTOMATIC LDAP CREATION AND CONFIGURATION

If you are brave enough you can use the script I prepared to do all steps mentioned above in just one step
Just save all lines to text file, i.e. /tmp/ldap.sh and make it executable: