Re: [exim] LDAP / Virtual Domains

Top Page
Delete this message
Reply to this message
Author: Hans-Juergen Beie
Date:  
To: exim-users
Subject: Re: [exim] LDAP / Virtual Domains

James Davis wrote on 15.11.2005 13:52 Uhr:
> I have users, for example
>
> dn: cn=James Davis,ou=people,ou=Operations,ou=Jolt,dc=jolt,dc=co,dc=uk
>
> with the attributes
>
> uid: james
> mail: james@???
> gosaMailAlternateAddress: postmaster@???
> gosaMailAlternateAddress: james@???
>
> What I'd like to do is on receipt of a message, exim search through the
> mail and gosaMailAlternateAddress attributes within dc=jolt,dc=co,dc=uk
> for a matching entry for the recepient for that message. Exim then

delivers it to the account specified with the uid through the following
transport
>
> cyrus_delivery:
>     driver = lmtp
>     socket = /var/run/cyrus/socket/lmtp
>     batch_max = 20
>     user = mail


That transport is exactly the same what i'm using. Probably copied from
the same source ;)

> Any ideas how I need to tweak my configuration to achieve this? I've

looked around for examples but nothing seems to be written quite at my
level :-) Currently I'm serving virtual domains using
>
> domainlist local_domains = @:localhost:dsearch;/etc/exim4/virtual
>
> and

[...]

I didn't analyze your configuration in detail, but perhaps it may be
useful to have a look at the routers i'm using for a similar task:
deliver mails to local and several virtual domains including forwarding
and alternate addresses. The ldap schemas are GOsa out-of-the-box ones. I
don't claim that my setup is the ultimate exim4-gosa-solution, but it
works. That's all ;)

> Regards,
>
> James


hjb :-?

P.S. I noticed that you have posted a similar question on the GOsa
mailinglist. I was in doubt whether to answer here or there.
# these are "our very own" domains
domainlist real_local_domains = CONFDIR/local_domains

# virtual domains hostet by our MX
domainlist virtual_domains = CONFDIR/virtual_domains

# all together now...
domainlist local_domains = +no_domain : +real_local_domains : +virtual_domains

[...]

###
begin routers
####

[...]

#
# The remaining routers handle addresses in the local (including 'virtual') domain(s).
#

real_local:
debug_print = "R: real_local for $local_part@$domain"
driver = accept
domains = +local_domains
local_part_prefix = real-
check_local_user
transport = LOCAL_DELIVERY

userforward:
  debug_print = "R: userforward for $local_part@$domain"
  driver = redirect
  domains = +local_domains
  check_local_user
  file = $home/.forward
  no_verify
  no_expn
  check_ancestor
  allow_filter
  directory_transport = address_directory
  file_transport = address_file
  pipe_transport = address_pipe
  reply_transport = address_reply
  skip_syntax_errors
  syntax_errors_to = real-$local_part@$domain
  syntax_errors_text = \
    This is an automatically generated message. An error has\n\
    been found in your .forward file. Details of the error are\n\
    reported below. While this error persists, you will receive\n\
    a copy of this message for every message that is addressed\n\
    to you. If your .forward file is a filter file, or if it is\n\
    a non-filter file containing no valid forwarding addresses,\n\
    a copy of each incoming message will be put in your normal\n\
    mailbox. If a non-filter file contains at least one valid\n\
    forwarding address, forwarding to the valid addresses will\n\
    happen, and those will be the only deliveries that occur.



# If you still want to deliver some messages to a mail spool then use
# this transport, changing the local_parts as necessary.
#
copy_to_mbox:
debug_print = "R: copy_to_mbox for $local_part@$domain"
driver = accept
unseen
local_parts = postmaster
transport = mail_spool


#
# gosa related routers
#
# Found in ...
#   From: Czako Krisztian <slapic@???>
#   To: Gosa lista <gosa@???>
#   In-Reply-To: <1083851716.31804.58.camel@???>
#   References: <29096.1083784571@???>
#      <1083851716.31804.58.camel@???>
#   Content-Type: text/plain; charset=ISO-8859-2
#   Organization: Pilatus-Comp Kft.
#   Message-Id: <1083859991.31802.67.camel@???>
#
# ... and adapted for our needs.


  #
  # aliases defined with gosa:
  # lookup gosaMailAlternateAddress of gosaMailAccount
  #
  gosa_aliases:
    debug_print = "R: gosa_aliases for $local_part@$domain"
    driver = redirect
    domains = +local_domains
    allow_fail
    allow_defer
    data = ${lookup ldap \
        {ldap:///dc=our,dc=net?mail?sub?\
            (&(|(mail=$local_part@$domain)(gosaMailAlternateAddress=$local_part@$domain))\
              (objectClass=gosaMailAccount)\
            )\
        }\
    }                                    



  #
  # forwarding addresses defined with gosa:
  # lookup gosaMailForwardingAddress of (gosaMailAlternateAddress or gosaMailAccount)
  #
  gosa_forward:
    debug_print = "R: gosa_forward for $local_part@$domain"
    driver = redirect
    domains = +local_domains
    allow_fail
    allow_defer
    check_ancestor
    # 'unseen' will feed the receipients found here again into the router queue
    unseen
    data = ${lookup ldap \
                {ldap:///dc=our,dc=net?gosaMailForwardingAddress?sub?\
                        (&(|(mail=$local_part@$domain)(gosaMailAlternateAddress=$local_part@$domain))\
                    (objectClass=gosaMailAccount)\
                        )\
                }\
            }


  #
  # conventional aliases
  # it's important to have these routers after the gosa routers, to be able to
  # deliver to maiboxes like webmaster@* in different domains
  #
  system_aliases:
    debug_print = "R: system_aliases for $local_part@$domain"
    driver = redirect
    domains = +local_domains
    allow_fail
    allow_defer
    data = ${lookup{$local_part}lsearch{/etc/aliases}}
    file_transport = address_file


  our_aliases:
    debug_print = "R: our_aliases for $local_part@$domain"
    driver = redirect
    domains = +real_local_domains
    allow_fail
    allow_defer
    data = ${lookup{$local_part}lsearch{CONFDIR/our_aliases}}
    file_transport = address_file


  virtual_aliases:
    debug_print = "R: virtual_aliases for $local_part@$domain"
    driver = redirect
    domains = +virtual_domains
    allow_fail
    allow_defer
    require_files = CONFDIR/alias.d/$domain
    data = ${lookup{$local_part}lsearch{CONFDIR/alias.d/$domain}}
    file_transport = address_file


  #
  # local users without cyrus mailbox
  #
  local_user:
    debug_print = "R: local_user for $local_part@$domain"
    driver = accept
    domains = +real_local_domains
    check_local_user
    local_parts = ! root
    transport = mail_spool
    #cannot_route_message = Unknown user