I've got a new server build running Windows Server 2012 R2, IIS 8.5 (inc. ClassicASP feature) and SQL Server 2014 Express. I want to use Application Pool Identity to connect to the database. The database is set to "Windows Authentication Mode".
My Application Pool Identity is called activbase.net
. I've set up a Security Login in SQL Server called IIS AppPool\activbase.net
and user mapped it my database with db_datareader
and db_datawriter
access.
However when I try to access the database from the website, I get:
Cannot open database "ActivbaseLive" requested by the login. The login failed.
I thought this was enough to get the connection working. The Application Log (Event Viewer) shows:
Login failed for user 'NT AUTHORITY\IUSR'. Reason: Failed to open the explicitly specified database 'ActivbaseLive'. [CLIENT: ]
So I have added NT AUTHORITY\IUSR
likewise to the SQL Server>Security>Logins and Databases>[ActivbaseLive]>Security>Users and this fixes the problem.
My questions are as follows:
NT AUTHORITY\IUSR
login/user in addition to IIS AppPool\activbase.net
login/user to my SQL Server Instance and database?Thanks, Chris
NT AUTHORITY\IUSR is a built-in Windows account that is the default identity used when Anonymous Authentication is enabled for your application.
Click the Locations button and make sure that you select your computer. Enter IIS AppPool\<myappoolname> (eg: IIS AppPool\PK Protect) in the Enter the object names to select: text box. Click the Check Names button and click OK. Check Modify under the Allow column, and click OK, and OK.
Inside SQL Server Management Studio, locate the Security -> Logins node, using the right-click menu and selecting the "New Login" option. Using the new user dialogue add the user you used for your Application Pools, in our example, we used IIS_AdiminUI.
No. You don't need to add an SQL Server login for the NT AUTHORITY\IUSR
identity in addition to the IIS AppPool\activbase.net
identity. A login for the IIS AppPool\activbase.net
application pool identity alone is adequate for connecting to SQL Server using Windows Authentication.
NT AUTHORITY\IUSR
is a built-in Windows account that is the default identity used when Anonymous Authentication is enabled for your application. This page describes the rationale for the account.
To connect to your database with the IIS AppPool\activbase.net
identity, you need to change the account set up for anonymous users from NT AUTHORITY\IUSR
to your IIS AppPool\activbase.net
application pool identity. Proceed as follows to make this change:
The question in the link below (and its answer) addresses the same issue:
Login failed for user NT AUTHORITY\IUSR
With regard to your second question, "Is there a security issue with doing this?", the answer is, "Yes". You preferably don't want the NT AUTHORITY\IUSR
built-in account having access to your SQL Server database since it is used as the default anonymous account on any other websites (and their applications) hosted on your IIS web server. This means those other websites and applications would be able to connect to your database. If they are compromised in an attack, they could potentially be used to access your data. So it's best not to have an SQL Server login for NT AUTHORITY\IUSR
. Instead, limit database access to your website's (or application's) application pool identity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With