diff options
author | thomascube <thomas@roundcube.net> | 2011-10-19 15:28:11 +0000 |
---|---|---|
committer | thomascube <thomas@roundcube.net> | 2011-10-19 15:28:11 +0000 |
commit | 5da48a95224e925f4b070f2581a121516df33829 (patch) | |
tree | fadc87888faae54cdb1efc6f7b73fbfce79e0fe7 /plugins/password/drivers/hmail.php | |
parent | b03854de3a36a322bf98c733ed9b75d996694e38 (diff) |
Copy plugins to release branch
Diffstat (limited to 'plugins/password/drivers/hmail.php')
-rw-r--r-- | plugins/password/drivers/hmail.php | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/plugins/password/drivers/hmail.php b/plugins/password/drivers/hmail.php new file mode 100644 index 000000000..39a87ab34 --- /dev/null +++ b/plugins/password/drivers/hmail.php @@ -0,0 +1,61 @@ +<?php + +/** + * hMailserver password driver + * + * @version 1.3 - 05.11.2010 + * @author Roland 'rosali' Liebl <myroundcube@mail4us.net> + * + */ + +function password_save($curpass, $passwd) +{ + $rcmail = rcmail::get_instance(); + + if ($curpass == '' || $passwd == '') + return PASSWORD_ERROR; + + try { + $remote = $rcmail->config->get('hmailserver_remote_dcom', false); + if ($remote) + $obApp = new COM("hMailServer.Application", $rcmail->config->get('hmailserver_server')); + else + $obApp = new COM("hMailServer.Application"); + } + catch (Exception $e) { + write_log('errors', "Plugin password (hmail driver): " . trim(strip_tags($e->getMessage()))); + 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) { + write_log('errors','Plugin password (hmail driver): $rcmail_config[\'username_domain\'] is not defined.'); + write_log('errors','Plugin password (hmail driver): Hint: Use hmail_login plugin (http://myroundcube.googlecode.com'); + 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) { + write_log('errors', "Plugin password (hmail driver): " . trim(strip_tags($e->getMessage()))); + write_log('errors', "Plugin password (hmail driver): This problem is often caused by DCOM permissions not being set."); + return PASSWORD_ERROR; + } +} + +?> |