HttpContext.Current.User.Identity.Name is null
20,798
When I have:
<authentication mode="Windows"/>
<identity impersonate="true/>
in web.config I get the current user with:
string currUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
Author by
Nick
Updated on July 15, 2022Comments
-
Nick almost 2 years
I'm trying to use HttpContext.Current.User.Identity.Name to get the user's Windows login details from the internal network, however it's empty.
I've tried changing the authentication mode in Web.Config with no joy:
<system.web> <authentication mode="Windows" /> <compilation debug="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5" /> </system.web>
I've also heard that in the project properties you should enable Windows authentication and disable anonymous authentication like so:
But then I get a re-direct loop, with the message "This webpage has a redirect loop" in Chrome.
I've also checked that Windows Authentication is installed on my machine:
Any ideas on how to fix this please?
Many thanks
-
Nick almost 10 yearsThank you very much for the reply, however I get the following error: An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode. Most likely causes: system.web/identity@impersonate is set to true.
-
Nick almost 10 yearsFurther to the above, I got rid of the error: stackoverflow.com/questions/4209999/… However unfortunately the value
System.Security.Principal.WindowsIdentity.GetCurrent().Name
of is still null :(