IIS impersonation returns app pool user Service account

Viewed 3722

I have developed one MVC application and hosted in server. I used Service Account as app pool identity and provided full access(SysAdmin) on database to that Service Account only. Below are my configurations in Web.config & coding.

Web.config:

<authentication mode="Windows" />
 <identity impersonate="false"/>

In my Data Access layer I'm using below coding to get windows identity :

 string windowsLogin = HttpContext.Current.User.Identity.Name.ToString();

Now my issue is, when I'm accessing my application it is taking app pool Identity instead of Windows identity.

if I set the identity in Web.config to impersonate="true" I'm able to get windows login but the communication between application and database happening with my windows login instead of app pool identity (service account).

How can I get the identity of the user accessing the application and not the IIS APPPOOL user?

1 Answers
Related