Roundcube Community Forum

 

RC Plugin "password" configuration for Hmailserver

Started by OlafWalther, February 26, 2018, 04:41:06 AM

Previous topic - Next topic

OlafWalther

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

alec

This error does not make sense. From where did you get the hmail.php file? Could you paste its content here?

OlafWalther

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 <[email protected]>
*
* 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

alec

That configuration should be put into plugins/password/config.inc.php. Remove all custom code from hmail.php.