[Dovecot] Per-user IMAP enable - is it possible?

Gedalya gedalya at gedalya.net
Tue Mar 20 08:18:12 EET 2012


On 3/20/2012 1:43 AM, Gedalya wrote:
> On 3/20/2012 1:28 AM, Alexander Chekalin wrote:
>> Just wonder if it is possible to enable/disable IMAP4 on Dovecot 
>> (2.0.x as far) on per-user basis?
>>
>> The deal is simple: our policy is not to store a lot of mailing on 
>> mailserver (the user should store it locally), thus the 'use POP3' 
>> approach, but for a vary few users it is permitted to use IMAP4. But 
>> users sometimes simple miss the point that some mail clients (e.g. 
>> TB) 'prefer' to use IMAP4 first, and afterward I see mailbox full of 
>> mailings and no local store of it on user's workstation.
>>
>> Sound too complicated, but setting up two Dovecots is not something 
>> I'd love to do as well.
>>
>> Thank you for any ideas,
>>   Alexander
> There would be various ways to do this, the specifics would depend on 
> what kind of passdb you use.
>
> If you happen to be using a SQL database, you could do something like 
> this: Add an allow_imap column, and change the password_query in 
> dovecot-sql.conf.ext to something like this:
>
> password_query = SELECT password FROM user WHERE username = '%n' AND 
> domain = '%d' \
>   AND ('%s' != 'imap' or allow_imap=1)
>
> This would make the user appear to not exist when trying to log in via 
> IMAP.
>
> http://wiki2.dovecot.org/Variables
>
Or like this, might be more appropriate.

password_query = SELECT password, if('%s' != 'imap' or allow_imap=1, 
NULL, 'y') as nologin \
   FROM user WHERE username = '%n' AND domain = '%d'

http://wiki2.dovecot.org/PasswordDatabase/ExtraFields/NoLogin




More information about the dovecot mailing list