The account does not have permission to impersonate the requested user

user2123527 picture user2123527 · Mar 4, 2013 · Viewed 13k times · Source

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);
        }

Answer

Jakob Christensen picture Jakob Christensen · Mar 5, 2013

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