0
votes

We have an existing implementation that subscribes via EWS Managed API push notifications for a user's calendar in Office 365 Exchange Online.

PushSubscription pushSubscription = exchangeService.SubscribeToPushNotifications(
    new FolderId[] { WellKnownFolderName.Calendar },
    new Uri(callbackEndpoint), statusFrequency, null,
    EventType.Created, EventType.Deleted, EventType.Modified,
    EventType.Moved, EventType.Copied, EventType.FreeBusyChanged);

Other than the subscription not being able to last forever, it is otherwise fine; appointments scheduled on the calendar do send notifications to our web service.

Now instead of monitoring events from a user's mailbox perspective, we are wondering if it is possible to subscribe from the room resource mailbox perspective.

// Set room mailbox address.
exchangeService.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, roomAddress);

PushSubscription pushSubscription = exchangeService.SubscribeToPushNotifications(
    new FolderId[] { WellKnownFolderName.Calendar },
    new Uri(callbackEndpoint), statusFrequency, null,
    EventType.Created, EventType.Deleted, EventType.Modified,
    EventType.Moved, EventType.Copied, EventType.FreeBusyChanged);

Unfortunately it does not turn out to be so simple,

The request failed. The remote server returned an error: (457) https://autodiscover-s.outlook.com/owa/domain.onmicrosoft.com.

I cannot find any in-depth material explaining what error 457 truly is, and how to overcome this problem.

Additionally, I have not found anybody else attempting subscriptions to resource mailboxes. Is it because it is outright impossible, or simply nobody ever found a need to?

UPDATE

Tried using the EWSEditor tool to see what kinds of extra detail can be sniffed out; seems like impersonating a room mailbox requires some sort of special permission.

Exception details: Message: The account does not have permission to impersonate the requested user. Type: Microsoft.Exchange.WebServices.Data.ServiceResponseException Source: Microsoft.Exchange.WebServices ErrorCode: ErrorImpersonateUserDenied ErrorMessage: The account does not have permission to impersonate the requested user. Stack Trace: at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ProcessWebException(WebException webException) at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request) at Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(IEwsHttpWebRequest& request) at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest 1.Execute() at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalConvertIds(IEnumerable 1 ids, IdFormat destinationFormat, ServiceErrorHandling errorHandling)
at Microsoft.Exchange.WebServices.Data.ExchangeService.ConvertIds(IEnumerable 1 ids, IdFormat destinationFormat) at EWSEditor.Common.Extensions.ExchangeServiceExtensions.TestExchangeService(ExchangeService service)

I tried assigning Full access for mailbox delegation in the Office 365 admin interface, but that did not appear to do any favours.

1

1 Answers

0
votes

Looks like the key to making this happen is enabling impersonation for a nominated service account.

http://blogs.msdn.com/b/pareshj/archive/2011/11/29/exchange-web-services-fail-using-impersonation-to-access-mailboxes.aspx

http://msdn.microsoft.com/en-us/library/bb204095.aspx

Once this is done for the organisation account and the nominated user account, interacting with EWS with the impersonated room mailbox, and subscribing, becomes possible.