You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hmail.php 2.8KB

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