Messing around with Heiko's issue I started trying to
lay out some example coding, and ran into some brainfade.
I'd got to here:
${if forany \
{mail:EximMailPrimaryAddress:EximMailAlternateAddress} \
{inlisti {$local_part} \
{<, ${extract {$item} \
{${lookup
ldapm{ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4}}}\
}\
}\
}\
}
and, replacing the $local_part for testing, failed like so:
> ${if forany \
{mail:EximMailPrimaryAddress:EximMailAlternateAddress} \
{inlisti {user4alternate2@???} \
{<, ${extract {$item} \
{${lookup
ldapm{ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4}}}\
}\
}\
}\
}
expanding: mail:EximMailPrimaryAddress:EximMailAlternateAddress
result: mail:EximMailPrimaryAddress:EximMailAlternateAddress
expanding: user4alternate2@???
result: user4alternate2@???
skipping: result is not used
expanding: $item
result:
skipping: result is not used
expanding: ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4
result: ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4
skipping: result is not used
expanding: ${lookup
ldapm{ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4}}
result:
skipping: result is not used
failed to expand: <, ${extract {$item} {${lookup
ldapm{ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4}}}}}}}
error message: missing or misplaced { or }
failed to expand: ${if forany
{mail:EximMailPrimaryAddress:EximMailAlternateAddress} {inlisti
{user4alternate2@???} {<, ${extract {$item} {${lookup
ldapm{ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4}}}}}}}
error message: missing or misplaced { or } inside "forany" condition
Failed: missing or misplaced { or } inside "forany" condition
>
This looks to be a syntax-check initial run through
the arguments for the forany, failing because $item
is empty and ${extract requires nonempty.
Replace the $item with a dummy and it works.
Ideas?
(full expansion for the working test-hack:)
> ${if forany \
{mail:EximMailPrimaryAddress:EximMailAlternateAddress} \
{inlisti {user4alternate2@???} \
{<, ${extract {EximMailAlternateAddress} \
{${lookup
ldapm{ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4}}}\
}\
}\
}\
}
expanding: mail:EximMailPrimaryAddress:EximMailAlternateAddress
result: mail:EximMailPrimaryAddress:EximMailAlternateAddress
expanding: user4alternate2@???
result: user4alternate2@???
skipping: result is not used
expanding: EximMailAlternateAddress
result: EximMailAlternateAddress
skipping: result is not used
expanding: ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4
result: ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4
skipping: result is not used
expanding: ${lookup
ldapm{ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4}}
result:
skipping: result is not used
expanding: <, ${extract {EximMailAlternateAddress} {${lookup
ldapm{ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4}}}}
result: <,
skipping: result is not used
forany: $item = "mail"
expanding: user4alternate2@???
result: user4alternate2@???
expanding: EximMailAlternateAddress
result: EximMailAlternateAddress
expanding: ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4
result: ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4
search_open: ldapm "NULL"
search_find: file="NULL"
key="ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4"
partial=-1 affix=NULL starflags=0
LRU list:
internal_search_find: file="NULL"
type=ldapm
key="ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4"
database lookup required for
ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4
LDAP parameters: user=NULL pass=NULL size=0 time=0 connect=0
dereference=0 referrals=on
perform_ldap_search: ldapm URL =
"ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4"
server=NULL port=0 sizelimit=0 timelimit=0 tcplimit=0
after ldap_url_parse: host=localhost port=389
ldap_initialize with URL ldap://localhost:389/
initialized for LDAP (v3) server localhost:389
LDAP_OPT_X_TLS_TRY set due to ldap:// URI
binding with user=NULL password=NULL
Start search
ldap_result loop
LDAP entry loop
LDAP attr loop cn:user4
LDAP attr loop mail:user4@???
LDAP attr loop EximMailPrimaryAddress:user4primary@???
LDAP attr loop EximMailAlternateAddress:user4alternate1@???
LDAP attr loop EximMailAlternateAddress:user4alternate2@???
search ended by ldap_result yielding 101
ldap_parse_result: 0
ldap_parse_result yielded 0: Success
LDAP search: returning: cn="user4" mail="user4@???"
EximMailPrimaryAddress="user4primary@???"
EximMailAlternateAddress="user4alternate1@???,user4alternate2@???"
lookup yielded: cn="user4" mail="user4@???"
EximMailPrimaryAddress="user4primary@???"
EximMailAlternateAddress="user4alternate1@???,user4alternate2@???"
expanding: ${lookup
ldapm{ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4}}
result: cn="user4" mail="user4@???"
EximMailPrimaryAddress="user4primary@???"
EximMailAlternateAddress="user4alternate1@???,user4alternate2@???"
expanding: <, ${extract {EximMailAlternateAddress} {${lookup
ldapm{ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4}}}}
result: <, user4alternate1@???,user4alternate2@???
forany: condition evaluated to true
condition: forany {mail:EximMailPrimaryAddress:EximMailAlternateAddress}
{inlisti {user4alternate2@???} {<, ${extract
{EximMailAlternateAddress} {${lookup
ldapm{ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4}}}}}}
result: true
expanding: ${if forany
{mail:EximMailPrimaryAddress:EximMailAlternateAddress} {inlisti
{user4alternate2@???} {<, ${extract {EximMailAlternateAddress}
{${lookup
ldapm{ldap://localhost/ou=users,dc=example,dc=com?mail,cn?sub?cn=user4}}}}}}}
result: true
true
>
--
Cheers,
Jeremy