postfix, ldap and mailforward

I wanted to setup and postfix based on ldap with the following features:

  • each user in ldap-structure has one mailbox
  • each user can have one or more mailadresses that will end in the users mailbox
  • each user can have one or more forwardadresses



Solution:

Using standard ldap-users with following ObjectClasses:

  • posixAccount
  • shadowAccount
  • mailUser (from a non-standard ldap-mail-schema - see below)



The following attributes are relevant for the above features:

  • uid : username and name of the mailbox where the mail is delivered
  • mail: one or more adresses of this user
  • mailAlternateAddress: one or more forwarding adresses



I enabled virtual_maps in postfix/main.cf:

virtual_maps = ldap:/etc/postfix/ldap-aliases.cf



and ldap-aliases.cf looks like:


server_host = ldap://127.0.0.1

search_base = dc=ihf,dc=local
query_filter = (mail=%s)

result_attribute = uid, mailAlternateAddress

version = 3



The mailUser-schema


I found this schema on the internet, cause I didnt want to use the qmail-schema which was much to big and complex for my needs and I didnt want to use the misc-schema, cause many sources tell you not to do !!

attributetype ( 1.3.6.1.4.1.7914.1.2.1.4 NAME 'mailAlternateAddress'
 DESC 'Secondary (alias) mailaddresses for the same user'
 EQUALITY caseIgnoreIA5Match
 SUBSTR caseIgnoreIA5SubstringsMatch
 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )

attributetype ( 1.3.6.1.4.1.7914.1.2.1.5 NAME 'mailDrop'
        DESC 'Where to drop or send the message'
        EQUALITY caseIgnoreIA5Match
        SUBSTR caseIgnoreIA5SubstringsMatch
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )

attributetype ( 1.3.6.1.4.1.7914.1.2.1.7 NAME 'mailForwardingAddress'
 DESC 'Address(es) to forward all incoming messages to.'
 EQUALITY caseIgnoreIA5Match
 SUBSTR caseIgnoreIA5SubstringsMatch
 SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )

# Object Class Definitions

objectclass ( 1.3.6.1.4.1.7914.1.2.2.1 NAME 'mailUser'
 DESC 'Mail-LDAP User'
 SUP top
 AUXILIARY
 MUST ( cn $ mail )
 MAY ( uid $ userPassword $ mailAlternateAddress $
       mailForwardingAddress $ mailDrop ) )
 
knowwiki/howtos/postfix_ldap_mailforward.txt · Last modified: 2007/01/27 13:43