quarta-feira, 20 de junho de 2012

dovecot+ispconfig - authenticate user with alias domain

For anyone using ispconfig3 with dovecot ( imap/pop server), the default auth mechanism only allows the user to authenticate with e-mails from the main domain.

If one domain is @domain.com and we configure @domain.pt to be an alias of the first one, we can only login with:

username: user@domain.com
passwd: *******

To allow the login to be made with user@domain.pt, we have to change the query made by dovecot. Just replace the user_query and password_query in dovecot-sql.conf:

user_query = SELECT email as user, maildir as home, CONCAT('maildir:', maildir, '/Maildir') as mail, uid, gid, CONCAT('*:storage=', quota, 'B') AS quota_rule, CONCAT(maildir, '/.sieve') as sieve FROM mail_user WHERE disable%Ls = 'n' AND (email = '%u' OR email = CONCAT ( SUBSTRING_INDEX('%u', '@', 1), (select mail_forwarding.destination FROM mail_forwarding where source = CONCAT ('@', SUBSTRING_INDEX('%u', '@', -1)))))

password_query = SELECT password FROM mail_user WHERE disable%Ls = 'n' AND ( email = '%u' OR email = CONCAT ( SUBSTRING_INDEX('%u', '@', 1),(select mail_forwarding.destination FROM mail_forwarding where source = CONCAT ('@', SUBSTRING_INDEX('%u','@', -1)))))


Sem comentários:

Enviar um comentário