-->

The account does not have permission to impersonat

2019-02-19 14:44发布

问题:

I am getting this error while try to accessin the resource mailbox. pls any one help me on this . I am new to EWS.

I am able to access the resource mailbox through OWA(Outlook web app). But i am not owner of this mailbox as it is shared mailbox.

my code:

ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;
ExchangeService newExchangeService = new ExchangeService  (ExchangeVersion.Exchange2007_SP1);
newExchangeService.Credentials = new NetworkCredential(username, password, domain);
newExchangeService.AutodiscoverUrl(email-id, RedirectionUrlValidationCallback);

newExchangeService.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, email_which_i_want_to_access);

Folder visitorsFolder = Folder.Bind(newExchangeService, WellKnownFolderName.Inbox);
foreach (Folder childfolder in visitorsFolder.FindFolders(new FolderView(10)))
        {
            Console.WriteLine(childfolder.DisplayName);
        }

回答1:

The problem could be that you do not have permissions to impersonate the mailbox but you may have delegate access. Please see my answer to this similar question on how to access a mailbox when you have delegate access: https://stackoverflow.com/a/9242792/64161