[Dovecot] domain stripping

Adrian Stoica adrian.stoica at dacris.net
Thu Jan 20 08:13:51 EET 2011


You could use just sql to query for the username or username at domain like 
this ( i'm not a sql guru so any optimization is welcome) , this is how 
it works on my server with mysql (see user_query) :

password_query = SELECT mailbox.password FROM mailbox,domain WHERE \
     domain.default = '1' AND \
     (mailbox.username = '%Ln' AND mailbox.domain = '%Ld' ) OR \
     (mailbox.username = '%Ln' AND mailbox.domain = domain.domain ) AND \
     mailbox.active = '1'

user_query = SELECT CONCAT('/srv/vmail/',mailbox.domain,'/%Ln') AS 
'home' ,'98' AS 'uid', '98' AS 'gid' , \
     CONCAT('*:storage=', mailbox.quota,'M') AS quota_rule FROM 
mailbox,domain WHERE \
     domain.default = '1' AND \
     (mailbox.username = '%Ln' AND mailbox.domain = '%Ld' ) OR \
     (mailbox.username = '%Ln' AND mailbox.domain = domain.domain ) AND \
     mailbox.active = '1'


Adrian Stoica

On 1/19/2011 7:36 PM, PA wrote:
> Hi, using dovecot 2.0 and I'm using a couple of user DBs, sql/prefetch and
> pam. Currently if the user logins with username at domain it authenticates off
> the sql DB and works fine. If the user logins with username with no @domain
> it fails on the sql lookup and succeeds on the pam user DB.
>
> However I was wondering if I can have another sql DB lookup that says when
> the user logins and fails against the first two user DBs, sql/pam db, to try
> this last sql user DB and appends a default domain to it, because the sql DB
> lists username with the domain. Currently I have all users login in with no
> realm on the older mail server and I wanted to migrate these users to
> dovecot 2.x with minimal impact and wanted to have the ability for these
> virtual users to login with and without a realm.
>
>
>
>   Thanks paul.
>
>

-- 



*DACRIS*
Papetãrie & Tipografie

Otopeni - ROMÂNIA, Jud. Ilfov
Str. Ardealului nr.9F
TEL.: (004) 021 350 67 57
FAX: (004) 021 350 67 59

e-mail: office at dacris.net <mailto:office at dacris.net>
www.dacris.net <http://www.dacris.net>
Adopta atitudinea VERDE
Printeaza acest document doar daca ai cu adevarat nevoie.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: adrian_stoica.vcf
Type: text/x-vcard
Size: 195 bytes
Desc: not available
Url : http://dovecot.org/pipermail/dovecot/attachments/20110120/2106dac0/attachment.vcf 


More information about the dovecot mailing list