示例#1
0
 public function testConstructor()
 {
     $expectedAuth = API\ExchangeWebServicesAuth::fromUsernameAndPassword('testUser', 'testPassword');
     $ntlmClient = new NTLMSoapClient('testLocation', API\ExchangeWebServicesAuth::fromUsernameAndPassword('testUser', 'testPassword'), __DIR__ . '/../../../Resources/wsdl/services.wsdl', array('version' => 'testVersion', 'impersonation' => 'testImpersonation'));
     $reflection = new ReflectionClass('\\jamesiarmes\\PEWS\\API\\NTLMSoapClient\\Exchange');
     $expected = new SoapHeader('http://schemas.microsoft.com/exchange/services/2006/types', 'RequestServerVersion Version="testVersion"');
     $this->assertEquals($expected, $ntlmClient->__default_headers[0]);
     $expected = new SoapHeader('http://schemas.microsoft.com/exchange/services/2006/types', 'ExchangeImpersonation', API\Type\ExchangeImpersonation::fromEmailAddress('testImpersonation')->toXmlObject());
     $this->assertEquals($expected, $ntlmClient->__default_headers[1]);
 }
示例#2
0
<?php

use jamesiarmes\PEWS\API\Type\ConnectingSIDType;
use jamesiarmes\PEWS\API\Type\ExchangeImpersonation;
//Impersonate an email address
$api = \jamesiarmes\PEWS\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 = \jamesiarmes\PEWS\API::withUsernameAndPassword('server', 'username', 'password', ['impersonation' => $impersonation]);
示例#3
0
 /**
  * @param mixed $location
  * @param string $user
  * @param string $password
  * @param $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->__default_headers[] = 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->__default_headers[] = new SoapHeader('http://schemas.microsoft.com/exchange/services/2006/types', 'ExchangeImpersonation', $impersonation->toXmlObject());
     }
     if (!empty($options['timezone'])) {
         $this->__default_headers[] = new SoapHeader('http://schemas.microsoft.com/exchange/services/2006/types', 'TimeZoneContext', array('TimeZoneDefinition' => array('Id' => $options['timezone'])));
     }
     $this->httpPlayback = HttpPlayback::getInstance($options['httpPlayback']);
     parent::__construct($wsdl, $options);
 }