I have a Postfix + Dovecot daemon combo setup on a mail server (let's call it server M), that supports virtual domains and user look-ups to a LDAP server (let's call it server D). Right now, I've set-up Postfix to deliver mail to a specially created local user on server M to hold mail for all the virtual users, hence the mail directory for a user is in the format of /home/vmail/<domain>/<user id>.

In that case, I've also set-up Dovecot to fetch the mail from the user's directory:

userdb static {
    args = uid=501 gid=501 home=/home/vmail/%d/%n

The password lookup is:

passdb ldap {
    args = /etc/dovecot-ldap.conf

whereby the config file referred to contains the following:

hosts = server M
base = dc=www,dc=example,dc=com
ldap_version = 3
auth_bind = yes
pass_filter = (mail=%u)

Now, this configuration works (the LDAP object class implemented inetOrgPerson), but when I added posixAccount object class to a user record in server M, Dovecot stopped recognising the user in the format user@domain.

Checking the mail logs show that Dovecot somehow recognises the user as "user" instead of "user@domain", and thus caused my userdb directive to return /home/vmail//user instead of /home/vmail/domain/user

How should I change my configuration to get Dovecot to recognise the user as "user@domain" again?


It seems to me lie the passdb passwd-file { ... } block or maybe a similar userdb block is having precedence over the passdb ldap block


Found the answer!

Basically, to get Dovecot to recognise the user as "user@domain" after the authentication done by adding:

pass_attrs = mail=user

This causes Dovecot to recognise the user from the mail attribute in LDAP. Since the format of the field is "user@domain", it causes Dovecot to accept the user as "user@domain"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy