Author Topic: RC Plugin "password" configuration for Hmailserver  (Read 13390 times)

Offline OlafWalther

  • Newbie
  • *
  • Posts: 4
RC Plugin "password" configuration for Hmailserver
« on: February 26, 2018, 04:41:06 AM »
Hello,

i try to configure the RC Plugin "password" to allow user changing their emailpassword from a local hmailserver.
I follwed the readme instructions.
After I`ve changed the email password and clicked on "save". Roundcube leaves with a blank space.
RC hangs on http://127.0.0.1/?_task=settings&_action=plugin.password-save

This is my installation:
OS Windows 10 64bit Pro
all programs on localhost
XAMP v3.2.2
MySql: 5.7.20 X86
PHP 7.2.1
Roundcube 1.3.4
HMailserver 5.6.6

com.allow_dcom = true is activated

The hole Installtion runs fine but i can´t get the password plug to work.

The XAMP ERROR LOG shows:
[26-Feb-2018 09:04:50 UTC] PHP Fatal error:  Uncaught Error: Cannot use object of type rcube_config as array in C:\xampp\htdocs\plugins\password\drivers\hmail.php:6
Stack trace:
#0 C:\xampp\htdocs\plugins\password\password.php(322): include_once()
#1 C:\xampp\htdocs\plugins\password\password.php(172): password->_save('oldpassword', 'newpassword')
#2 C:\xampp\htdocs\program\lib\Roundcube\rcube_plugin_api.php(493): password->password_save()
#3 C:\xampp\htdocs\index.php(289): rcube_plugin_api->exec_action('plugin.password...')
#4 {main}
  thrown in C:\xampp\htdocs\plugins\password\drivers\hmail.php on line 6

best regards from Germany
Olaf
« Last Edit: February 26, 2018, 04:53:10 AM by OlafWalther »

Offline alec

  • Hero Member
  • *****
  • Posts: 1,363
Re: RC Plugin "password" configuration for Hmailserver
« Reply #1 on: February 26, 2018, 08:09:31 AM »
This error does not make sense. From where did you get the hmail.php file? Could you paste its content here?

Offline OlafWalther

  • Newbie
  • *
  • Posts: 4
Re: RC Plugin "password" configuration for Hmailserver
« Reply #2 on: February 27, 2018, 02:29:47 AM »
Thank you Alec for your reply,

i´ve changed line 6 to a wrong value. Now it is the original code.
But the password plugin does not work. The behavior is almost the same when i change and save the new emailpassword.
Roundcube stuck with a blank page after I´ve saved the password.
The blank page has following URL:
"http://127.0.0.1/?_task=settings&_action=plugin.password-save"

Here ist the last XAMP ERR Log:

[27-Feb-2018 07:05:28 UTC] PHP Fatal error:  Uncaught Error: Cannot use object of type rcube_config as array in C:\xampp\htdocs\plugins\password\drivers\hmail.php:6
Stack trace:
#0 C:\xampp\htdocs\plugins\password\password.php(322): include_once()
#1 C:\xampp\htdocs\plugins\password\password.php(172): password->_save('pcshop2010', 'KnipS!2000')
#2 C:\xampp\htdocs\program\lib\Roundcube\rcube_plugin_api.php(493): password->password_save()
#3 C:\xampp\htdocs\index.php(289): rcube_plugin_api->exec_action('plugin.password...')
#4 {main}
  thrown in C:\xampp\htdocs\plugins\password\drivers\hmail.php on line 6

<?php


this is my Hmail.php in (htdocs\plugins\password\drivers)

// Remote hMailServer configuration
// true: HMailserver is on a remote box (php.ini: com.allow_dcom = true)
// false: Hmailserver is on same box as PHP
$config['hmailserver_remote_dcom'] = false;
// Windows credentials
$config['hmailserver_server'] = array(
'Server' => '127.0.0.1', // hostname or ip address
'Username' => 'administrator', // windows username
'Password' => 'mypassword' // windows user password
);

/**
 * hMailserver password driver
 *
 * @version 2.0
 * @author Roland 'rosali' Liebl <myroundcube@mail4us.net>
 *
 * Copyright (C) 2005-2014, The Roundcube Dev Team
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
 */

class rcube_hmail_password
{
    public function save($curpass, $passwd)
    {
        $rcmail = rcmail::get_instance();

        if ($curpass == '' || $passwd == '') {
            return PASSWORD_ERROR;
        }

        try {
            $remote = $rcmail->config->get('127.0.0.1', false);
            if ($remote)
                $obApp = new COM("hMailServer.Application", $rcmail->config->get('127.0.0.1'));
            else
                $obApp = new COM("hMailServer.Application");
        }
        catch (Exception $e) {
            rcube::write_log('errors', "Plugin password (hmail driver): " . trim(strip_tags($e->getMessage())));
            rcube::write_log('errors', "Plugin password (hmail driver): This problem is often caused by DCOM permissions not being set.");
            return PASSWORD_ERROR;
        }

        $username = $rcmail->user->data['username'];
        if (strstr($username,'@')){
            $temparr = explode('@', $username);
            $domain = $temparr[1];
        }
        else {
            $domain = $rcmail->config->get('username_domain',false);
            if (!$domain) {
                rcube::write_log('errors','Plugin password (hmail driver): $config[\'username_domain\'] is not defined.');
                return PASSWORD_ERROR;
            }
            $username = $username . "@" . $domain;
        }

        $obApp->Authenticate($username, $curpass);
        try {
            $obDomain = $obApp->Domains->ItemByName($domain);
            $obAccount = $obDomain->Accounts->ItemByAddress($username);
            $obAccount->Password = $passwd;
            $obAccount->Save();
            return PASSWORD_SUCCESS;
        }
        catch (Exception $e) {
            rcube::write_log('errors', "Plugin password (hmail driver): " . trim(strip_tags($e->getMessage())));
            rcube::write_log('errors', "Plugin password (hmail driver): This problem is often caused by DCOM permissions not being set.");
            return PASSWORD_ERROR;
        }
    }
}


Thank you for your troubke
Olaf

Offline alec

  • Hero Member
  • *****
  • Posts: 1,363
Re: RC Plugin "password" configuration for Hmailserver
« Reply #3 on: February 27, 2018, 07:53:23 AM »
That configuration should be put into plugins/password/config.inc.php. Remove all custom code from hmail.php.