Re: dovecot username with domain

2023-09-23 Thread Tom Hendrikx via dovecot

On 19-09-2023 22:36, Dave McGuire wrote:

On 9/19/23 16:34, Michael Grant wrote:


Thanks, I was hoping for something less complicated.  I found
   auth_username_format %n
which drops the domain if supplied.  Unfortunately my imap username
isn't 'mgrant'.  Probably i could make this work if there was no other
way.  This forces me to have my IMAP password the same as my unix
password.

I probably should move to virtual users for everyone on my box but
that's not so easy.  I was hoping there was some way i could translate
individual users which would make this transition easier.


You could have virtual users with any username (matching the required 
format for 'New Outlook') and password in an SQL passdb + userdb, and a 
second backend for the system users (PAM probably) as a fallback.


The docs describe this precise scenario at: 
https://doc.dovecot.org/configuration_manual/authentication/multiple_authentication_databases/



Regards,
Tom
___
dovecot mailing list -- dovecot@dovecot.org
To unsubscribe send an email to dovecot-le...@dovecot.org


Re: dovecot username with domain

2023-09-21 Thread Oscar del Rio

On 2023-09-19 3:51 p.m., Michael Grant via dovecot wrote:

I've been using dovecot using system usernames (my unix uname as my
IMAP username).  But today I tried New Outlook which requires the imap
username match my email address.


I'm not sure about "New Outlook" but other versions of Outlook (e.g. 
M365) allows setting up different username by using Windows Control 
Panel - Mail... instead of using Outlook's Account Settings.


___
dovecot mailing list -- dovecot@dovecot.org
To unsubscribe send an email to dovecot-le...@dovecot.org


Re: dovecot username with domain

2023-09-19 Thread Tom Hendrikx via dovecot

On 19-09-2023 22:36, Dave McGuire wrote:

On 9/19/23 16:34, Michael Grant wrote:


Thanks, I was hoping for something less complicated.  I found
   auth_username_format %n
which drops the domain if supplied.  Unfortunately my imap username
isn't 'mgrant'.  Probably i could make this work if there was no other
way.  This forces me to have my IMAP password the same as my unix
password.

I probably should move to virtual users for everyone on my box but
that's not so easy.  I was hoping there was some way i could translate
individual users which would make this transition easier.


You could have virtual users with any username (matching the required 
format for 'New Outlook') and password in an SQL passdb + userdb, and a 
second backend for the system users (PAM probably) as a fallback.


The docs describe this precise scenario at: 
https://doc.dovecot.org/configuration_manual/authentication/multiple_authentication_databases/



Regards,
Tom
___
dovecot mailing list -- dovecot@dovecot.org
To unsubscribe send an email to dovecot-le...@dovecot.org


Re: dovecot username with domain

2023-09-19 Thread Dave McGuire

On 9/19/23 16:34, Michael Grant wrote:

   Heya mgrant, been a long time!


Very!  Will hit you off-list.


  :-)


   If you're using a database for authentication, you can do this sort of
translation past using stored functions in MySQL.  Queries look something
like this:

password_query = SELECT userid AS username, domain, password FROM mail_users
WHERE userid = addr_to_uname('%u') AND domain =
addr_to_domain_or_default('%u', 'domain.com')

...

Thanks, I was hoping for something less complicated.  I found
   auth_username_format %n
which drops the domain if supplied.  Unfortunately my imap username
isn't 'mgrant'.  Probably i could make this work if there was no other
way.  This forces me to have my IMAP password the same as my unix
password.

I probably should move to virtual users for everyone on my box but
that's not so easy.  I was hoping there was some way i could translate
individual users which would make this transition easier.


  You can use that technique, though, to implement any sort of 
translation table that you could build into an SQL query.  Just a 
suggestion.


   -Dave

--
Dave McGuire, AK4HZ
New Kensington, PA

___
dovecot mailing list -- dovecot@dovecot.org
To unsubscribe send an email to dovecot-le...@dovecot.org


Re: dovecot username with domain

2023-09-19 Thread Michael Grant via dovecot
>   Heya mgrant, been a long time!

Very!  Will hit you off-list.

>   If you're using a database for authentication, you can do this sort of
> translation past using stored functions in MySQL.  Queries look something
> like this:
> 
> password_query = SELECT userid AS username, domain, password FROM mail_users
> WHERE userid = addr_to_uname('%u') AND domain =
> addr_to_domain_or_default('%u', 'domain.com')
...

Thanks, I was hoping for something less complicated.  I found
  auth_username_format %n
which drops the domain if supplied.  Unfortunately my imap username
isn't 'mgrant'.  Probably i could make this work if there was no other
way.  This forces me to have my IMAP password the same as my unix
password.

I probably should move to virtual users for everyone on my box but
that's not so easy.  I was hoping there was some way i could translate
individual users which would make this transition easier.


signature.asc
Description: PGP signature
___
dovecot mailing list -- dovecot@dovecot.org
To unsubscribe send an email to dovecot-le...@dovecot.org


Re: dovecot username with domain

2023-09-19 Thread Dave McGuire

On 9/19/23 15:51, Michael Grant via dovecot wrote:

I've been using dovecot using system usernames (my unix uname as my
IMAP username).  But today I tried New Outlook which requires the imap
username match my email address.

Is there some way to tell dovecot that username@host is the same as uname?
(where username@host is an email address and uname is a unix login
which might be completely different).


  Heya mgrant, been a long time!

  If you're using a database for authentication, you can do this sort 
of translation past using stored functions in MySQL.  Queries look 
something like this:


password_query = SELECT userid AS username, domain, password FROM 
mail_users WHERE userid = addr_to_uname('%u') AND domain = 
addr_to_domain_or_default('%u', 'domain.com')


  One of the functions is something like this:


DELIMITER ?
CREATE FUNCTION addr_to_domain_or_default (userid VARCHAR(255), 
default_domain VARCHAR(255)) RETURNS VARCHAR(255) DETERMINISTIC

BEGIN
DECLARE at_pos INT;
DECLARE addr_out VARCHAR(255);

SELECT LOCATE('@', userid) INTO at_pos;
IF at_pos = 0 THEN
  CASE userid
WHEN 'user1' THEN SET addr_out = 'domain1.com';
WHEN 'user2' THEN SET addr_out = 'domain2.com';
ELSE SET addr_out = default_domain;
  END CASE;
ELSE
  SELECT SUBSTRING(userid, at_pos + 1) INTO addr_out;
END IF;

RETURN addr_out;

END ?
DELIMITER ;
--

  This isn't exactly the functionality you want, but it illustrates the 
kinds of translations that can easy be done on the database side.  I've 
been using a scheme like this for many years with great results.


-Dave

--
Dave McGuire, AK4HZ
New Kensington, PA

___
dovecot mailing list -- dovecot@dovecot.org
To unsubscribe send an email to dovecot-le...@dovecot.org