none
EWS Authentication problem RRS feed

  • Question

  • 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


    • Edited by AmmarBIZ Wednesday, July 10, 2013 11:32 AM
    Wednesday, July 10, 2013 11:26 AM

Answers