[Dovecot] Tricky Master User Query - need MySQL help
Marc Perkel
marc at perkel.com
Tue Aug 17 21:50:07 EEST 2010
OK - I want to do something very tricky with master users and if I get
it to work I'm adding it to the wiki for everyone to use.
So far I have a MySQL database that servers multiple domains. I can set
a flag making someone a domain owner that allows that person to become
master of that domain. Here's the query for that.
password_query = SELECT user_name, domain_name, password FROM users
WHERE user_name = '%n' AND domain_name = '%d' AND owns_domain='1' AND
'%d'='%{login_domain}'
So - here's where we get tricky.
I have another table called "ownership" where I have 2 fields which is a
pairing of email addresses (login_id) and domains owned (owned_object).
Data might look like this:
joe at blow.com domain1.com
joe at blow.com domain2.com
Since joe at blow.com owns both domain1.com and domain2.com I want him to
be able to log in as anyone in those 2 domains as a master user.
Examples:
tom at domain1.com*joe at blow.com
harry at domain2.com*joe at blow.com
So the idea is to create a MySQL query so that if the master user
matches the domain part of the login user then it returns true and
allows the login.
What MySQL query will do that?
More information about the dovecot
mailing list