comparison plugins/password/drivers/hmail.php @ 0:1e000243b222

vanilla 1.3.3 distro, I hope
author Charlie Root
date Thu, 04 Jan 2018 15:50:29 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1e000243b222
1 <?php
2
3 /**
4 * hMailserver password driver
5 *
6 * @version 2.0
7 * @author Roland 'rosali' Liebl <myroundcube@mail4us.net>
8 *
9 * Copyright (C) 2005-2014, The Roundcube Dev Team
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see http://www.gnu.org/licenses/.
23 */
24
25 class rcube_hmail_password
26 {
27 public function save($curpass, $passwd)
28 {
29 $rcmail = rcmail::get_instance();
30
31 if ($curpass == '' || $passwd == '') {
32 return PASSWORD_ERROR;
33 }
34
35 try {
36 $remote = $rcmail->config->get('hmailserver_remote_dcom', false);
37 if ($remote)
38 $obApp = new COM("hMailServer.Application", $rcmail->config->get('hmailserver_server'));
39 else
40 $obApp = new COM("hMailServer.Application");
41 }
42 catch (Exception $e) {
43 rcube::write_log('errors', "Plugin password (hmail driver): " . trim(strip_tags($e->getMessage())));
44 rcube::write_log('errors', "Plugin password (hmail driver): This problem is often caused by DCOM permissions not being set.");
45 return PASSWORD_ERROR;
46 }
47
48 $username = $rcmail->user->data['username'];
49 if (strstr($username,'@')){
50 $temparr = explode('@', $username);
51 $domain = $temparr[1];
52 }
53 else {
54 $domain = $rcmail->config->get('username_domain',false);
55 if (!$domain) {
56 rcube::write_log('errors','Plugin password (hmail driver): $config[\'username_domain\'] is not defined.');
57 return PASSWORD_ERROR;
58 }
59 $username = $username . "@" . $domain;
60 }
61
62 $obApp->Authenticate($username, $curpass);
63 try {
64 $obDomain = $obApp->Domains->ItemByName($domain);
65 $obAccount = $obDomain->Accounts->ItemByAddress($username);
66 $obAccount->Password = $passwd;
67 $obAccount->Save();
68 return PASSWORD_SUCCESS;
69 }
70 catch (Exception $e) {
71 rcube::write_log('errors', "Plugin password (hmail driver): " . trim(strip_tags($e->getMessage())));
72 rcube::write_log('errors', "Plugin password (hmail driver): This problem is often caused by DCOM permissions not being set.");
73 return PASSWORD_ERROR;
74 }
75 }
76 }