Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Exchange Web Server Authentication Problem - Share Point 2013 Web Part

$
0
0

Dears,

Please find the code snippet as below which i used to connect to exchange server to read emails.

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);

ServicePointManager.ServerCertificateValidationCallback = Cert.CertificateValidationCallBack;

service.Credentials = new NetworkCredential("user", "password", "domain");

service.Url = new Uri(serverUrl);

I was trying to connect to the same service based on the currently logged in User via SharePoint webpart.

In MSDN (http://msdn.microsoft.com/en-us/library/exchange/ff597939%28v=exchg.80%29.aspx)

It was mentioned like below.

// Connect by using the default credentials of the authenticated user.

service.UseDefaultCredentials = true;

Eventhough i used the above code entry i was unable to connect to the web service hence was getting the below error :

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

how can solve the above mentioned problem?

thanks in advance,

Ammar


Viewing all articles
Browse latest Browse all 7589

Trending Articles



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