Asp.net-core – Asp.net Core Web API – Current user & Windows Authentication

asp.net-coreiiswindows-authentication

We have following technical stack in our application
AngularJS2
Asp.Net Core API
SQL Server

Now we need to store User Name for the Logged in User in table during Create/Edit for given item i.e. in Core API.

We have tried with

  • WindowsIdentity.GetCurrent().Name, it gives IIS APPPOOL\Asp.netCore
  • HttpContext.User.Identity gives null value

I get User Name with WindowsIdentity while working with Visual Studio, but with IIS, it gives value as Asp.Netcore i.e. pool name

Windows Authentication is enabled and Anonymous Authentication is disabled

Using IIS Version 6.1

Am I missing anything?

Best Answer

Do you have the forwardWindowsAuthToken set to true in the web.config?

<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="true"/>