public static function login($username, $password) { // Login to MAPI to check credentials $mapiSession = mapi_logon_zarafa($username, $password, ZARAFA_SERVER); if ($mapiSession == false) { return false; } Encryption::add('username', $username); Encryption::add('password', $password); Authentication::$_authenticated = true; }
function openMsgStore($username, $password) { $session = mapi_logon_zarafa($username, $password, SERVER); if (mapi_last_hresult() != 0) { trigger_error(sprintf("MAPI Error: 0x%x", mapi_last_hresult()), E_USER_ERROR); } $storesTable = mapi_getmsgstorestable($session); $stores = mapi_table_queryallrows($storesTable, array(PR_ENTRYID, PR_MDB_PROVIDER)); for ($i = 0; $i < count($stores); $i++) { if ($stores[$i][PR_MDB_PROVIDER] == ZARAFA_SERVICE_GUID) { $storeEntryid = $stores[$i][PR_ENTRYID]; break; } } if (!isset($storeEntryid)) { trigger_error("Default store not found", E_USER_ERROR); } $store = mapi_openmsgstore($session, $storeEntryid); isUnicodeStore($store); return $store; }
function zpa_zarafa_admin_setup($mapi, $user, $pass) { require PHP_MAPI_PATH . 'mapi.util.php'; require PHP_MAPI_PATH . 'mapidefs.php'; require PHP_MAPI_PATH . 'mapicode.php'; require PHP_MAPI_PATH . 'mapitags.php'; require PHP_MAPI_PATH . 'mapiguid.php'; $session = @mapi_logon_zarafa($user, $pass, $mapi); if (!$session) { echo "User '{$user}' could not login. The script will exit. Errorcode: 0x" . sprintf("%x", mapi_last_hresult()) . "\n"; exit(1); } $stores = @mapi_getmsgstorestable($session); $storeslist = @mapi_table_queryallrows($stores); $adminStore = @mapi_openmsgstore($session, $storeslist[0][PR_ENTRYID]); if (!$stores || !$storeslist || !$adminStore) { echo "There was error trying to log in as admin or retrieving admin info. The script will exit.\n"; exit(1); } return array("session" => $session, "adminStore" => $adminStore); }
/** * Constructor */ public function __construct() { parent::__construct(); // send Z-Push version and user agent to ZCP >7.2.0 if ($this->checkMapiExtVersion('7.2.0')) { $this->session = mapi_logon_zarafa(USERNAME, PASSWORD, SERVER, CERTIFICATE, CERTIFICATE_PASSWORD, 0, self::VERSION, self::NAME . " " . self::VERSION); } else { $this->session = mapi_logon_zarafa(USERNAME, PASSWORD, SERVER, CERTIFICATE, CERTIFICATE_PASSWORD, 0); } if (mapi_last_hresult()) { $this->Terminate(sprintf("Kopano: login failed with error code: 0x%08X", mapi_last_hresult())); } $this->mainUser = USERNAME; $this->targetStore = HIDDEN_FOLDERSTORE; $this->defaultstore = $this->openMessageStore($this->mainUser); $this->store = $this->openMessageStore(HIDDEN_FOLDERSTORE); $this->folderCache = array(); $this->storeCache = array(); $this->mapiprops = array("chunktype" => "PT_STRING8:PSETID_Appointment:0x6822", "chunkCRC" => "PT_STRING8:PSETID_Appointment:0x8208", "createtime" => "PT_SYSTIME:PSETID_Appointment:0x820d", "updatetime" => "PT_SYSTIME:PSETID_Appointment:0x820e", "reminderset" => "PT_BOOLEAN:PSETID_Common:0x8503", "isrecurring" => "PT_BOOLEAN:PSETID_Appointment:0x8223", "busystatus" => "PT_LONG:PSETID_Appointment:0x8205"); $this->mapiprops = getPropIdsFromStrings($this->store, $this->mapiprops); }
function Logon($user, $domain, $pass) { $pos = strpos($user, "\\"); if ($pos) { $user = substr($user, $pos + 1); } $this->_session = mapi_logon_zarafa($user, $pass, MAPI_SERVER); if ($this->_session === false) { debugLog("logon failed for user {$user}"); $this->_defaultstore = false; return false; } // Get/open default store $this->_defaultstore = $this->_openDefaultMessageStore($this->_session); if ($this->_defaultstore === false) { debugLog("user {$user} has no default store"); return false; } $this->_importedFolders = array(); debugLog("User {$user} logged on"); $this->_isUnicodeStore(); return true; }
} } // final cleanup $dup_count = count($dup_messages); if ($dup_count) { $total_deleted += $dup_count; echo " [i] Finally deleting {$dup_count} duplicates. \n"; delete_messages($folder, $dup_messages); $dup_messages = array(); echo "Deleted {$total_deleted} messages so far.\n\n"; } } /* * END FUNCTIONS */ $session = mapi_logon_zarafa("{$zarafa_user}", "", "{$zarafa_sock}"); if (!$session) { print "Unable to open session\n"; exit(1); } $msgstorestable = mapi_getmsgstorestable($session); if (!$msgstorestable) { print "Unable to open message stores table\n"; exit(1); } $msgstores = mapi_table_queryallrows($msgstorestable, array(PR_DEFAULT_STORE, PR_ENTRYID)); foreach ($msgstores as $row) { if ($row[PR_DEFAULT_STORE]) { $default_store_entry_id = $row[PR_ENTRYID]; } }
function logon() { $this->session = mapi_logon_zarafa($this->options->loginuser, $this->options->password, "file:///var/run/zarafa"); if (!$this->session) { print "Logon failure\n"; exit(RESULT_ERROR_LOG_FAILURE); } }
require "server/core/class.properties.php"; require "server/modules/class.appointmentitemmodule.php"; require "server/modules/class.appointmentlistmodule.php"; if (isset($_POST['user']) && isset($_POST["pwd"]) && isset($_POST['zid'])) { ////////////////////////////////// /// get username and password ////////////////////////////////// $username = $_POST['user']; $password = $_POST['pwd']; $server = 'http://localhost:236/zarafa'; //////////////////////////////// //connect to the zarafa server /////////////////////////////// $GLOBALS["mapisession"] = new MAPISession(); $sess = $GLOBALS["mapisession"]->logon($username, $password, $server); $session = mapi_logon_zarafa($username, $password, $server); $bus = new Bus(); // Create global bus object $GLOBALS["bus"] = $bus; // Make bus global $GLOBALS["settings"] = new Settings(); $storelist = $GLOBALS["mapisession"]->getAllMessageStores(); $id = "webclient_7"; //define an id $GLOBALS["operations"] = new Operations(); $datas = $GLOBALS["operations"]->getHierarchyList(array(PR_IPM_APPOINTMENT_ENTRYID)); $store_idhex = $datas[store][0][attributes][id]; $entryidhex = $datas[store][0][defaultfolders][calendar]; $entryid = hex2bin($entryidhex); $appointment_id = $_POST['zid']; $GLOBALS["properties"] = new Properties();
function listfolders_zarafa_admin_setup($mapi, $user, $pass) { $session = @mapi_logon_zarafa($user, $pass, $mapi); if (!$session) { echo "User '{$user}' could not login. The script will exit. Errorcode: 0x" . sprintf("%x", mapi_last_hresult()) . "\n"; exit(1); } $stores = @mapi_getmsgstorestable($session); $storeslist = @mapi_table_queryallrows($stores); $adminStore = @mapi_openmsgstore($session, $storeslist[0][PR_ENTRYID]); $zarafauserinfo = @mapi_zarafa_getuser_by_name($adminStore, $user); $admin = isset($zarafauserinfo['admin']) && $zarafauserinfo['admin'] ? true : false; if (!$stores || !$storeslist || !$adminStore || !$admin) { echo "There was error trying to log in as admin or retrieving admin info. The script will exit.\n"; exit(1); } return array("session" => $session, "adminStore" => $adminStore); }
/* FILETIME 64-bit int w/ number of 100ns periods since Jan 1,1601 */ define('PR_DEFAULT_STORE', mapi_prop_tag(PT_BOOLEAN, 0x3400)); define('PR_ENTRYID', mapi_prop_tag(PT_BINARY, 0xfff)); define('PR_IPM_WASTEBASKET_ENTRYID', mapi_prop_tag(PT_BINARY, 0x35e3)); define('PR_CREATION_TIME', mapi_prop_tag(PT_SYSTIME, 0x3007)); function greaterDate($start_date, $daysBeforeDeleted) { return strtotime($start_date) - strtotime(date('Y-m-d G:i:s', strtotime("-{$daysBeforeDeleted} days"))) < 0 ? 1 : 0; } // Add the SVN revision number to the version $mapi_version = str_replace('-', '.', phpversion('mapi')); // Log in to Zarafa server if (version_compare($mapi_version, '7.2.0.46424', '>=')) { $l_rSession = mapi_logon_zarafa($l_sUsername, $l_sPassword, $l_sServer, NULL, NULL, NULL, NULL); } else { $l_rSession = mapi_logon_zarafa($l_sUsername, $l_sPassword, $l_sServer); } echo (mapi_last_hresult() == 0 ? "Logged in successfully" : "Some error in login") . "\n"; // Get a table with the message stores within this session $l_rTableStores = mapi_getmsgstorestable($l_rSession); echo (mapi_last_hresult() == 0 ? "Processing to get data... " : "Some error in processing...") . "\n"; // Retrieve the default store by querying the table $l_aTableRows = mapi_table_queryallrows($l_rTableStores, array(PR_ENTRYID, PR_DEFAULT_STORE)); echo (mapi_last_hresult() == 0 ? "Fetching Deleted Folder..." : "Some error in fetching...") . "\n"; $l_bbnEntryID = false; // Either boolean or binary // Loop through returned rows for ($i = 0; $i < count($l_aTableRows); $i++) { // Check to see if this entry is the default store if (isset($l_aTableRows[$i][PR_DEFAULT_STORE]) && $l_aTableRows[$i][PR_DEFAULT_STORE] == true) { $storeEntryId = $l_aTableRows[$i][PR_ENTRYID];
} while (1) { $rows = mapi_table_queryrows($table, array(PR_MESSAGE_SIZE), 0, 100); if (count($rows) == 0) { break; } foreach ($rows as $row) { if (isset($row[PR_MESSAGE_SIZE])) { $size += $row[PR_MESSAGE_SIZE]; } } } return $size; } $times["load"] = t(); $session = mapi_logon_zarafa($argv[1], "", "file:///var/run/zarafa"); $times["logon"] = t(); $msgstorestable = mapi_getmsgstorestable($session); $msgstores = mapi_table_queryallrows($msgstorestable, array(PR_DEFAULT_STORE, PR_ENTRYID)); $times["stores"] = t(); foreach ($msgstores as $row) { if ($row[PR_DEFAULT_STORE]) { $storeentryid = $row[PR_ENTRYID]; } } if (!$storeentryid) { print "Can't find default store\n"; exit(1); } $store = mapi_openmsgstore($session, $storeentryid); if (!$store) {
function ScanMailBox($uid) { $ct = new user($uid); $sock = new sockets(); $username = $uid; $password = $ct->password; $zarafa_sock = "file:///var/run/zarafa"; $ZarafaServerListenIP = $sock->GET_INFO("ZarafaServerListenIP"); if ($ZarafaServerListenIP == null) { $ZarafaServerListenIP = "127.0.0.1"; } if ($ZarafaServerListenIP == "0.0.0.0") { $ZarafaServerListenIP = "127.0.0.1"; } $ZarafaServerListenPort = intval($sock->GET_INFO("ZarafaServerListenPort")); if ($ZarafaServerListenPort == 0) { $ZarafaServerListenPort = 236; } $zarafaServer = "http://{$ZarafaServerListenIP}:{$ZarafaServerListenPort}/zarafa"; $session = mapi_logon_zarafa($username, $password, $zarafaServer); $hard_delete_messages = true; $folder_to_process = 'Sent Items'; $total_deleted = 0; if (!$session) { print "Unable to open session {$username}@{$zarafaServer} `{$password}`\n"; return; } $msgstorestable = mapi_getmsgstorestable($session); if (!$msgstorestable) { print "Unable to open message stores table\n"; return; } $msgstores = mapi_table_queryallrows($msgstorestable, array(PR_DEFAULT_STORE, PR_ENTRYID)); foreach ($msgstores as $row) { if ($row[PR_DEFAULT_STORE]) { $default_store_entry_id = $row[PR_ENTRYID]; } } $default_store = mapi_openmsgstore($session, $default_store_entry_id); if (!$default_store) { print "Unable to open default store\n"; exit(1); } $root = mapi_msgstore_openentry($default_store); // get folders $folders = mapi_folder_gethierarchytable($root, CONVENIENT_DEPTH); // loop over every folder while (1) { $rows = mapi_table_queryrows($folders, array(PR_DISPLAY_NAME, PR_FOLDER_TYPE, PR_ENTRYID), 0, 100); if (count($rows) == 0) { break; } foreach ($rows as $row) { // skip searchfolders if (isset($row[PR_FOLDER_TYPE]) && $row[PR_FOLDER_TYPE] == FOLDER_SEARCH) { continue; } // operate only on folders, whose name is specified in the config section. // Like 'Sent Objects'. if ($row[PR_DISPLAY_NAME] == $folder_to_process) { parse_messages($default_store, $row[PR_ENTRYID]); } } } }
// The charset of the CSV input files //set it to true if the first line of the csv file contains field names, it will be skipped then. define("FIELD_NAMES", true); //the format of date values: true if they are as unix timestamps, false otherwise define("DATES_AS_TIMESTAMPS", false); // mapping for the csv column number to contact field (first field is 0) $csv_mapping = array("given_name" => 0, "middle_name" => 1, "surname" => 2, "display_name_prefix" => 3, "webpage" => 6, "birthday" => 8, "wedding_anniversary" => 9, "notes" => 13, "email_address_1" => 14, "email_address_2" => 15, "email_address_3" => 16, "home_telephone_number" => 18, "home2_telephone_number" => 19, "cellular_telephone_number" => 20, "pager_telephone_number" => 21, "home_fax_number" => 22, "home_address" => 23, "home_address_street" => 24, "home_address_street2" => 25, "home_address_street3" => 26, "home_address_pobox" => 27, "home_address_city" => 28, "home_address_state" => 29, "home_address_postal_code" => 30, "home_address_country" => 31, "spouse_name" => 32, "manager_name" => 34, "assistant" => 35, "company_telephone_number" => 37, "office_telephone_number" => 38, "business2_telephone_number" => 39, "business_fax_number" => 40, "assistant_telephone_number" => 41, "company_name" => 42, "job_title" => 43, "department_name" => 44, "office_location" => 45, "profession" => 47, "business_address" => 49, "business_address_street" => 50, "business_address_street2" => 51, "business_address_street3" => 52, "business_address_pobox" => 53, "business_address_city" => 54, "business_address_state" => 55, "business_address_postal_code" => 56, "business_address_country" => 57, "other_telephone_number" => 58, "other_address" => 60, "other_address_street" => 61, "other_address_street2" => 62, "other_address_street3" => 63, "other_address_pobox" => 64, "other_address_city" => 65, "other_address_state" => 66, "other_address_postal_code" => 67, "other_address_country" => 68, "callback_telephone_number" => 69, "car_telephone_number" => 70, "isdn_number" => 71, "radio_telephone_number" => 72, "ttytdd_telephone_number" => 73, "telex_telephone_number" => 74, "sensitivity" => 84, "categories" => 87); ########################## ## end of configuration ## ########################## error_reporting(E_ALL); ini_set("display_errors", true); ini_set("html_errors", false); mapidefs(); mapitags(); $session = mapi_logon_zarafa($username, $password, SERVER); if (mapi_last_hresult() != 0) { trigger_error(sprintf("MAPI Error: 0x%x", mapi_last_hresult()), E_USER_ERROR); } $storesTable = mapi_getmsgstorestable($session); $stores = mapi_table_queryallrows($storesTable, array(PR_ENTRYID, PR_MDB_PROVIDER)); for ($i = 0; $i < count($stores); $i++) { if ($stores[$i][PR_MDB_PROVIDER] == ZARAFA_SERVICE_GUID) { $storeEntryid = $stores[$i][PR_ENTRYID]; break; } } if (!isset($storeEntryid)) { trigger_error("Default store not found", E_USER_ERROR); } $store = mapi_openmsgstore($session, $storeEntryid);
} else { print "Permissions successfully set\n"; } } function resolve($session, $name) { $ab = mapi_openaddressbook($session); $resolved = mapi_ab_resolvename($ab, array(array(PR_DISPLAY_NAME => $name)), EMS_AB_ADDRESS_LOOKUP); $id = false; if ($resolved) { $id = $resolved[0][PR_ENTRYID]; } return $id; } // Log on to zarafa as admin user $session = mapi_logon_zarafa('SYSTEM', '', SERVER); if (!$session) { print "Unable to logon\n"; return; } // Get our stores table $storetable = mapi_getmsgstorestable($session); if (!$storetable) { print "Unable to get stores list\n"; return; } // Find our default store $stores = mapi_table_queryallrows($storetable, array(PR_DISPLAY_NAME, PR_ENTRYID, PR_DEFAULT_STORE)); $storenentryid = false; // Set default to false foreach ($stores as $row) {
/** * Connect to Zarafa and do some init * @param $user user login * @param $password user password */ public function connect($user, $password) { $this->logger->debug("connect({$user}," . md5($password) . ")"); $this->session = NULL; try { $session = mapi_logon_zarafa($user, $password, ZARAFA_SERVER); } catch (Exception $e) { $this->logger->debug("connection failed: " . get_mapi_error_name()); return false; } if ($session === FALSE) { // Failed return false; } $this->logger->trace("Connected to zarafa server - init bridge"); $this->session = $session; // Find user store $storesTable = mapi_getmsgstorestable($session); $stores = mapi_table_queryallrows($storesTable, array(PR_ENTRYID, PR_MDB_PROVIDER)); for ($i = 0; $i < count($stores); $i++) { switch ($stores[$i][PR_MDB_PROVIDER]) { case ZARAFA_SERVICE_GUID: $storeEntryid = $stores[$i][PR_ENTRYID]; break; case ZARAFA_STORE_PUBLIC_GUID: $pubStoreEntryid = $stores[$i][PR_ENTRYID]; break; } } if (!isset($storeEntryid)) { trigger_error("Default store not found", E_USER_ERROR); } $this->store = mapi_openmsgstore($this->session, $storeEntryid); $root = mapi_msgstore_openentry($this->store, null); $rootProps = mapi_getprops($root, array(PR_IPM_CONTACT_ENTRYID)); // Store rootfolder $this->rootFolder = mapi_msgstore_openentry($this->store, $rootProps[PR_IPM_CONTACT_ENTRYID]); $this->rootFolderId = $rootProps[PR_IPM_CONTACT_ENTRYID]; if (isset($pubStoreEntryid)) { $this->pubStore = mapi_openmsgstore($this->session, $pubStoreEntryid); $pubFolder = mapi_msgstore_openentry($this->pubStore); $h_table = mapi_folder_gethierarchytable($pubFolder, CONVENIENT_DEPTH); // $subfolders = mapi_table_queryallrows($h_table, array(PR_ENTRYID, PR_DISPLAY_NAME)); $subfolders = mapi_table_queryallrows($h_table); for ($i = 0; $i < count($subfolders); $i++) { $name = $subfolders[$i][PR_DISPLAY_NAME]; $entryid = $subfolders[$i][PR_ENTRYID]; $folder = mapi_msgstore_openentry($this->pubStore, $entryid); $props = mapi_getprops($folder); if (isset($props[PR_CONTAINER_CLASS_A]) && $props[PR_CONTAINER_CLASS_A] == "IPF.Contact") { $this->pubFolderIds[] = $entryid; $this->pubFolders[] = mapi_msgstore_openentry($this->pubStore, $entryid); } } } // Check for unicode $this->isUnicodeStore($this->store); // Load properties $this->initProperties(); // Store username for principals $this->connectedUser = $user; // Set protected variable to NULL. $this->adressBooks = NULL; return true; }
// mapi include files include '/usr/share/php/mapi/mapi.util.php'; include '/usr/share/php/mapi/mapidefs.php'; include '/usr/share/php/mapi/mapicode.php'; include '/usr/share/php/mapi/mapitags.php'; include '/usr/share/php/mapi/mapiguid.php'; // config options $ADMINUSERNAME = "******"; $ADMINPASSWORD = ""; $SERVER = "file:///var/run/zarafa"; $USAGEMESSAGE = "Usage:\n\tfor selected users \n\t\tphp clear_suggestionlist.php -u <username1> <username2> ...\n\tfor all users \n\t\tphp clear_suggestionlist.php -a\n"; if ($argc < 2) { exit($USAGEMESSAGE); } // use SYSTEM account for login $session = mapi_logon_zarafa($ADMINUSERNAME, $ADMINPASSWORD, $SERVER); if (!$session) { exit("Can't login into zarafa server\n"); } // get all stores of SYSTEM account $msgStoresTable = mapi_getmsgstorestable($session); $msgStores = mapi_table_queryallrows($msgStoresTable, array(PR_DEFAULT_STORE, PR_ENTRYID)); // get default store foreach ($msgStores as $row) { if ($row[PR_DEFAULT_STORE]) { $storeEntryid = $row[PR_ENTRYID]; } } if (!$storeEntryid) { exit("Can't find default store\n"); }
} if (!isset($_SERVER["LOGNAME"])) { echo "This script should not be called in a browser.\n"; exit(1); } define("MAPI_PATH", "/usr/share/php/mapi/"); define("ZARAFA_SERVER", "file:///var/run/zarafa"); define("ZARAFA_USER", "SYSTEM"); define("ZARAFA_PASS", ""); require MAPI_PATH . "mapi.util.php"; require MAPI_PATH . "mapicode.php"; require MAPI_PATH . "mapidefs.php"; require MAPI_PATH . "mapitags.php"; require MAPI_PATH . "mapiguid.php"; $supported_classes = array("IPF.Note" => "SYNC_FOLDER_TYPE_USER_MAIL", "IPF.Task" => "SYNC_FOLDER_TYPE_USER_TASK", "IPF.Appointment" => "SYNC_FOLDER_TYPE_USER_APPOINTMENT", "IPF.Contact" => "SYNC_FOLDER_TYPE_USER_CONTACT", "IPF.StickyNote" => "SYNC_FOLDER_TYPE_USER_NOTE"); $session = @mapi_logon_zarafa(ZARAFA_USER, ZARAFA_PASS, ZARAFA_SERVER); if (!$session) { die("Login to Zarafa failed\n"); } $storetable = @mapi_getmsgstorestable($session); $storeslist = @mapi_table_queryallrows($storetable, array(PR_ENTRYID, PR_MDB_PROVIDER)); for ($i = 0; $i < count($storeslist); $i++) { if ($storeslist[$i][PR_MDB_PROVIDER] == ZARAFA_STORE_PUBLIC_GUID) { $publicstore = @mapi_openmsgstore($session, $storeslist[$i][PR_ENTRYID]); break; } } if (!isset($publicstore)) { die("Public folder not available"); } $pub_folder = @mapi_msgstore_openentry($publicstore);
/** * Authenticates the user with the configured Zarafa server * * @param string $username * @param string $domain * @param string $password * * @access public * @return boolean * @throws AuthenticationRequiredException */ public function Logon($user, $domain, $pass) { ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZarafaBackend->Logon(): Trying to authenticate user '%s'..", $user)); $this->mainUser = strtolower($user); try { // check if notifications are available in php-mapi if (function_exists('mapi_feature') && mapi_feature('LOGONFLAGS')) { $this->session = @mapi_logon_zarafa($user, $pass, MAPI_SERVER, null, null, 0); $this->notifications = true; } else { $this->session = @mapi_logon_zarafa($user, $pass, MAPI_SERVER); $this->notifications = false; } if (mapi_last_hresult()) { ZLog::Write(LOGLEVEL_ERROR, sprintf("ZarafaBackend->Logon(): login failed with error code: 0x%X", mapi_last_hresult())); if (mapi_last_hresult() == MAPI_E_NETWORK_ERROR) { throw new HTTPReturnCodeException("Error connecting to ZCP (login)", 503, null, LOGLEVEL_INFO); } } } catch (MAPIException $ex) { throw new AuthenticationRequiredException($ex->getDisplayMessage()); } if (!$this->session) { ZLog::Write(LOGLEVEL_WARN, sprintf("ZarafaBackend->Logon(): logon failed for user '%s'", $user)); $this->defaultstore = false; return false; } // Get/open default store $this->defaultstore = $this->openMessageStore($this->mainUser); if (mapi_last_hresult() == MAPI_E_FAILONEPROVIDER) { throw new HTTPReturnCodeException("Error connecting to ZCP (open store)", 503, null, LOGLEVEL_INFO); } if ($this->defaultstore === false) { throw new AuthenticationRequiredException(sprintf("ZarafaBackend->Logon(): User '%s' has no default store", $user)); } $this->store = $this->defaultstore; $this->storeName = $this->mainUser; ZLog::Write(LOGLEVEL_DEBUG, sprintf("ZarafaBackend->Logon(): User '%s' is authenticated", $user)); // check if this is a Zarafa 7 store with unicode support MAPIUtils::IsUnicodeStore($this->store); return true; }
print "\n"; print "To do a test translation, use: -t <language>\n"; print "\n"; print "A <language> could be: nl_NL.UTF-8\n"; print "\n"; exit(2); } if ($argv[1] == "-t") { $trans_array = translate($argv[2], 1); foreach ($trans_array as $key => $value) { echo str_pad($key, 20, " "); echo "{$value}\n"; } exit(0); } $session = mapi_logon_zarafa("SYSTEM", "", "file:///var/run/zarafa"); $msgstorestable = mapi_getmsgstorestable($session); $msgstores = mapi_table_queryallrows($msgstorestable, array(PR_DEFAULT_STORE, PR_ENTRYID)); foreach ($msgstores as $row) { if ($row[PR_DEFAULT_STORE]) { $storeentryid = $row[PR_ENTRYID]; } } if (!$storeentryid) { print "Can't find default store\n"; exit(1); } $store = mapi_openmsgstore($session, $storeentryid); if (!$store) { print "Unable to open system store\n"; exit(1);
/** * Check authentication * @param string HTTP Authentication type (Basic, Digest, ...) * @param string Username * @param string Password * @return bool true on successful authentication */ function check_auth($type, $user, $pass) { $user = str_replace('%', '@', $user); // This fixes a logon problem with Evolution, login with user%domain instead of user@domain which seems to confuse evolution... $user = str_replace('$', '@', $user); // Mac OS X Address Book App fix $session = mapi_logon_zarafa($user, $pass, $this->server); if (false != $session) { $this->zarafa = $this->open_zarafa($session); $this->zarafa['user'] = $user; $this->specialprops = getPropIdsFromStrings($this->zarafa["store"], $this->specialprops); return true; } return false; }
print "\n"; exit(2); } if ($argv[1] == "-t") { $trans_array = translate($argv[2], 1); foreach ($trans_array as $key => $value) { echo str_pad($key, 20, " "); echo "{$value}\n"; } exit(0); } $socket = "file:///var/run/zarafa"; if (preg_match("#--socket=([0-9]+)#", @implode(" ", $argv), $re)) { $socket = "file:///var/run/zarafa-{$re[1]}"; } $session = mapi_logon_zarafa("SYSTEM", "", $socket); $msgstorestable = mapi_getmsgstorestable($session); $msgstores = mapi_table_queryallrows($msgstorestable, array(PR_DEFAULT_STORE, PR_ENTRYID)); foreach ($msgstores as $row) { if ($row[PR_DEFAULT_STORE]) { $storeentryid = $row[PR_ENTRYID]; } } if (!$storeentryid) { print "Can't find default store\n"; exit(1); } $store = mapi_openmsgstore($session, $storeentryid); if (!$store) { print "Unable to open system store\n"; exit(1);
/** * Authenticates the user with the configured Kopano server * * @param string $username * @param string $domain * @param string $password * * @access public * @return boolean * @throws AuthenticationRequiredException */ public function Logon($user, $domain, $pass) { ZLog::Write(LOGLEVEL_DEBUG, sprintf("KopanoBackend->Logon(): Trying to authenticate user '%s'..", $user)); $this->mainUser = strtolower($user); try { // check if notifications are available in php-mapi if (function_exists('mapi_feature') && mapi_feature('LOGONFLAGS')) { // send Z-Push version and user agent to ZCP - ZP-589 if (Utils::CheckMapiExtVersion('7.2.0')) { $zpush_version = 'Z-Push_' . @constant('ZPUSH_VERSION'); $user_agent = Request::GetDeviceID() ? ZPush::GetDeviceManager()->GetUserAgent() : "unknown"; $this->session = @mapi_logon_zarafa($user, $pass, MAPI_SERVER, null, null, 0, $zpush_version, $user_agent); } else { $this->session = @mapi_logon_zarafa($user, $pass, MAPI_SERVER, null, null, 0); } $this->notifications = true; } else { $this->session = @mapi_logon_zarafa($user, $pass, MAPI_SERVER); $this->notifications = false; } if (mapi_last_hresult()) { ZLog::Write(LOGLEVEL_ERROR, sprintf("KopanoBackend->Logon(): login failed with error code: 0x%X", mapi_last_hresult())); if (mapi_last_hresult() == MAPI_E_NETWORK_ERROR) { throw new HTTPReturnCodeException("Error connecting to KC (login)", 503, null, LOGLEVEL_INFO); } } } catch (MAPIException $ex) { throw new AuthenticationRequiredException($ex->getDisplayMessage()); } if (!$this->session) { ZLog::Write(LOGLEVEL_WARN, sprintf("KopanoBackend->Logon(): logon failed for user '%s'", $user)); $this->defaultstore = false; return false; } // Get/open default store $this->defaultstore = $this->openMessageStore($this->mainUser); if (mapi_last_hresult() == MAPI_E_FAILONEPROVIDER) { throw new HTTPReturnCodeException("Error connecting to KC (open store)", 503, null, LOGLEVEL_INFO); } if ($this->defaultstore === false) { throw new AuthenticationRequiredException(sprintf("KopanoBackend->Logon(): User '%s' has no default store", $user)); } $this->store = $this->defaultstore; $this->storeName = $this->mainUser; ZLog::Write(LOGLEVEL_DEBUG, sprintf("KopanoBackend->Logon(): User '%s' is authenticated", $user)); $this->isZPushEnabled(); // check if this is a Zarafa 7 store with unicode support MAPIUtils::IsUnicodeStore($this->store); return true; }