LDAP Addressbook

in

Provide a centralized addressbook of your server's accounts using OpenLDAP.

http://www.sudleyplace.com/LDAP/index.en.html
http://www.macgeekery.com/hacks/software/shared_address_book_via_ldap
http://www.wickedlush.com/blog/2005/10/06/importing-contacts-from-thunderbird-addressbook-into-ldap/

LDAP Server Installation
http://www.onlamp.com/pub/a/onlamp/2003/03/27/ldap_ab.html

For corporate installations, it can be handy to have a global address book containing the email address of the email users. We'll integrate this addressbook with vpopmail's onchange feature to automatically add or remove addresses from the LDAP server.

These instructions assume that you are going to install OpenLDAP on the same CentOS server that your Qmail server is running on. Installation instructions for OpenLDAP are here.

Once the LDAP server has been configured, you can create a container for the addressbook entries.

cd ~
vi abook.ldif

Insert the container structure into the file:
dn: ou=addressbook, dc=<domain>, dc=com
objectClass: top
objectClass: organizationalUnit
ou: addressbook

Import the LDIF entries into the directory using ldapadd:
ldapadd -D 'cn=Manager,dc=<domain>, dc=com' -f abook.ldif -W

Assuming everything went well, OpenLDAP should now have imported the entries. To verify this did indeed occur, use ldapsearch to dump your directory by specifying objectclass=*:
ldapsearch -b 'dc=<domain>, dc=com' 'objectclass=*'

Squirrelmail Configuration
Squirrelmail can access an LDAP addressbook, however when you configure it, you must specify "3" as the LDAP version otherwise you will get a protocol error.

onchange configuration
In order to have addresses automatically added or removed from the address book, we'll add a script to our onchange program.
In order to run this script, you will need the Net::LDAP Perl module installed!

perl -MCPAN -e shell
install Net::LDAP

Once that is done, install the script:
cd /usr/local/bin
wget http://productionmonkeys.net/sites/productionmonkeys.net/files/vpopLDAPaddress.pl.txt
mv vpopLDAPaddress.pl.txt vpopLDAPaddress.pl
chmod ugo+x vpopLDAPaddress.pl

Edit /usr/local/bin/vpopLDAPaddress.pl and adjust the variables at the beginning to reflect your LDAP server setup (base DN, password, admin DN).

Once those changes are made, add the vpopLDAPaddress.pl script to the onchange script. Edit /home/vpopmail/etc/onchance and add:

/usr/local/bin/vpopLDAPaddress.pl $*

To test if the script is working, add a test domain to your mail server:
/home/vpopmail/bin/vadddomain testdomain.com

And execute a couple queries on your server to see if the
Import Existing vpopmail accounts