jamesiarmes / php-ews

PHP Exchange Web Services
http://jamesarmes.com/php-ews/
MIT License
566 stars 304 forks source link

Can't Set Timezone Exchange 2013 #363

Open BenjaminCan opened 7 years ago

BenjaminCan commented 7 years ago

I have been unable to set a timezone with Exchange 2013.

I get this error when trying to set StartTimeZone: Fatal error: Uncaught SoapFault exception: [a:ErrorSchemaValidation] The request failed schema validation: The element 'CalendarItem' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types' has invalid child element 'StartTimeZone' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'. List of possible elements expected: 'OriginalStart, IsAllDayEvent, LegacyFreeBusyStatus, Location, When, IsMeeting, IsCancelled, IsRecurring, MeetingRequestWasSent, IsResponseRequested, CalendarItemType, MyResponseType, Organizer, RequiredAttendees, OptionalAttendees, Resources, ConflictingMeetingCount, AdjacentMeetingCount, ConflictingMeetings, AdjacentMeetings, Duration, TimeZone, AppointmentReplyTime, AppointmentSequenceNumber, AppointmentState, Recurrence, FirstOccurrence, LastOccurrence, ModifiedOccurrences, DeletedOccurrences, MeetingTimeZone, ConferenceType, AllowNewTimeProposal, IsOnlineMeeting, MeetingWorkspaceUrl, NetShowUrl' in namespace 'http://schemas.microsoft.com/exchange/services/2006/type in C:\inetpub\wwwroot\MariniCRM-dev\app\php-ews-master\ExchangeWebServices.php on line 331

I can't run GetServerTimeZones example from the documentation: `Fatal error: Uncaught SoapFault exception: [a:ErrorSchemaValidation] The request failed schema validation: Could not find schema information for the element 'http://schemas.microsoft.com/exchange/services/2006/messages:GetServerTimeZones'. in C:\inetpub\wwwroot\MariniCRM-dev\app\php-ews-master\ExchangeWebServices.php:771 Stack trace:

0 C:\inetpub\wwwroot\MariniCRM-dev\app\php-ews-master\ExchangeWebServices.php(771): SoapClient->__call('GetServerTimeZo...', Array)

1 C:\inetpub\wwwroot\MariniCRM-dev\app\php-ews-master\ExchangeWebServices.php(771): NTLMSoapClient_Exchange->GetServerTimeZones(Object(EWSType_GetServerTimeZonesType))

2 C:\inetpub\wwwroot\MariniCRM-dev\app\app.ews.php(376): ExchangeWebServices->GetServerTimeZones(Object(EWSType_GetServerTimeZonesType))

3 C:\inetpub\wwwroot\MariniCRM-dev\tool\ews.calendar.list.php(33): CRMEWS->getSupportedTimezones()

4 {main}

thrown in C:\inetpub\wwwroot\MariniCRM-dev\app\php-ews-master\ExchangeWebServices.php on line 771 `

jamesiarmes commented 7 years ago

Can you please provide an example request that produces the error you have described?

BenjaminCan commented 7 years ago

This is the code that runs GetServerTimezones. ` class CRMEWS { private $host = ""; private $username = ""; private $password = ""; private $version = ""; private $impersonation = ""; private $ews;

public function __construct($Impersonate = null) {
    $this->ews = new ExchangeWebServices($this->host, $this->username, $this->password, $this->version);

    if (isset($Impersonate)) {
        $this->setImpersonation($Impersonate);
    }
}

public function setImpersonation($ImpersonatedUser) {
    $this->impersonation = $ImpersonatedUser;

    $ei = new EWSType_ExchangeImpersonationType();
    $sid = new EWSType_ConnectingSIDType();
    $sid->PrimarySmtpAddress = $ImpersonatedUser;
    $ei->ConnectingSID = $sid;
    $this->ews->setImpersonation($ei);
}

public function getSupportedTimezones() {
    $request = new EWSType_GetServerTimeZonesType();

    $response = $this->ews->GetServerTimeZones($request);
    var_dump($response);
}

} `

and then called with

$ews = new CRMEWS(); print_r($ews->getSupportedTimezones());

jamesiarmes commented 7 years ago

I see that you're using instance properties to set the properties on the constructor. I'm not sure how this is working since those properties wouldn't be set yet in the constructor, but make sure the version being passed matches the version of the server you are connecting to, as this operation was not added until Exchange 2010 and the default is 2007.

Assuming that is correct, I am not able to reproduce this using the latest version from master. I see that you're using an older version, so this may been resolved in a more recent update.

sritechie26 commented 6 years ago

ExchangeImpersonation SOAP header must not exist for this type of OAuth token. error while impersonation.

It was working fine on Exchange server 2007 and 2013, also on office 365 well. but from last couple of days its throwing some error while impersonating on office 365.

The error read as "ExchangeImpersonation SOAP header must not exist for this type of OAuth token."

It was working well earlier, Anyone faced this issue recently? any pointers to solve this issue please?