How do I set up .NET WindowsAuthentication - the name always shows up as “IIS APPPOOL\Classic .NET AppPool” when I want it to use the actual user

后端 未结 2 983
有刺的猬
有刺的猬 2021-01-06 01:55

I\'m using the following code to authenticate via Kerberos.

IntPtr logonToken = WindowsIdentity.GetCurrent().Token;
string authenticationType = \"WindowsAut         


        
相关标签:
2条回答
  • 2021-01-06 02:33

    Your problem is, your IIS server runs under its own identity, not yours. Therefore, WindowsIdentity.GetCurrent().Token returns IIS work process' identity.

    You can configure your website to run under different identity (including yours) using IIS Manager console: enter image description here

    0 讨论(0)
  • 2021-01-06 02:40

    You need to enable impersonation in web.config:

    To configure ASP.NET to impersonate the Windows identity supplied by IIS as the WindowsIdentity for the ASP.NET application, edit the Web.config file for the application and set the impersonate attribute of the identity configuration element to true, as shown in the following example.

    <configuration>
      <system.web>
        <identity impersonate="true" />
      </system.web>
    </configuration>
    

    When you run the code locally for debugging you're probably using the web dev server that runs as your logged-in user, which is why you'll see the correct user in debug.

    0 讨论(0)
提交回复
热议问题