This documentation is for Dovecot v1.x, see wiki2 for v2.x documentation.

User database extra fields

A user database lookup typically returns uid, gid, home and mail fields. Other possibilities are:

These fields can be returned the exact same way as uid, gid, home and mail fields. Below are examples for some user databases.

Overriding settings

Most commonly settings are overridden from plugin section. For example if your plugin section has quota=maildir:storage=1024 value and the userdb lookup returns quota=maildir:storage=2048, the original quota setting gets overridden. In fact if the lookup always returns a quota field, there's no point in having the quota setting in plugin section at all, because it always gets overridden anyway.

To understand how imap and pop3 processes see their settings, it may be helpful to know how Dovecot internally passes them:

  1. All actual settings are first placed into environment variables. The environment name may be different than the setting name.
  2. Everything inside plugin section is placed into environment variables. %variables in values are expanded first.

  3. Everything from userdb lookup is placed into environment variables.
  4. At this point if post-login scripting is used, it may modify the environment if wanted.

  5. imap/pop3 reads the settings from environment variables. It doesn't matter how they got there, they're read the exact same way.

At each step if the environment variable already exists, it's replaced with the new value (ie. the setting is overridden).

Note that




# NOTE: \ line splitting works only with v1.1+. The quota_rule is also for v1.1+.
user_query = SELECT home, uid, gid, \
  '*:storage=100M' as quota_rule, mail_plugins \
  FROM users WHERE userid = '%u'



user_attrs = homeDirectory=home,uidNumber=uid,gidNumber=gid,quotaDovecot=quota,mail_plugins


Below are examples that show how to give two userdb extra fields ("mail" and "quota"). Note that all userdb extra fields must be prefixed with "userdb_", otherwise they're treated as passdb extra fields.

# v1.0 quota format:
user:{plain}pass:1000:1000::/home/user::userdb_mail=mbox:~/mail userdb_quota=maildir:storage=102400
# v1.1 quota format:
user:{plain}pass:1000:1000::/home/user::userdb_mail=mbox:~/mail userdb_quota_rule=*:storage=100M
user2:{plain}pass2:1001:1001::/home/user2::userdb_mail=maildir:~/Maildir userdb_quota_rule=*:storage=200M

None: UserDatabase/ExtraFields (last edited 2010-03-27 05:46:02 by TimoSirainen)