How can I configure an LDAP map to use one result attribute if it exists, and another if not?
Entries in our LDAP directory have a "uid" attribute, and possibly a "mail" and/or "mailRoutingAddress" attributes 1) If an entry has neither a "mail" attribute nor a "mailRoutingAddress" attribute, then mail to that uid should be delivered normally, and mail from that uid should not be rewritten, e.g. just append $myorigin 2) If an entry has a "mail" attribute and no "mailRoutingAddress" attribute, then mail to that uid should be forwarded to the address in the "mail" attribute, and mail from that uid should be rewritten with the address in the "mail" attribute 3) If an entry has a "mailRoutingAddress" attribute and no "mail" attribute, then mail to that uid should be forwarded to the address in the "mailRoutingAddress" attribute. Mail from that uid should not be rewritten, e.g. just append $myorigin 4) If an entry has both a "mail" attribute and a "mailRoutingAddress" attribute, then mail to that uid should be forwarded to the address in the "mailRoutingAddress" attribute. Mail from that uid should be rewritten with the address in the "mail" attribute. To achieve this, I put in main.cf, alias_maps = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases, ldap:/etc/postfix/ldap-aliases.cf canonical_maps = ldap:/etc/postfix/ldap-canonical.cf - and in /etc/postfix/ldap-aliases.cf, search_base = ou=People,dc=campcoop,dc=com query_filter = uid=%u result_attribute = mailRoutingAddress version = 3 - and in /etc/postfix/ldap-canonical.cf, search_base = ou=People,dc=campcoop,dc=com query_filter = uid=%u result_attribute = mail version = 3 This works great for cases 1), 3), and 4) - but in case 2), where the entry has a "mail" attribute and no "mailRoutingAddress" attribute, mail to that uid is not forwarded to the address in the "mail" attribute To fix this, I tried changing in ldap-aliases.cf, result_attribute = mailRoutingAddress - to - result_attribute = mailRoutingAddress, mail - but now in case 4), where the entry has both a "mail" attribute and a "mailRoutingAddress" attribute, mail to that uid is forwarded to both the addresses in the "mail" attribute and the "mailRoutingAddress" attribute - instead of just to the "mailRoutingAddress" attribute How can I configure ldap-aliases.cf to use the "mailRoutingAddress" attribute if it exists, and the "mail" attribute otherwise?