Συντάκτης: Brian Candler Ημερομηνία: Προς: Christiaan den Besten Υ/ο: exim-users Αντικείμενο: Re: [exim] LDAP, multiple results ?!
On Wed, Apr 06, 2005 at 12:15:43PM +0200, Christiaan den Besten wrote: > All our recipient data is stored in LDAP, this includes an extra
> entry for 'catch-all' adresses. These entry's have a
> 'mailForwardingAddress' attribute that I would like to access in a
> redirect router.
>
> But, it should take the attribute from the recipients if it has
> one, -or- it should take the attribute from the catch-all entry ...
> which offcourse gives me all kind of 'multiple results' errors if
> both are the case. I have been expirimenting with {$ extract }, but
> it doesn't seem to help either.
>
> The lookups are defined as follow:
>
> ${lookup ldap
> {ldap:///ou=$domain,ou=Domain,o=custdomain,c=nl?mailForwardingAddress?sub?(|(mail=${quote_ldap:$local_part@$domain})(mail=[catchall]${quote_ldap:@$domain}))}}
>
> Any clue how to only extract only the first result ? (if both match)
If your ldap query matches multiple entries, as yours will, then you can use
'ldapm' to get them both, separated by newline. However it will be
indetermine which way round they are. That means including the key in the
response:
Remembering that each entry may have multiple values for the
mailForwardingAddress attribute, then the result of this LDAP lookup may
look something like this:
You could then use some very nasty sg{}ing to (1) extract the one line you
are interested in, and (2) join together all the mailForwardingAddress
attributes into a comma-separated list.
Personally, I'd just do two LDAP lookups: one looking for
$local_part@$domain, and if that fails, a subsequent one for
[catchall]@$domain. If you make the assumption that most incoming mail will
hit a specific user entry rather than the catchall, then you are not
suffering a big performance hit.