Exemplo n.º 1
0
<?php

use garethp\ews\API\Type\ConnectingSIDType;
use garethp\ews\API\Type\ExchangeImpersonation;
//Impersonate an email address
$api = \garethp\ews\API::withUsernameAndPassword('server', 'username', 'password', ['impersonation' => '*****@*****.**']);
//Build your own impersonation
$connectingSID = new ConnectingSIDType();
$connectingSID->setPrincipalName('Some Name');
$connectingSID->setPrimarySmtpAddress('*****@*****.**');
$impersonation = new ExchangeImpersonation();
$impersonation->setConnectingSID($connectingSID);
$api = \garethp\ews\API::withUsernameAndPassword('server', 'username', 'password', ['impersonation' => $impersonation]);
Exemplo n.º 2
0
 /**
  * @param string $location
  * @param string $wsdl
  * @param array $options
  */
 public function __construct($location, $auth, $wsdl, $options = array())
 {
     $this->auth = $auth;
     $options = array_replace_recursive(['httpPlayback' => ['mode' => null]], $options);
     $options['location'] = $location;
     // If a version was set then add it to the headers.
     if (!empty($options['version'])) {
         $this->ewsHeaders['version'] = new SoapHeader('http://schemas.microsoft.com/exchange/services/2006/types', 'RequestServerVersion Version="' . $options['version'] . '"');
     }
     // If impersonation was set then add it to the headers.
     if (!empty($options['impersonation'])) {
         $impersonation = $options['impersonation'];
         if (is_string($impersonation)) {
             $impersonation = ExchangeImpersonation::fromEmailAddress($options['impersonation']);
         }
         $this->ewsHeaders['impersonation'] = new SoapHeader('http://schemas.microsoft.com/exchange/services/2006/types', 'ExchangeImpersonation', $impersonation->toXmlObject());
     }
     if (!empty($options['timezone'])) {
         $this->ewsHeaders['timezone'] = new SoapHeader('http://schemas.microsoft.com/exchange/services/2006/types', 'TimeZoneContext', array('TimeZoneDefinition' => array('Id' => $options['timezone'])));
     }
     $this->httpClient = Factory::getInstance($options['httpPlayback']);
     parent::__construct($wsdl, $options);
 }