Пример #1
0
 public function testValidateCertificate()
 {
     $reflection = new ReflectionClass('\\garethp\\ews\\API\\NTLMSoapClient');
     $prop = $reflection->getProperty('validate');
     $prop->setAccessible(true);
     $client = new NTLMSoapClient('location', API\ExchangeWebServicesAuth::fromUsernameAndPassword('user', 'password'), __DIR__ . '/../../../Resources/wsdl/services.wsdl');
     $this->assertFalse($prop->getValue($client));
     $client->validateCertificate(true);
     $this->assertTrue($prop->getValue($client));
     $client->validateCertificate(false);
     $this->assertFalse($prop->getValue($client));
 }
 public function testFromUsernameAndPassword()
 {
     $expected = array('curl' => array(CURLOPT_HTTPAUTH => CURLAUTH_BASIC | CURLAUTH_NTLM, CURLOPT_USERPWD => 'testUser' . ':' . 'testPassword'));
     $this->assertEquals($expected, ExchangeWebServicesAuth::fromUsernameAndPassword('testUser', 'testPassword'));
 }
Пример #3
0
    /**
     * Perform the NTLM authenticated post against one of the chosen
     * endpoints.
     *
     * @param string $url URL to try posting to
     * @param string $email
     * @param string $password
     * @param string $username
     *
     * @return string The discovered settings
     */
    protected function doNTLMPost($url, $email, $password, $username)
    {
        $autodiscoverXml = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006">
 <Request>
  <EMailAddress>{$email}</EMailAddress>
  <AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema>
 </Request>
</Autodiscover>
XML;
        $postOptions = ['body' => $autodiscoverXml, 'timeout' => 2, 'allow_redirects' => true, 'headers' => ['Content-Type' => 'text/xml; charset=utf-8'], 'curl' => [], 'verify' => false];
        $auth = ExchangeWebServicesAuth::fromUsernameAndPassword($username, $password);
        $postOptions = array_replace_recursive($postOptions, $auth);
        try {
            $response = $this->httpPlayback->post($url, $postOptions);
        } catch (\Exception $e) {
            return false;
        }
        return $this->parseAutodiscoverResponse($response->getBody()->__toString());
    }
Пример #4
0
 public static function fromUsernameAndPassword($server, $username, $password, $options)
 {
     $self = new self();
     $self->createClient($server, ExchangeWebServicesAuth::fromUsernameAndPassword($username, $password), $options);
     $self->options = $options;
     return $self;
 }