Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the current application pool user in IIS when using impersonate=true?

In .net when a website hosted in IIS how do you get the current user the website is running under. ie the Application Pool user not the the current user accessing the site.

Using windows integrated and impersonate.

<authentication mode="Windows"/>
<identity impersonate="true"/>
like image 600
Simon Avatar asked Apr 30 '10 01:04

Simon


1 Answers

To revert to the app pool user in managed code you can do the following:

using (WindowsIdentity.Impersonate(IntPtr.Zero)) 
{
   //This code executes under app pool user
}
like image 131
John Simons Avatar answered Oct 24 '22 10:10

John Simons