Re: [exim] howto set macros depending on ldap request

Góra strony
Delete this message
Reply to this message
Autor: Jeremy Harris
Data:  
Dla: exim-users @ exim. org
Temat: Re: [exim] howto set macros depending on ldap request
Jonas Meurer wrote:
> at least it works to set this macro after the router with ldap lookup.
> i need this to set the path to the Maildir dynamicly.


Um, no.

> is there a better
> way to do so?


Avoid it. You don't need a macro, I think.

>
>
>
>>>.ifdef ${extract{mailMessageStore}{$address_data}}
>>
>>This isn't exim syntax at all. I'm guessing your installation
>>runs a set of files through some preprocessor to produce an
>>exim config file, and you got the idea from there? Debian, maybe?
>>Perhaps there's a mailinglist dedicated to exim on that installation
>>which might better help you?
>
>
> yes, i use the splitted configuration scheme from debian, but this is
> indeed exim4 syntax.
>
> i have the following configuration:
> --snip--
> # macros:
> ldap_default_servers = 127.0.0.1::389
> BASEDN = ou=mail,ou=accounts,dc=resivo,dc=mejo,dc=net
> GET_ADDRESS_DATA = ${lookup ldap \
>     {ldap:///BASEDN??sub?(&(uid=${quote_ldap:$local_part}@${quote_ldap:$domain}))}}
> GET_CATCHALL_DATA = ${lookup ldap \
>     {ldap:///BASEDN??sub?(&(uid=catchall@${quote_ldap:$domain}))}}

>
> # routers:
> lookup:
> driver = redirect
> address_data = GET_ADDRESS_DATA
> data =
>
> localdelivery:
> driver = accept
> condition = ${if match {${extract{uid}{$address_data}}}{$local_part@$domain} {1}{0}}
> user = mail
> group = mail
> transport = maildir_home
> --snip--
>
> ${extract{mailMessageStore}{$address_data}} is the value of
> mailMessageStore out of the ldap lookup result in $address_data.
>
> what's wrong with that?


No problem, on it's own.

>
> or do you mean the usage of .ifdef?


Yes. That isn't exim syntax. I'm guessing it's preprocessor syntax,
in which case it get evaluated at preprocessing time, i.e. when you
install the exim setup. At such a time, $address_data is meaningless -
so the preprocessor cannot make use of it.

> is it for exim4 macros only? how can
> i verify that ${extract{mailMessageStore}{$address_data}} has a value
> before setting MAILDIR_HOME_MAILDIR_LOCATION?


You don't need to set a macro. Just condition the running of a router
using the result of that extract. Use and/or to combine conditions
as needed (details in the exim docs).

- Jeremy