Author Topic: Multiple Domains Login  (Read 107683 times)

Offline jingo

  • Jr. Member
  • **
  • Posts: 15
Re: Multiple Domains Login
« Reply #30 on: May 17, 2007, 05:26:28 AM »
In my setup I have multiple domains

mail.domain1.com
mail.domain2.com
mail.domain3.com

which are all redirected through apache mod_rewrite to

"https://ssl.mysslenableddomain.com/mail.domain1.com/roundcube/" etc.

Added these lines to main.inc.php:
Code: [Select]
$tempDomain = explode( "/", $_SERVER['REQUEST_URI'], 3);  # "3" is a limit of the array, never need more.
$tempDomain = array_reverse( explode( ".", $tempDomain[1] ) );
$rcmail_config['username_domain'] = $tempDomain[1].".".$tempDomain[0];

$_SERVER['REQUEST_URI'] returns "/mail.domain1.com/roundcube/"
explode by "/" then returns an array :
[ 0] => ""
[1] => "mail.domain1.com"
[2] => the rest... because of the limit of 3

then explode [1] by "." returns
[ 0] => "mail"
[1] => "domain1"
[2] => "com"

array is reversed to support other configs like "http://www.mail.domain1.com" which is common.

Offline renevdb

  • Newbie
  • *
  • Posts: 8
Re: Multiple Domains Login
« Reply #31 on: June 29, 2007, 09:05:26 PM »
I have a setup with a dropdown for a few domains, now I want to change to the smtp server instead of PHP. If I put in a snmp server it works okay, but as I use multiple domains I created a array. This however does not work.

$rcmail_config['default_host'] = array(
 'mail.domain1.com' => 'domain1.com',
 'mail.domain2.com' => 'domain2.com'
 );

$rcmail_config['username_domain'] = array(
 'mail.domain1.com' => 'domain1.com',
 'mail.domain2.com' => 'domain2.com'
 );

$rcmail_config['mail_domain'] = $rcmail_config['username_domain'];

$rcmail_config['smtp_server'] = 'mail.domain1.com';

==============================================

If I chance this it will not let me sent.

$rcmail_config['smtp_server'] = array(
 'mail.domain1.com' => 'domain1.com',
 'mail.domain2.com' => 'domain2.com'
 );

What do I need to change?
Eddie would go !

Offline bpat1434

  • Administrator
  • Hero Member
  • *****
  • Posts: 673
Re: Multiple Domains Login
« Reply #32 on: July 08, 2007, 05:22:22 PM »
I contributed a patch to the devs for multiple SMTP servers. If you grab the latest trunk (although currently the SVN server is down :() you should be able to do exactly as you have done. But if you downloaded the 0.1-rc1 it is not included.
 
  

Offline TommyER

  • Newbie
  • *
  • Posts: 3
Re: Multiple Domains Login
« Reply #33 on: July 16, 2007, 01:56:26 PM »
I have seen that in the user-entry in the data is a field called "mail_host".

Is it possible to create a login only with username (or alias) and password and the script lookup for the "mail_host" and continue with RC?

So it would be easy to login with multiple mail servers.

Tom

Offline bpat1434

  • Administrator
  • Hero Member
  • *****
  • Posts: 673
Re: Multiple Domains Login
« Reply #34 on: July 16, 2007, 02:35:56 PM »
You mean like a VirtUser file? Roundcube supports those already. I don't know how to use them, but it seems like what you want.
 
  

Offline TommyER

  • Newbie
  • *
  • Posts: 3
Re: Multiple Domains Login
« Reply #35 on: July 16, 2007, 04:36:25 PM »
No. I don' want to use a edited file on the server. I'd like to use the main functions and tables of RC.

Example:

Username: email-adress -> stored in alias in the database, instead of the username (could also the username if someone likes it)
Password: Password
Server: leave blank or hidden field

On the login process the RC-script should lookup in table users for the entry "mail_host" and set the variable to the value of the database entry and connect to the mail-server. So there is no extra file necessary. RC have the information but didn't use it.

Offline bpat1434

  • Administrator
  • Hero Member
  • *****
  • Posts: 673
Re: Multiple Domains Login
« Reply #36 on: July 17, 2007, 09:56:29 AM »
If the server is blank or hidden, then it can only be one server (as per RC main.inc.php file). Otherwise a drop-down is shown for multiple servers, or a blank input box for user-defined servers.

So in that case, you can just have them use their username (without the "@domain.tld" portion) and define the domain to append to the username in the main.inc.php file and they can log in that way.
 
  

Offline TommyER

  • Newbie
  • *
  • Posts: 3
Re: Multiple Domains Login
« Reply #37 on: July 17, 2007, 01:35:42 PM »
Hi Brett,

i know those two options. But I suggest an idea of an third option if you re-read my posting. I can't programming this in cgi, but maybe can someone program it.

Offline Mickey

  • Newbie
  • *
  • Posts: 1
Re: Multiple Domains Login
« Reply #38 on: August 04, 2007, 09:55:37 AM »
I'll just add my 2 cents here. This works fine for us with multiple domains:
we have mail.***.com domains pointing to one rc install. This hack works
like: if the domain has a prefix "mail" then it get's rid of the server part and
@domain part in login. if no "mail" prefix found it displays the standard login
form where you have to type in everything:

in config/main.inc.php add this:
Code: [Select]
function getDomain() {
$host=$_SERVER['HTTP_HOST'];
$prefix='mail';
$arr=explode('.',$host);
if ($arr[0]==$prefix) { unset($arr[0]); $host=implode('.',$arr); }
else { $host=''; }
return $host;
}

and modify the following 2 config lines:
Code: [Select]
$rcmail_config['default_host'] = getDomain();
Code: [Select]
$rcmail_config['username_domain'] = getDomain();
Hope this is helps for someone,
Mickey



Offline bpat1434

  • Administrator
  • Hero Member
  • *****
  • Posts: 673
Re: Multiple Domains Login
« Reply #39 on: August 04, 2007, 03:48:50 PM »
TommyER: You might look at the source-code to Roundcube. A virtual user query is what you need. I'm not 100% sure how to do it, but I know it can be done (as others on here have done before).
 
  

Offline rsw686

  • Newbie
  • *
  • Posts: 5
Re: Multiple Domains Login
« Reply #40 on: October 31, 2007, 02:13:41 PM »
I'm slightly confused on how to configure the options for my setup. I am using postfix with virtual domains and roundcube is on the same server. The server is behind NAT so I currently have the following set

$rcmail_config['default_host'] = 'localhost';

When logging in the user has to type the full email@domain.com. I want a dropdown of domains available, but no matter the domain choice it needs to use localhost for the default_host. Otherwise unless I hard code each domain with the public IP into my hosts file the request will go out to the router through NAT and back, which ties up CPU cycles on the router.

Seems simple but I have a feeling this isn't possible. As the host is used to link the username_domain to default_host to append the correct domain name.

Offline bpat1434

  • Administrator
  • Hero Member
  • *****
  • Posts: 673
Re: Multiple Domains Login
« Reply #41 on: October 31, 2007, 08:28:10 PM »
Not possible right now as each array key for the domains has to be different, and since they'll all be "localhost" you can only have one.

What you could do is manually add in the template a drop-down box and set all the values to localhost.....
 
  

Offline dave1978

  • Newbie
  • *
  • Posts: 9
Re: Multiple Domains Login
« Reply #42 on: January 04, 2008, 04:08:01 PM »
Is it possible to strip the domain from the user and use that as the server to save the user having to enter the domain twice for example:

User info@domain1.com
Server domain1.com (automatically taken from the address that user entered)

User info@domain2.com
Server domain2.com (automatically taken from the address that user entered)

Offline bpat1434

  • Administrator
  • Hero Member
  • *****
  • Posts: 673
Re: Multiple Domains Login
« Reply #43 on: January 04, 2008, 06:04:37 PM »
Yes it's possible, but you'd have to modify the source in the login functions to do so.
 
  

Offline dave1978

  • Newbie
  • *
  • Posts: 9
Re: Multiple Domains Login
« Reply #44 on: January 04, 2008, 08:59:18 PM »
I should have had a better look anyway I've now replaced line 500 of main.inc

Code: [Select]
$host = isset($_POST['_host']) ? get_input_value('_host', RCUBE_INPUT_POST) : $CONFIG['default_host'];

with

Code: [Select]
$usersplit = explode('@', get_input_value('_user', RCUBE_INPUT_POST));
 $host = $usersplit[1];

and it now seems to work a treat does exactly what I needed