Forum Discussion
"The account does not have permission to impersonate the requested user" error
SlavaGDid you ever find out why this happend or even resolved this? Currently we have the same problem for one customer using O365 Exchange, but we've got no clue why some users can be impersonated and some cannot. There are no management scopes set limiting the impersonated users on the impersonation role.
alex3683 We had exactly the same problem. The solution was to use the X-AnchorMailbox header. More information is here:
https://blogs.msdn.microsoft.com/webdav_101/2015/05/11/best-practices-ews-authentication-and-access-issues/
"When EWS Impersonation is used the X-AnchorMailbox always should be correctly set. Without doing so you may get 500 or 503 errors at times. It is critical for performance and also for notifications with Exchange Online/Exchange 2013. Not setting it can double or more the time it takes to complete the call. In some cases you can also get timeouts. The rule is to always set this header when using impersonation - this will make your EWS Impersonated code from Exchange 2007 work better with Exchange 2013."
- alex3683Jun 04, 2019Copper Contributor
stevereinhold SlavaG Thank you both for your help. In the end it was really the missing X-AnchorMailbox header that resolved the issue for us. A pity that this isn't set by default in the EWS API when using impersonation with an email address.
- alex3683Jun 03, 2019Copper Contributor
stevereinhold @SlavaG Thanks for your replies. I'll try your solutions and let you (and further visitors) know if that worked out.