Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

Access Exchange Service From SharePoint 2013 Custom Web part getting The request failed with HTTP status 401: Unauthorized.

$
0
0

I want to Fill a drop down with Outlook Meeting of Current log-in user in SharePoint 2013 web part for default credentials I am using the following code

                                                                

 ExchangeServiceBinding binding = new ExchangeServiceBinding();

            ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true;

            binding.RequestServerVersionValue = new RequestServerVersion();
            binding.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2010_SP2;

            binding.PreAuthenticate = true;
            binding.UseDefaultCredentials = true;
            binding.Credentials = CredentialCache.DefaultCredentials ; 
            string server = "https://*********/ews/Exchange.asmx";

            binding.Url = server;

I Am Getting the Error "The request failed with HTTP status 401: Unauthorized."

but when I Replace  the line  

binding.Credentials = CredentialCache.DefaultCredentials ; 

with 

 binding.Credentials = new NetworkCredential(userName, password, domain);

Its run fine.  Is there any way I could able to use default credential.

  

Viewing all articles
Browse latest Browse all 7132

Trending Articles



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