Re: [exim] server_condition syntax help?

Top Page
Delete this message
Reply to this message
Author: Jakob Hirsch
Date:  
To: 'Exim-users'
Subject: Re: [exim] server_condition syntax help?
Joe Kocsis wrote:

> What Im trying to accomplish is something like this..
>
> server_condition = ${if eq{$1}{${lookup mysql{SELECT Account FROM
> UserSession WHERE (Account='$1' or Account='$1@???') and
> Password='$2'}{$value}fail}}{1}{0}}
>
> I need to be able to authenticate if the domain is left off and would
> like to supply a default domain.. ex: domain.com


What you wrote above should work, I think, though you can simply it:

${lookup mysql{
SELECT 'yes' FROM UserSession
WHERE (Account='${quote_mysql:$1}'
OR Account='${quote_mysql:$1@???}')
AND Password='${quote_mysql:$2}'}
{yes}fail}

You should really use quote_mysql for any remote-given input you send to
mysql.

You can also use two different queries depending on if there is a '@' in
the username. Or oven put ${if !match {$1}{@} {@domain.com}} in the
query. But I don't think it's worth this hassle.

BTW, I'd recommend to allow different separators (e.g. !#%) between
localpart and domain, since there are some MUAs that can't handle @ in
the username.