LDAP Addressbook

Credits

Various bits of code, scripts, and procedures were put together with information from John Simpson's qmail.jms1.net website. It's an excellent resource on managing and setting up a Qmail server.

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.
Add the inetorgperson.schema to your LDAP server config in /usr/local/etc/openldap/slapd.conf. It's dependent on having the cosine.schema:

include         /usr/local/etc/openldap/schema/cosine.schema
include         /usr/local/etc/openldap/schema/inetorgperson.schema

Restart the LDAP server:

svc -t /service/slapd

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=*'

SSL Configuration
Edit /usr/local/etc/openldap/slapd.conf and add the certificate from your email install:

TLSCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
#TLSCipherSuite ALL:!NULL
TLSCertificateFile /var/qmail/control/servercert.pem
TLSCACertificateFile /var/qmail/control/servercert.pem
TLSCertificateKeyFile /var/qmail/control/servercert.pem

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/onchange 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

AttachmentSize
Plain text icon vpopLDAPaddress.pl.txt4.02 KB

Recent Updates

  • 8 months 3 weeks ago
    1.27.2 update
  • 9 months 6 days ago
    Drupal 10/11 config
  • 9 months 1 week ago
  • PHP
    9 months 1 week ago
    PHP 8.3.11 and AlmaLinux
  • 9 months 1 week ago
    New version of Pound