Third Party Contributions > Old Style Plug-Ins

Multiple Domains Login

<< < (10/12) > >>

bpat1434:
Fantastic!! Glad to hear you got it working as you wanted ;)

dano:
Hello,

I use part of a hack that was originally posted as a Cpanel password change hack. I will try to post the pertinent information here. I am using this on a Cpanel 11 server with multiple virtual hosts and multiple users per domain.

I have my httpd.conf configure so that Roundcube loads when a user browses to http://www.domain.com/rcmail.

The user MUST put 'www' in the url or else it will not work. An error returns and Roundcube puts the user name in the log in box but you can see that it's incorrect.

In index.php locate the login section (find // try to log in). Replace it with

--- Code: ---// try to log in
if(isset($_POST['_user']) && $_action == 'login' && $_task == 'mail')
 {
 if($_SERVER['SERVER_NAME'] and !preg_match('/(.*)\@(.*)/',$_POST['_user'])){
    $domain = preg_replace('/^(\w*)\./','',$_SERVER['SERVER_NAME']);
    $_POST['_user'] = $_POST['_user'].&quot;@&quot;.$domain;
 }

--- End code ---

In main.inc.php:

Set default_host to localhost

--- Code: ---$rcmail_config['default_host'] = 'localhost';

--- End code ---

Set smtp_server to localhost

--- Code: ---$rcmail_config['smtp_server'] = 'localhost';

--- End code ---

Set smtp_user to %u

--- Code: ---$rcmail_config['smtp_user'] = '%u';

--- End code ---

Set smtp_pass to %p

--- Code: ---$rcmail_config['smtp_pass'] = '%p';

--- End code ---

And I believe that that is everything. Hope that's able to help someone!

yenemy:
Edit: Haha, sorry about the post resurrection; didn't notice this was from way back in January

Hi all, just installed Roundcube a few days ago and I'm liking it quite a lot. I too got tired of typing in my full email address when logging in, so I put the following in main.inc.php:


--- Code: ---// Automatically add this domain to user names for login
// Only for IMAP servers that require full e-mail addresses for login
// Specify an array with 'host' => 'domain' values to support multiple host
$hostStr = $_SERVER['HTTP_HOST'];
$wPos = strPos($hostStr, '.')+1;
$rcmail_config['username_domain'] = substr($hostStr,$wPos);
--- End code ---

Basically just grabs the browser domain and strips the first element. So as long as the user's logging in at the right domain, they should be fine. Works a treat for me, thought I'd share in case anyone else wants it. I saw some stuff with database calls, etc. earlier in this thread, but that's way beyond me at this point... I'm no programmer, and certainly not a PHP one.

cornbread:
Hope you don't mind I added this to the trac as a feature request.

http://trac.roundcube.net/ticket/1484930

yenemy:
cornbread, I don't mind at all!
Although, a more foolproof way would be to grab the last two elements instead of stripping the first one since some subdomains come in differently: e.g., four elements like some subdomains ("http://www.email.domain.com")

---------------------------------

So after my last post, I figured I should just go ahead and do it.

And here it is:


--- Code: ---// Automatically add this domain to user names for login
// Only for IMAP servers that require full e-mail addresses for login
// Specify an array with 'host' => 'domain' values to support multiple host

$hostArr = explode('.',$_SERVER['HTTP_HOST']);
$hostDomain = join('.',array_reverse(array(array_pop($hostArr),array_pop($hostArr))));
$rcmail_config['username_domain'] = $hostDomain;
--- End code ---

--------------

Haha, which looks a lot like a dupe of jingo's.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version