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

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 24th October 2010, 11:09
necromncr necromncr is offline
Junior Member
 
Join Date: Jul 2008
Posts: 9
Thanks: 1
Thanked 6 Times in 3 Posts
Default Roundcubemail 0.4.3 HOWTO for ISP 2.x

*EDIT* what an embarasment - there is no Roundcube 0.4.3, just 0.4.2.

Hi,

Being stuck on 2.x myself and noticing Roundcube got really good lately I decided to upgrade / switch my webmail solution. While there I didn't find any good solutions for authentication with ISPConfig except for virtuser_file plugin so I decided to do some work to make a plugin for setting real user's name and email into Roundcube settings.

Result is very user-friendly experience as there is no "new user identity" settings to be done.

Being in serious lack of time here I ask of you, does any of you need a howto / this plugin to be installed so I know to take the time and share it with you?

Let me know :-)
Reply With Quote
Sponsored Links
  #2  
Old 25th October 2010, 13:23
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,739 Times in 2,574 Posts
Default

Quote:
Originally Posted by necromncr View Post
Being in serious lack of time here I ask of you, does any of you need a howto / this plugin to be installed so I know to take the time and share it with you?

Let me know :-)
That would be great!

BTW, do you have a download link?
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 26th October 2010, 11:21
walkero walkero is offline
Junior Member
 
Join Date: Sep 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That would be great
Reply With Quote
  #4  
Old 26th October 2010, 16:00
ressel ressel is offline
Senior Member
 
Join Date: Apr 2007
Location: Denmark
Posts: 128
Thanks: 18
Thanked 5 Times in 5 Posts
Default

Sounds nice, looking forward to it already.


Quote:
Originally Posted by necromncr View Post
*EDIT* what an embarasment - there is no Roundcube 0.4.3, just 0.4.2.

Hi,

Being stuck on 2.x myself and noticing Roundcube got really good lately I decided to upgrade / switch my webmail solution. While there I didn't find any good solutions for authentication with ISPConfig except for virtuser_file plugin so I decided to do some work to make a plugin for setting real user's name and email into Roundcube settings.

Result is very user-friendly experience as there is no "new user identity" settings to be done.

Being in serious lack of time here I ask of you, does any of you need a howto / this plugin to be installed so I know to take the time and share it with you?

Let me know :-)
Reply With Quote
  #5  
Old 29th October 2010, 19:11
necromncr necromncr is offline
Junior Member
 
Join Date: Jul 2008
Posts: 9
Thanks: 1
Thanked 6 Times in 3 Posts
Default

Due to extreme interest (3 people ;-) awesome!) here is my ISPConfig 2.x for Roundcube 0.4.2 integration plugin.

1.) Make a MySQL user to access ISPConfig database. I myself prefer to give just the right amount of privileges - in my case I used username "roundcube":
Code:
GRANT SELECT (web_domain, doc_id, doctype_id) ON `db_ispconfig`.`isp_isp_web` TO 'roundcube'@'localhost'
GRANT SELECT (user_username, doc_id, user_emailalias, user_name) ON `db_ispconfig`.`isp_isp_user` TO 'roundcube'@'localhost'
GRANT SELECT (child_doctype_id, child_doc_id, parent_doctype_id, parent_doc_id) ON `db_ispconfig`.`isp_dep` TO 'roundcube'@'localhost'
Don't forget to set a password!

2.) First make a folder in your Roundcube installation called "ispconfig_addons".

3.) Make two files, "config.inc.php" and "ispconfig_addons.php".

4.) Fill config.inc.php with this code:
Code:
<?php                                                                                                                                                                                                          
$rcmail_config['isp_db_name'] = 'db_ispconfig'; // your ISPConfig database
$rcmail_config['isp_db_user'] = 'roundcube'; // username for ISPConfig database from step #1
$rcmail_config['isp_db_pass'] = '<password>'; // extremly long, complicated and just impossible to guess password from step #1
?>
5.) Fill ispconfig_addons.php with this code:
Code:
<?php

/**                                                                                                                                                                                                            
 * ISPConfig v2.x integration for Roundcube 0.4.2 plugin                                                                                                                                                       
 *                                                                                                                                                                                                             
 * Adds ability to authenticate against ISPConfig 2.x user database.                                                                                                                                           
 *                                                                                                                                                                                                             
 * To use you must have config.inc.php file following settings:                                                                                                                                                
 * isp_db_name - ISPConfig database name                                                                                                                                                                       
 * isp_db_user - user with access to only selected fields in selected tables                                                                                                                                   
 * isp_db_pass - password for that user                                                                                                                                                                        
 *                                                                                                                                                                                                             
 * Code is tested however there is no waranty for it. Use at your own risk. Feedback is welcome!                                                                                                               
 *                                                                                                                                                                                                             
 * @version 0.1                                                                                                                                                                                                
 * @author Janez Dolinar s.p., <info@tuksi.net>                                                                                                                                                                
 */   
class ispconfig_addons extends rcube_plugin
{  
  function init()
  {
    $this->add_hook('user_create', array($this, 'usercreate'));
    $this->add_hook('login_after', array($this, 'loginafter'));

    $this->load_config();
  }
                                                                                                                                                                                                               
  function loginafter($query) {                                                                                                                                                                                
    $rcmail = rcmail::get_instance();                                                                                                                                                                          
                                                                                                                                                                                                               
    if (isset($_SESSION['userFullName'])) {                                                                                                                                                                    
      $sql = 'UPDATE identities SET name=?, email=? WHERE identity_id = ?';                                                                                                                                    
                                                                                                                                                                                                               
      $rcmail->db->query($sql,$_SESSION['userFullName'], $_SESSION['userEmail'], $rcmail->user->data['user_id']);                                                                                              
                                                                                                                                                                                                               
      unset($_SESSION['userFullName']);                                                                                                                                                                        
      unset($_SESSION['userEmail']);                                                                                                                                                                           
    }                                                                                                                                                                                                          
    return $query;
  }
  
  
  function usercreate($args)
  {
    $rcmail = rcmail::get_instance();
    if (($rcmail->config->get('isp_db_name')=='') || ($rcmail->config->get('isp_db_user')=='') || ($rcmail->config->get('isp_db_pass')=='')) {
      return $args;
    } else {
      $sql = "SELECT iiu.user_username, iiu.user_emailalias, iiu.user_name, iid.web_domain FROM isp_isp_user iiu, isp_dep id, isp_isp_web iid "
            ."WHERE iiu.user_username = '%s'  AND iiu.doc_id = id.child_doc_id  AND id.child_doctype_id = 1014  AND iid.doc_id = id.parent_doc_id";
            
      $mysql = new MySQLi('localhost', $rcmail->config->get('isp_db_user'), $rcmail->config->get('isp_db_pass'), $rcmail->config->get('isp_db_name'));
      
      if ($mysql->connect_error) return false;
      $result = $mysql->query(sprintf($sql,addslashes($args['user'])));

      if ($result) {
        $row = $result->fetch_object();
        $userEmail = explode("\n",str_replace("\r","",$row->user_emailalias));
        $args['alias'] = $userEmail[0].'@'.$row->web_domain;
        $_SESSION['userFullName'] = $row->user_name;
        $_SESSION['userEmail'] = $userEmail[0].'@'.$row->web_domain;
        $result->close();
      }
      
      $mysql->close();
    }
  
    return $args;
  }

}
?>
6.a) make sure it's web-server readable!

7.) Add the plugin to your Roundcube config file /config/main.inc.php :
Code:
// ----------------------------------                                                                                                                                                                          
// PLUGINS                                                                                                                                                                                                     
// ----------------------------------                                                                                                                                                                          
                                                                                                                                                                                                               
// List of active plugins (in plugins/ directory)                                                                                                                                                              
$rcmail_config['plugins'] = array('virtuser_file','ispconfig_addons');
Also don't forget to configure virtuser_file plugin. Add this to the end of config/main.inc.php file:

Code:
                                                                                                                                                                                                               
$rcmail_config['virtuser_file'] = '/etc/postfix/virtusertable';
This is valid for Ubuntu / Debian users. This is just a guess, find your location and modify this line accordingly.

Code uses MySQLi extension so you'll need that as well however I think it should be no problem changing it to MySQL extension.

That should be it! You / your clients can now login with any email set for their account and their password! Their names should already be set to ther ISPConfig full names and default email address.

Please note I made this after a long hard working day and was tired. There could be some room for improvement or even some flaws. I ask for your feedback, I'll be glad to fix the code. Oh, and no waranty

Enjoy!

Last edited by necromncr; 31st October 2010 at 11:52. Reason: Oh, could they just release v0.4.3? Made the same typo AGAIN!
Reply With Quote
The Following User Says Thank You to necromncr For This Useful Post:
kextra1 (24th June 2011)
  #6  
Old 29th October 2010, 19:29
necromncr necromncr is offline
Junior Member
 
Join Date: Jul 2008
Posts: 9
Thanks: 1
Thanked 6 Times in 3 Posts
Default

Quote:
Originally Posted by falko View Post
That would be great!

BTW, do you have a download link?
Here you go: http://www.tuksi.net/datoteke/ispcon...n_v0.1.tar.bz2
Reply With Quote
  #7  
Old 3rd November 2010, 15:15
necromncr necromncr is offline
Junior Member
 
Join Date: Jul 2008
Posts: 9
Thanks: 1
Thanked 6 Times in 3 Posts
Default

Now I'm worried - no replies!

Anyone else tried this? Did it work? Was it worth installing?

I need feedback people!

Re!
Reply With Quote
  #8  
Old 4th November 2010, 18:04
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,739 Times in 2,574 Posts
Default

I'll test it soon and let you know.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #9  
Old 29th November 2010, 12:22
madmucho madmucho is offline
Senior Member
 
Join Date: Oct 2006
Location: Czech republic, Karlovy Vary
Posts: 158
Thanks: 79
Thanked 11 Times in 11 Posts
Send a message via ICQ to madmucho
Default test

Heloo.
I tested your addon on ISPCONFIG 2 with roundcubemail package from ispconfig.com webpage currently 3.1.
So i login using email address but have problem that new profile have created as name web2_pok2 with correct email, du u thing that can be corrected ? or if i can test that somehow?

i using ispconfig with mysql database and user for connection is same as in script config.inc.php.
Reply With Quote
  #10  
Old 5th December 2010, 14:55
necromncr necromncr is offline
Junior Member
 
Join Date: Jul 2008
Posts: 9
Thanks: 1
Thanked 6 Times in 3 Posts
 
Default

Quote:
Originally Posted by madmucho View Post
Heloo.
So i login using email address but have problem that new profile have created as name web2_pok2 with correct email, du u thing that can be corrected ? or if i can test that somehow?
Did you use this on your existing profile or a new profile? This solution will work only for new profiles, old ones will still have their settings intact. You will be able to authenticate though.

Last edited by necromncr; 5th December 2010 at 14:59. Reason: Reason for the first question
Reply With Quote
Reply

Bookmarks

Tags
ispconfig 2, roundcube, webmail

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
Which XEN howto is recommended for webhosting? Hans HOWTO-Related Questions 2 29th June 2009 18:23


All times are GMT +2. The time now is 00:46.


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