From: "jim on
Hi,

I have inherited a postfix MDA that I'm just trying to understand and we
currently have a problem with the forwarding of emails using LDAP lookups.

Currently an email is forwarded if it matches the below map:

virtual_alias_maps = ldap:ldapforward
ldapforward_query_filter =
(&(|(mail=%s)(mailalternateaddress=%s))(mailforwardingaddress=*))
ldapforward_result_attribute = mailforwardingaddress

Now if we have the following 2 LDAP users:

mail=bob(a)somedomain.com

mail=fred(a)somedomain.com
mailalternateaddress=catchall(a)somedomain.com
mailforwardingaddress=fred(a)elsewhere.com

The initial lookup doesnt match against bob as he has no mailforward,
but then the postfix catchall lookup matches against the 2nd address and
forwards the email that should of gone to bob.

Whats the solution for this setup? How do I stop LDAP filters matching
the catchall mailbox when a more specific one exists without a mailforward?

We will need to do similar things to this later with AV & anti-spam
where we will need to match against bob and only match against catchall
when there is no bob email account etc. I have been searching but havent
found solutions to this problem, I'm guessing we are doing it wrong if
others dont have this issue.

Thanks in advance.

Jim.

From: Wietse Venema on
jim(a)scusting.com:
> Hi,
>
> I have inherited a postfix MDA that I'm just trying to understand and we
> currently have a problem with the forwarding of emails using LDAP lookups.
>
> Currently an email is forwarded if it matches the below map:
>
> virtual_alias_maps = ldap:ldapforward
> ldapforward_query_filter =
> (&(|(mail=%s)(mailalternateaddress=%s))(mailforwardingaddress=*))
> ldapforward_result_attribute = mailforwardingaddress
>
> Now if we have the following 2 LDAP users:
>
> mail=bob(a)somedomain.com
>
> mail=fred(a)somedomain.com
> mailalternateaddress=catchall(a)somedomain.com
> mailforwardingaddress=fred(a)elsewhere.com
>
> The initial lookup doesnt match against bob as he has no mailforward,
> but then the postfix catchall lookup matches against the 2nd address and
> forwards the email that should of gone to bob.
>
> Whats the solution for this setup? How do I stop LDAP filters matching
> the catchall mailbox when a more specific one exists without a mailforward?

This requires a one-to-one virtual alias mapping:

bob(a)example.com -> bob(a)example.com

By design, virtual aliasing stops when a right-hand side address
matches the left-hand side (of course it also stops when a right-hand
side address fails to match the virtual alias table).

Wietse