locked
[UWP] How to set default credentials in Windows Authentication RRS feed

  • Question

  • I'm developing UWP application using C#.net and it has WCF service with Windows Authentication enabled. I struggling to pass default NetworkCredential after consume a service call using Add reference option.

    Please find below my examinations.

    When I pass correct windows authentication credentials, it is working as expected.

    var service = new ServiceReference.Service1Client();
    service.ClientCredentials.Windows.ClientCredential =new NetworkCredential("pradeep","****");
    var test = await service.GetDataAsync(1);

     but, I wanted pass default network credentials while using my service methis

    var service = new ServiceReference.Service1Client();
    service.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
    var test = await service.GetDataAsync(1);

    I also tried below option.

    service.ClientCredentials.Windows.ClientCredential = (NetworkCredential)CredentialCache.DefaultCredentials;


    When I pass default credentials. I'm getting below exception.

    The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate, NTLM'.

    I tested same service call with default NetworkCredential in WPF application which is working as expected.



    Monday, March 21, 2016 8:35 AM

Answers

All replies

  • Hi Pradeep1983,

    I’m trying to reproduce this issue, if I get any useful information, I would tell you in time.

    Best Regards,

    Xavier Eoro


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, March 22, 2016 9:24 AM
  • Hello,

    For this question, please check my reply in your another same thread:
    http://stackoverflow.com/questions/36126305/how-to-pass-default-credentials-in-windows-authentication/36197993#36197993  .

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, March 24, 2016 12:10 PM