/**
  * @param \RainLoop\Model\Account $oHmailAccount
  * @param string $sPrevPassword
  * @param string $sNewPassword
  *
  * @return bool
  */
 public function ChangePassword(\RainLoop\Account $oHmailAccount, $sPrevPassword, $sNewPassword)
 {
     if ($this->oLogger) {
         $this->oLogger->Write('Try to change password for ' . $oHmailAccount->Email());
     }
     $bResult = false;
     try {
         $oHmailApp = new COM("hMailServer.Application");
         $oHmailApp->Connect();
         if ($oHmailApp->Authenticate($this->sLogin, $this->sPassword)) {
             $sEmail = $oHmailAccount->Email();
             $sDomain = \MailSo\Base\Utils::GetDomainFromEmail($sEmail);
             $oHmailDomain = $oHmailApp->Domains->ItemByName($sDomain);
             if ($oHmailDomain) {
                 $oHmailAccount = $oHmailDomain->Accounts->ItemByAddress($sEmail);
                 if ($oHmailAccount) {
                     $oHmailAccount->Password = $sNewPassword;
                     $oHmailAccount->Save();
                     $bResult = true;
                 } else {
                     $this->oLogger->Write('HMAILSERVER: Unknown account (' . $sEmail . ')', \MailSo\Log\Enumerations\Type::ERROR);
                 }
             } else {
                 $this->oLogger->Write('HMAILSERVER: Unknown domain (' . $sDomain . ')', \MailSo\Log\Enumerations\Type::ERROR);
             }
         } else {
             $this->oLogger->Write('HMAILSERVER: Auth error', \MailSo\Log\Enumerations\Type::ERROR);
         }
     } catch (\Exception $oException) {
         if ($this->oLogger) {
             $this->oLogger->WriteException($oException);
         }
     }
     return $bResult;
 }
Beispiel #2
0
 public function 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;
     }
 }
Beispiel #3
0
/**
 * hMailserver password driver
 *
 * @version 1.0
 * @author Roland 'rosali' Liebl <*****@*****.**>
 *
 */
function password_save($curpass, $passwd)
{
    $rcmail = rcmail::get_instance();
    try {
        $obApp = new COM("hMailServer.Application");
    } catch (Exception $e) {
        write_log('errors', 'Plugin password:'******'. This problem is often caused by DCOM permissions not being set.');
        return PASSWORD_ERROR;
    }
    $username = $rcmail->user->data['username'];
    $temparr = explode('@', $username);
    $domain = $temparr[1];
    $obApp->Authenticate($username, $curpass);
    $obDomain = $obApp->Domains->ItemByName($domain);
    $obAccount = $obDomain->Accounts->ItemByAddress($username);
    $obAccount->Password = $passwd;
    $obAccount->Save();
    return PASSWORD_SUCCESS;
}
Beispiel #4
0
 function getHmsComServer($user)
 {
     $conf = $this->rc->config->get('hmailserver_server_for_hmsrc');
     $obBaseApp = new COM("hMailServer.Application", NULL, CP_UTF8);
     $obBaseApp->Connect();
     $obBaseApp->Authenticate($conf['Username'], $conf['Password']);
     $obDomain = $obBaseApp->Domains->ItemByName(substr($user, strpos($user, "@") + 1));
     return $obDomain->Accounts->ItemByAddress($user);
 }
Beispiel #5
0
function user_delete_backend($props, $authenticate)
{
    if (class_exists('COM')) {
        $username = strtolower(trim($props['username']));
        $domain = explode('@', $username);
        $domain = strtolower($domain[1]);
        $p = user_get_backend(array('arg' => $username), $authenticate);
        if (!$p['abort']) {
            try {
                $obApp = new COM('hMailServer.Application');
                $obApp->Authenticate($authenticate['admin'], $authenticate['password']);
                $obDomain = $obApp->Domains->ItemByName($domain);
                $obAccount = $obDomain->Accounts->ItemByAddress($username);
                $obDomain->Accounts->DeleteByDBID($obAccount->ID);
                $p = user_get_backend(array('arg' => $username), $authenticate);
                if ($p['abort']) {
                    $props = array('abort' => false);
                } else {
                    $props = array('abort' => true, 'message' => array('type' => 'error', 'label' => 'errorsaving'));
                }
            } catch (Exception $e) {
                $props = array('abort' => true, 'message' => array('type' => 'error', 'label' => 'errorsaving'));
            }
        } else {
            $props = array('abort' => true, 'message' => array('type' => 'error', 'label' => 'companyaddressbook.usernotfound'));
        }
    } else {
        $props = array('abort' => true, 'message' => array('type' => 'error', 'label' => 'companyaddressbook.COMerror'));
    }
    return $props;
}
Beispiel #6
0
 #Get the hmail domain id for the users mailbox
 $hmaildatabase = GetSystemOption('hmailserver_db');
 $sql = "SELECT accountdomainid FROM hm_accounts WHERE accountid='" . $faaccountid . "'";
 $listaccountdomainid = DataExchange("r", $hmaildatabase, $sql);
 $rowaccountdomainid = mysql_fetch_assoc($listaccountdomainid);
 $faadomainid = $rowaccountdomainid['accountdomainid'];
 #we try to connect to the hmailserver
 $obBaseApp = new COM("hMailServer.Application");
 if (!$obBaseApp) {
     header("location: " . GetNormalModuleURL($returnurl) . "&r=hmcomerror");
     exit;
 }
 #connection established, now we authenticate
 $obBaseApp->Connect();
 // Authenticate the user
 $obBaseApp->Authenticate($Usermailbox, $ExMessageAuth);
 if (!$obBaseApp->Authenticate($Usermailbox, $ExMessageAuth)) {
     header("location: " . GetNormalModuleURL($returnurl) . "&r=hmautherror&mb=" . $Usermailbox . "");
     exit;
 }
 #we have authenticated, and all our variables set up so lets move on...
 $domainid = $faadomainid;
 $accountid = $faaccountid;
 $obDomain = $obBaseApp->Domains->ItemByDBID($domainid);
 $obAccount = $obDomain->Accounts->ItemByDBID($accountid);
 $obFetchAccounts = $obAccount->FetchAccounts();
 $obFA = $obFetchAccounts->Add();
 $obFA->Enabled = '1';
 $obFA->Name = $ExMessageAccount;
 $obFA->MinutesBetweenFetch = $ExMessagecheck;
 $obFA->Port = $ExMessagePort;
require_once 'config.php';
//initialize php variables used in the form
$username = "";
$password = "";
$password_confirm = "";
$error = "";
//check to see that the form has been submitted
if (isset($_POST)) {
    //retrieve the $_POST variables
    $username = rawurldecode($_POST['username']);
    $password = rawurldecode($_POST['password']);
    $password_confirm = rawurldecode($_POST['password_confirm']);
    if (!$CONF['dev_env']) {
        $obBaseApp = new COM("hMailServer.Application");
        $obBaseApp->Connect();
        $obBaseApp->Authenticate($CONF['mail_admin_user'], $CONF['mail_admin_pass']);
        $domain = $obBaseApp->Domains->ItemByName($CONF['host']);
    }
    //initialize variables for form validation
    $success = true;
    if ($success && safe_register($username) != $username) {
        $error = "Invalid Characters in username.";
        $success = false;
    }
    $username = safe_register($username);
    if ($success && !$username) {
        $error = "You must input a Username.";
        $success = false;
    }
    //validate that the form was filled out correctly
    //check to see if user name already exists
Beispiel #8
0
require_once "include/functions.php";
require_once "include_versioncheck.php";
session_start();
// Connect to hMailServer
try {
    $obBaseApp = new COM("hMailServer.Application");
} catch (Exception $e) {
    echo $e->getMessage();
    echo "<br>";
    echo "This problem is often caused by DCOM permissions not being set.";
    die;
}
if ($obBaseApp->Version != REQUIRED_VERSION) {
    echo "<br>";
    echo "The hMailServer version does not match the WebAdmin version.<br>";
    echo "hMailServer version: " . $obBaseApp->Version . "<br>";
    echo "WebAdmin version: " . REQUIRED_VERSION . "<br>";
    echo "Please make sure you are using the PHPWebAdmin version which came with your hMailServer installation.<br>";
    die;
}
try {
    $obBaseApp->Connect();
    if (isset($_SESSION['session_username']) && isset($_SESSION['session_password'])) {
        // Authenticate the user
        $obBaseApp->Authenticate($_SESSION['session_username'], $_SESSION['session_password']);
    }
} catch (Exception $e) {
    echo $e->getMessage();
    die;
}
$obLanguage = $obBaseApp->GlobalObjects->Languages->ItemByName($hmail_config['defaultlanguage']);