Hello,
I am running Dovecot 2.3 with SQL passdb and userdb. At the moment the login name is the same as the email address, and everything else is built on top of that: the mail location, the userdb lookup, LMTP delivery, Sieve, quota and so on all use the full address as the user.
What I would like to do is let users authenticate with a dedicated login name that is different from their email address, while keeping the email address as the canonical user for everything else. In other words, the login name should only be an alias used at authentication time, and once the passdb has accepted it, the session should continue exactly as it does today, with the email address as %u, the same home and mail location, and the same userdb lookup.
My first attempt was to add a separate column holding the login name and change the password_query so that it matches on that column instead of the address, while still returning the email address in the user field, for example selecting the address as user and filtering with the login name in the where clause. On a single server this seems (i'm not 100% sure) to behave as intended. The difficulty appears in my real setup, where the mailbox sits behind a Dovecot proxy. The proxy passdb returns proxy_maybe and host, and I also had to return destuser so that the backend receives the new login name, since the backend now looks the account up by that name. Authentication then works end to end, but sessions start using the login name as the actual user: new empty mail directories named after the login name get created on every access, and the mailbox appears empty from both IMAP clients and webmail, while the real mail is still under the old address-based location.
I am not sure which component is responsible. One possibility is that with proxy_maybe, when the destination is the local server, Dovecot skips the proxy but still applies destuser as the new username. Another is that the userdb used in the real login path does not see the user field that the passdb rewrites, even though doveadm auth lookup reports the email address as the user. I also wonder whether I should set home or mail explicitly from the database so that the storage location can never depend on the name used at login.
Could someone tell me whether this kind of setup is supported, what the recommended way is to keep the email address as the canonical user when the login name differs, and how the user field, destuser and proxy_maybe are supposed to interact in this case? I can provide doveconf -n output and the relevant queries from both the proxy and the backend if that would help.
Thank you very much for your time.
Best regards