Quantcast
Viewing all articles
Browse latest Browse all 7132

EWS Managed API - The request failed. The remote server returned an error: (401) Unauthorized for one logon id

Hi all,

I recently try to use EWS Managed API to access exchange email account from two LAN ID

My scenario is that the two LAN IDs (let's say ID_A, ID_B) can access the email inbox, I proved

this by using outlook accessing the email account (It prompts me to enter LAN ID and Password)

Then I use the following codes to see if I can use EWS Managed API with windows authentication to access the email inbox

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.TraceEnabled = false;
Console.Out.WriteLine("Try using windows authentication!");
service.Credentials = new WebCredentials(CredentialCache.DefaultNetworkCredentials);
service.Url = new Uri("https://xxxhost/ews/exchange.asmx");
Console.Out.WriteLine("Connected to Exchange!");
FindItemsResults<Item> findResults = service.FindItems(new FolderId(WellKnownFolderName.Inbox, new Mailbox("HK.XX@xxxhost.com")), new ItemView(100));

With ID_A logon, the C# program can access the email inbox with windows authentication and print out the email subjects

But Wth ID_B logon, the C# program returns the following error:

Exception : The request failed. The remote server returned an error: (401) Unauthorized.

I really don't get it from one account can work but another is failed to work.

Both accounts should have access read right to the email account.

Would some experts here help me on this issue?

Thanks for your kind attention,

RayLee


Viewing all articles
Browse latest Browse all 7132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>