Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Tips/Tricks/Mods

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #11  
Old 20th May 2010, 12:37
nachbar nachbar is offline
Junior Member
 
Join Date: May 2010
Posts: 7
Thanks: 1
Thanked 1 Time in 1 Post
Unhappy

Quote:
Originally Posted by Grey View Post
So as I see things, it would be necessary for Roundcube to be able to select the server according to the username given automagically. I don't have a DB dump of a v3 database at hand, but I think there has to be a connection between the mail user account and it's corresponding mailserver somewhere (has to, as ISPConfig has to know which server to make changes to mailpasswords or sth).
Perhaps no databse connection is necessary. What is if roundcube is doing a dig ns-request to locate the server and so take the correct server? This is just an idea.

If you think the database is the better solution just do it. Sorry about but i can't help a lot because iam not a programmer.
Reply With Quote
The Following User Says Thank You to nachbar For This Useful Post:
Hans (20th May 2010)
Sponsored Links
  #12  
Old 20th May 2010, 12:41
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 36,411
Thanks: 834
Thanked 5,496 Times in 4,326 Posts
Default

One possible problem that I see with using a dns query is that someone else might be able to use the webmail for emails that are not hosted on servers of your company. You might prevent that by e.g. providing a list of allowed mailserver IP's or mailserver hostnames, but then the complexity gets to to a similar level then doing a sql query.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
The Following User Says Thank You to till For This Useful Post:
Hans (20th May 2010)
  #13  
Old 20th May 2010, 13:33
Hans Hans is offline
Moderator
 
Join Date: Dec 2005
Location: Montfoort, The Netherlands
Posts: 2,259
Thanks: 215
Thanked 648 Times in 294 Posts
Default

Thanks to you all,
If Grey will succeed it will be wonderful !!

@Grey:
Quote:
As we are in progress of evaluating to switch from ISPConfig 2 to V3 it sure will be a thing I will look into, as we are happy users of your last RoundCube Package for v2 for a long time, Hans. Thanks for that again. So if I can help you this time, it would be a great "payback"
Thanks for your words and You'll have no regret when you're migrated to ISPConfig3!

@Till:
Quote:
The ispconfig mail_user table has a field server_id which holds the ID of the server this address belongs to. Yoou can lookup the server hostname then with tis ID in the server table.
I think that information is very useful indeed.
__________________
Hans

MrHostman | Master in managed hosting
Reply With Quote
  #14  
Old 20th May 2010, 18:19
Grey Grey is offline
Member
 
Join Date: May 2008
Location: Germany
Posts: 70
Thanks: 9
Thanked 18 Times in 15 Posts
Default

Quote:
Originally Posted by till View Post
The ispconfig mail_user table has a field server_id which holds the ID of the server this address belongs to. Yoou can lookup the server hostname then with tis ID in the server table.
That's exactly what I was thinking when I wrote my answer. I wouldn't like to do a dig or NS-lookup via PHP, as that's something that can be abused "relative easily". Also a simple (even a nested) query should not decrease performance of the login that much, so I would rather rely on the ISPConfig DB than other data

I'm currently looking into setting up a VM for testing a few ideas.
Reply With Quote
The Following User Says Thank You to Grey For This Useful Post:
Hans (20th May 2010)
  #15  
Old 20th May 2010, 22:04
austingecko austingecko is offline
Junior Member
 
Join Date: May 2010
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This thread caught my attention...while I don't yet run in a multiserver environment I liked the idea and concept to do so with a centralized Roundcube install location. A query based approach would seem doable as Hans indicated the server_id is in the "mail_user" table which could be queried with a join to the "server" table in the "dbispconfig" database to retrieve the "server_name" value.

I poked around and found in the Roundcube directory:

index.php

Code:
 $auth = $RCMAIL->plugins->exec_hook('authenticate', array(
    'host' => $RCMAIL->autoselect_host(),
    'user' => trim(get_input_value('_user', RCUBE_INPUT_POST)),
    'cookiecheck' => true,
  )) + array('pass' => get_input_value('_pass', RCUBE_INPUT_POST, true, 'ISO-88$
program/include/rcmail.php


Code:
  public function autoselect_host()
  {
    $default_host = $this->config->get('default_host');
    $host = null;

    if (is_array($default_host)) {
      $post_host = get_input_value('_host', RCUBE_INPUT_POST);

      // direct match in default_host array
      if ($default_host[$post_host] || in_array($post_host, array_values($defau$
        $host = $post_host;
      }

      // try to select host by mail domain
      list($user, $domain) = explode('@', get_input_value('_user', RCUBE_INPUT_$
      if (!empty($domain)) {
        foreach ($default_host as $imap_host => $mail_domains) {
          if (is_array($mail_domains) && in_array($domain, $mail_domains)) {
            $host = $imap_host;
            break;
          }
        }
      }

      // take the first entry if $host is still an array
      if (empty($host)) {
        $host = array_shift($default_host);
      }
    }
    else if (empty($default_host)) {
      $host = get_input_value('_host', RCUBE_INPUT_POST);
    }
    else
      $host = $default_host;

    return $host;
  }
Seems like one should be able to modify the autoselect_host function to include a SQL query and return the right host/server needed.

Hopefully someone with PHP/MySQL programming experience will come along and contribute and knock this out for you.
Reply With Quote
  #16  
Old 20th May 2010, 23:19
Grey Grey is offline
Member
 
Join Date: May 2008
Location: Germany
Posts: 70
Thanks: 9
Thanked 18 Times in 15 Posts
Default

Thank you for looking into. If the plugin approach fails this is surely a good starting point to look into. But I'll try to hook into the login first.
Reply With Quote
  #17  
Old 21st May 2010, 17:32
Grey Grey is offline
Member
 
Join Date: May 2008
Location: Germany
Posts: 70
Thanks: 9
Thanked 18 Times in 15 Posts
Default

After quite a good time messing around with RC code, I found a solution. One problem remains, though, that is a bit unpleasant:

I got it working to "auto-select" the mailhost according to the username given (aka email-adress). That was possible doing with a simple plugin and api hooks. Nice. BUT:

It seems RC gets a bit angry if you write "anything" into it's "default_host" configuration field. I tried setting it to 'none' or 'ispc-controlled' to symbolize, that no hostname will be given but instead the plugin will do the work. Problem is, that RC takes this value above all others (as it seems) and even ignores the values my plugin was setting while logging in. If you change it to '' (empty string) it works! But instead now it shows the server-input field, that I tried to avoid.

So my solution isn't that shiny as I thought it would be. It merely consists of two parts:

1) Small & simple plugin that does the dirty-work in background, selecting the server with a double SELECT sql statement like Till suggested.

2) I simply hacked around in RCs intestines By modifying "./program/include/rcube_template.php" at about line 1046-1048, I set the server fields to hidden so they won't show up in the login screen.

1) is - I think - upgradeable without big problems to new RC versions.
2) has to be done again if you install a new version of RC.


If that is acceptable, would someone (probably Hans as it was his request originally and he has the required setup) be able to test that thing with me? I don't have a real multi-server-environment, so I have to guess it works as I'm now able to login without a server set anywhere (so it must be read out of the database).

Greets
Jens
Reply With Quote
  #18  
Old 21st May 2010, 20:20
Hans Hans is offline
Moderator
 
Join Date: Dec 2005
Location: Montfoort, The Netherlands
Posts: 2,259
Thanks: 215
Thanked 648 Times in 294 Posts
Default

Thanks Grey,
I think option 1 is probably the best as we need to avoid problems with new releases of RoundCube.

I will test your files and let you know how i'm doing.
Thanks for your work so far!
__________________
Hans

MrHostman | Master in managed hosting
Reply With Quote
  #19  
Old 21st May 2010, 20:45
Grey Grey is offline
Member
 
Join Date: May 2008
Location: Germany
Posts: 70
Thanks: 9
Thanked 18 Times in 15 Posts
Default

Quote:
Originally Posted by Hans View Post
Thanks Grey,
I think option 1 is probably the best as we need to avoid problems with new releases of RoundCube.

I will test your files and let you know how i'm doing.
Thanks for your work so far!
Those were no options but parts of the same solution. The server field can not be stripped out without modifications on the source, I suppose. But I hope that will change.
Reply With Quote
  #20  
Old 21st May 2010, 21:01
Hans Hans is offline
Moderator
 
Join Date: Dec 2005
Location: Montfoort, The Netherlands
Posts: 2,259
Thanks: 215
Thanked 648 Times in 294 Posts
 
Default Simple solution

I think i found a possible but simple solution.

If you replace the line
Code:
$rcmail_config['default_host'] = 'ssl://localhost';
in the RoundCube configuration file with:
Code:
$rcmail_config['default_host'] = str_replace("www.","",$_SERVER['SERVER_NAME']);
Then in your browser, go to http://www.yourdomain.tld/webmail.
As you can see the server field at the RoundCube login screen is hidden and yourdomain.tld will be used as the server name. The result is a succesful login from every ISPConfig server in my network.

The problem is that it only works when you type http://www.yourdomain.tld/webmail in your browser. It does not work with names other the "www". Maybe i'm on the right track and someone can make it better then this.
__________________
Hans

MrHostman | Master in managed hosting

Last edited by Hans; 21st May 2010 at 22:53.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable send receive emails vassilis3 Installation/Configuration 15 19th May 2007 14:34
No SPF record. beryl Installation/Configuration 6 17th May 2007 19:52
How to setup external mail servers? mxc Installation/Configuration 1 16th July 2006 12:39
godaddy and centos 4.3 setup with single ip on dsl using ispconfig sethtat HOWTO-Related Questions 3 21st June 2006 01:34
Single Server Setup mfiendd HOWTO-Related Questions 7 31st May 2006 21:32


All times are GMT +2. The time now is 19:18.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.