Remove IMAP domain from username


#1

I have IMAP auth enabled. My users can login with "username" or with "username@domain" which creates 2 different OC accounts

There's any way to remove the domain?


#2

Are you using an LDAP server?

You could setup an authentication via LDAP, that way you can add an email adress to the username, so you have only 1 account for 1 user.

If you use IMAP, you would have to only allow users to login via email address to avoid 2 user accounts for 1 user.


#3

SOLVED

https://doc.owncloud.org/server/10.0/admin_manual/configuration/user/user_auth_ftp_smb_imap.html is outdated

There's a "$domain" parameter to the imap config documented in the module (committed on Jul 30, 2015)
https://github.com/owncloud/apps/tree/master/user_external

Add the following to your config.php:

'user_backends' => array(
    array(
        'class' => 'OC_User_IMAP',
        'arguments' => array(
            '{127.0.0.1:143/imap/readonly}', 'example.com'
        ),
    ),
),

This connects to the IMAP server on IP 127.0.0.1, in readonly mode. If a domain name (e.g. example.com) is specified, then this makes sure that only users from this domain will be allowed to login. After successfull login the domain part will be striped and the rest used as username in ownCloud. e.g. 'username@example.com' will be 'username' in ownCloud.

This will parameter will also reject logins with other domains, which is not a problem in my case.


#4

Thank you for figuring that out, the documentation needs to be updated