exim4 and SMTP auth against ldap

Introduction

In this small HOWTO I want to give you some ideas how to setup a smtp auth against an ldap directory server with exim4. We will use LDAP Auth to check the user/password. This is not a "in-deepth tutorial", but a small guide with examples, you could use for your own setup. (for me the most difficult part on every exim related setup, is the translation from the basic idea to the the strange exim prefix-operator-syntax).
I asume you have set up your ldap server and it everything works fine. In the examples I will use dc=example, dc=net as base-dn and look for user entries under ou=People, dc=example, dc=com.

The config sniped

First of all here is the part of the config which enables the authentification:



ldap_default_servers = ldap.example.com::636

begin authenticators

 plain_server:
   driver = plaintext
   server_advertise_condition = ${if match{$sender_host_address}{\N^10\.0\.0\.\d{1,3}\N}{0}{1}}
   public_name = PLAIN
   server_condition = ${if ldapauth \
    {user="uid=${quote_ldap_dn:$2},ou=People,dc=example,dc=com" \
    pass=${quote:$3} \
    ldaps:///}{yes}{no}}
   server_set_id = $2
   server_prompts = :

 login_server:
   driver = plaintext
   server_advertise_condition = ${if match{$sender_host_address}{\N^10\.0\.1\.\d{1,3}\N}{0}{1}}
   public_name = LOGIN
   server_prompts = "Username:: : Password::"
   server_condition = ${if ldapauth \
    {user="uid=${quote_ldap_dn:$1},ou=People,dc=example,dc=com" \
    pass=${quote:$2} \
    ldaps:///}{yes}{no}}
   server_set_id = $1
				


The explanation

Now some explanations about the stuff up there. I hope this helped you a little bit. The most importent source of information is: The Exim Documentation.

by Markus Barenhoff <mbarenh at alios dot org> (c)2005