I am working in C# and ASP.NET making a webbased database application with integrated security such that the Windows user is used in access to the database. When I run the application in IIS Express from Visual Studio, everything is fine. When I publish the webpage under IIS, I get problem with the Windows Authentication.
In IIS Express, the following two code lines produce the same Windows username corresponding to the currently logged in user, which is also what I want:
string user = Page.User.Identity.Name;
string loginName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
but in the published form in IIS, the second line gives a different user: IIS APPPOOL\"the-name-of-my-Visual-Studio-solution". This user has no rights to the databases, and the application breaks down.
I have enabled Windows authentication in web.config:
<authentication mode="Windows" />
<identity impersonate ="false" />
<authorization>
<deny users="?" />
</authorization>
In IIS, the following settings are used (see pictures below):
And this is the application pools settings:
IIS Application pools settings
Where to look for the problem?