I'm creating an intranet asp.net mvc application that everyone in the company should have access to. I need to run the website impersonated for database access etc., but I want to know who each user is.
When I look at Page.User.Identity.Name
it's blank. Is it possible to get the user's windows account name even though the site is running impersonated?
Edit:
Here's a little more info. I have a site in IIS 6 running with anonymous access enabled. The site is running under a system account that has access to the database (because all of the employees do not have access to the database).
My web.config has <authentication mode="Windows" />
and <identity impersonate="true"/>
My goal is that the users won't have to log in – that fact that they are logged into our network (and the fact that the site is not on an external IP) is enough authentication. I would just like to know who the user is in order to track changes they make, etc.
Best Answer
With
<authentication mode="Windows"/>
in your application and Anonymous access enabled in IIS, you will see the following results:With
<authentication mode="Windows"/>
in your application, and ‘Anonymous access’ disabled and only ‘Integrated Windows Authentication’ in IIS, you will see the following results:With
<authentication mode="Windows"/>
and<identity impersonate ="true"/>
in your application, and ‘Anonymous access’ disabled and only ‘Integrated Windows Authentication’ in IIS, you will see the following results: