question

DAquiJoseph-6365 avatar image
0 Votes"
DAquiJoseph-6365 asked ·

EWS Impersonation for emails and conference room booking

I created an on-prem app that will book conference rooms by first querying the available rooms as a service account (AD) and then hen it comes time for booking the app will impersonate the user who is logged in and send an email to the conference room and people invited. Now that some users in my company have had their email account moved to O365, they can still see the rooms available as the account is on-prem and in O365, but when it comes time in the code to impersonate the user, when it is an O365 account, to send the email to the conference room or invited users, I get the following error:

[ServiceResponseException: The account does not have permission to impersonate the requested user.]
Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ProcessWebException(WebException webException) +1322
Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request) +138
Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(IEwsHttpWebRequest& request) +535
Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute() +42
Microsoft.Exchange.WebServices.Data.ExchangeService.InternalCreateItems(IEnumerable`1 items, FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode, ServiceErrorHandling errorHandling) +142
Microsoft.Exchange.WebServices.Data.Item.InternalCreate(FolderId parentFolderId, Nullable`1 messageDisposition, Nullable`1 sendInvitationsMode) +271
Microsoft.Exchange.WebServices.Data.Appointment.Save(FolderId destinationFolderId, SendInvitationsMode sendInvitationsMode) +91
booknow.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\RoomBook\booknow.aspx.cs:1006
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +11760440
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +150
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5028

And this is the code that causes it:

appointment.Save(new FolderId(WellKnownFolderName.Calendar, email_addr), SendInvitationsMode.SendToAllAndSaveCopy);

Any guidance would be appreciated.

azure-active-directoryoffice-exchange-server-administrationoffice-exchange-hybrid-itpro
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AndyDavid avatar image
0 Votes"
AndyDavid answered ·

Have you enabled Impersonation for the service account to the Office 365 mailboxes as well?
Your code will have to account for the mailboxes now in 365.

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

KyleXu-MSFT avatar image
0 Votes"
KyleXu-MSFT answered ·

The using of EWS is related with Exchange development which doesn't supported in Q&A so far. I would suggest you post this question in Exchange development forum or open a ticket to Microsoft. It will help you solve this question.

Here are my suggestion which may be useful to you:

The account does not have permission to impersonate the requested use

From this error message we can see that there was lacking of permission to impersonation. Since this mailbox is migrated to Exchange online, I would suggest you to try to given permission for this mailbox from Exchange online again.

I also suggest you try to give the impersonation permission to a Exchange online rather than migrated mailbox, then check whether your application could impersonation this mailbox. If it cannot impersonation for Exchange online mailbox, I think it may not be suitable for migrated mailboxes.


If the response is helpful, please click "Accept Answer" and upvote it.

· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I wouldnt bother posting anything in the Exchange Dev Forum. No one is there anymore.

0 Votes 0 ·