dovecot-pgsql.conf revision 061da1b9d309301a7e3f5e0f240d7a7e99652d63
94ba4820927b906b333e39445c1508a29387c3aaTimo Sirainen# For the pgsql passdb module, you'll need a database with a table that
94ba4820927b906b333e39445c1508a29387c3aaTimo Sirainen# contains fields for at least the userid and password. If you want to
94ba4820927b906b333e39445c1508a29387c3aaTimo Sirainen# use the user@domain syntax, you might want to have a separate domain
cdf294e5cceee81d58c8477c7c28d9ad6b55c36aTimo Sirainen# field as well.
94ba4820927b906b333e39445c1508a29387c3aaTimo Sirainen# If your users all have the same uig/gid, and have predictable home
94ba4820927b906b333e39445c1508a29387c3aaTimo Sirainen# directories, you can use the static userdb module to generate the home
cdf294e5cceee81d58c8477c7c28d9ad6b55c36aTimo Sirainen# dir based on the userid and domain. In this case, you won't need fields
ea1ae54fcfbd8e911978c149f9e7265a45b6380aTimo Sirainen# for home, uid, or gid in the database.
1631885636d15abaf0375304a17928c8c23782cdTimo Sirainen# If you prefer to use the pgsql userdb module, you'll want to add fields
94ba4820927b906b333e39445c1508a29387c3aaTimo Sirainen# for home, uid, and gid. Here is an example table:
d389c93ada174a8fc6edf995b4f829d38e8fe567Timo Sirainen# CREATE TABLE users (
c154a05c76d4d83de1cdf9746ce4e2da0869705dTimo Sirainen# userid VARCHAR(128) NOT NULL,
94ba4820927b906b333e39445c1508a29387c3aaTimo Sirainen# password VARCHAR(64) NOT NULL,
8732bdd21579472feb40da8ffc99b8fd3b341417Timo Sirainen# home VARCHAR(256) NOT NULL,
f23baa3b53b1dd4eb19729e99a43937fa3c7f309Timo Sirainen# uid INTEGER NOT NULL,
8732bdd21579472feb40da8ffc99b8fd3b341417Timo Sirainen# gid INTEGER NOT NULL,
7f098e28ddad259d9fbe76e18347c722bb005189Timo Sirainen# active CHAR(1) DEFAULT 'Y' NOT NULL
cf63dc8723b971cc80638fccbf494d961cbafc7fTimo Sirainen# Database connection string.
8732bdd21579472feb40da8ffc99b8fd3b341417Timo Sirainen# For available options, see the PostgreSQL documention for the PQconnectdb
cdf294e5cceee81d58c8477c7c28d9ad6b55c36aTimo Sirainen# function of libpq.
d38ca817bdcec666a3b91efb917064ab844c36a2Timo Sirainen# connect = host=192.168.1.1 dbname=users
cdf294e5cceee81d58c8477c7c28d9ad6b55c36aTimo Sirainen# connect = host=sql.example.com dbname=virtual user=virtual password=blarg
d38ca817bdcec666a3b91efb917064ab844c36a2Timo Sirainen#connect = dbname=virtual user=virtual
e4ac89c5e7bb96598a47011993718f0e654912b4Timo Sirainen# Default password scheme.
cdf294e5cceee81d58c8477c7c28d9ad6b55c36aTimo Sirainen# Currently supported schemes include PLAIN, PLAIN-MD5, DIGEST-MD5, and CRYPT.
d38ca817bdcec666a3b91efb917064ab844c36a2Timo Sirainen#default_pass_scheme = PLAIN-MD5
d38ca817bdcec666a3b91efb917064ab844c36a2Timo Sirainen# Query to retrieve the password.
d38ca817bdcec666a3b91efb917064ab844c36a2Timo Sirainen# The query should return one row, one column. If more than one row or column
1631885636d15abaf0375304a17928c8c23782cdTimo Sirainen# is returned, authentication will automatically fail.
c154a05c76d4d83de1cdf9746ce4e2da0869705dTimo Sirainen# Available substitutions:
1631885636d15abaf0375304a17928c8c23782cdTimo Sirainen# %u = entire userid
1631885636d15abaf0375304a17928c8c23782cdTimo Sirainen# %n = user part of user@domain
1631885636d15abaf0375304a17928c8c23782cdTimo Sirainen# %d = domain part of user@domain
cdf294e5cceee81d58c8477c7c28d9ad6b55c36aTimo Sirainen# password_query = SELECT password FROM users WHERE userid = '%n' AND domain = '%d'
c154a05c76d4d83de1cdf9746ce4e2da0869705dTimo Sirainen# password_query = SELECT password FROM users WHERE userid = '%u' AND active = 'Y'
cdf294e5cceee81d58c8477c7c28d9ad6b55c36aTimo Sirainen#password_query = SELECT password FROM users WHERE userid = '%u'
ea1ae54fcfbd8e911978c149f9e7265a45b6380aTimo Sirainen# Query to retrieve the user information.
c154a05c76d4d83de1cdf9746ce4e2da0869705dTimo Sirainen# The query must return only one row. The columns to return are:
c154a05c76d4d83de1cdf9746ce4e2da0869705dTimo Sirainen# home - Home directory
ea1ae54fcfbd8e911978c149f9e7265a45b6380aTimo Sirainen# mail - MAIL environment
c154a05c76d4d83de1cdf9746ce4e2da0869705dTimo Sirainen# system_user - System user name (for initgroups())
ea1ae54fcfbd8e911978c149f9e7265a45b6380aTimo Sirainen# uid - System UID
cdf294e5cceee81d58c8477c7c28d9ad6b55c36aTimo Sirainen# gid - System GID
cdf294e5cceee81d58c8477c7c28d9ad6b55c36aTimo Sirainen# Either home or mail is required. uid and gid are required. If more than one
cf63dc8723b971cc80638fccbf494d961cbafc7fTimo Sirainen# row is returned or there's missing fields, login will automatically fail.
f77da594de6318312a7f31589c9e4c38e2b74c73Timo Sirainen# user_query = SELECT home, uid, gid FROM users WHERE userid = '%n' AND domain = '%d'
f77da594de6318312a7f31589c9e4c38e2b74c73Timo Sirainen# user_query = SELECT dir AS home, user AS uid, group AS gid FROM users where userid = '%u'
f77da594de6318312a7f31589c9e4c38e2b74c73Timo Sirainen# user_query = SELECT home, 501 AS uid, 501 AS gid FROM users WHERE userid = '%u'
f77da594de6318312a7f31589c9e4c38e2b74c73Timo Sirainen#user_query = SELECT home, uid, gid FROM users WHERE userid = '%u'