none
Net core RunImpersonated not working in Windows 10 RRS feed

  • Question

  • From my net core web api, I am calling another web api. I have to use current user for authentication so I am using WindowsIdentity.RunImpersonated for impersonating the user.

    below code runs perfectly fine in Win 7

    WindowsIdentity.RunImpersonated<Task<T>>(this.UserIdentity.AccessToken, func);

    func is an anonymous function which basically do HttpClient.GetAsync(url);

    When I run the same code in Windows10, 

    I am getting below socket exception 

    SocketException: This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server 

    HttpRequestException: This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server 

    Windows 10 is unable to resolve my "localhost". If I remove WindowsIdentity.RunImpersonated and directly runs HttpClient.GetAsync(url); then locahost is resovled correctly and call is going to another api where it eventually fails as it does not have proper user.

    Tuesday, January 22, 2019 10:13 AM

All replies

  • Hi crazymind8289,

    Thank you for posting here.

    For your question, is there any different between Windows 7 and Windows 10?

    Do you use the same version of .net framework and same permission? Please try the high permission on Windows 10 to test again. If it is possible, could you provide the code which could reproduce the error for us to test on Windows 7 and Windows 10?

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, January 23, 2019 6:56 AM