title: Impersonation not working - Asp.Net core 3.1 application with Windows Authentication hosting in IIS
body: <p>I created a Blazor Server application (.Net core 3.1). The application uses Windows authentication. The application will need to access some Windows services like file sharing, and database with Integrated security etc. So it has the following impersonation code.</p>
  
  <pre><code>var identity = await IdentityProvider.GetIdentityAsync();
  
  if (identity.IsAuthenticated &amp;&amp; identity is WindowsIdentity wid)
  {
      return WindowsIdentity.RunImpersonated(wid.AccessToken, () =&gt;
      {
          Fun1(....); // Should be called using the authentication of logged in user
      });
  </code></pre>
  
  <p>The <code>Fun1()</code> should be called using the identity of the Windows users who are using the application, instead of the account which is used to running the website. </p>
  
  <p>For example, the Identity of the application pool for my web site is <code>MyDomain\UserX</code>. And when a user <code>MyDomain\UserY</code> is using the website. I want the function <code>Fun1()</code> is impersonated under <code>MyDomain\UserY</code> instead of <code>MyDomain\UserX</code>.</p>
  
  <p>I created a website on IIS, published the code, disabled anonymous authentication and enabled Windows Authentication. However, the function <code>Fun1()</code> is still called using the identity in the Application Pool? Should any settings in the Active directory be changed?</p>