Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Login failed for user 'IIS APPPOOL\myAppPool

I having the following error message:

Cannot open database "SmallBakery" requested by the login. The login failed. Login failed for user 'IIS APPPOOL\MyAppPool'

How can correct this? I am using windows 7 Enterprise Edition and Sql server 2012.

like image 208
Freddy Avatar asked May 07 '13 19:05

Freddy


2 Answers

If you don't change, each app pool has it's own identity. In your case, just add a new user to your database SmallBakery with the name IIS APPPOOL\MyAppPool using SQL Management Studio. You find the users list in the "Security/Users" subnode of your database. This should look something like that:

enter image description here

For testing, let the user be member of the db_owner role. If that works, remove this role and just let it be member of db_datareader and db_datawriter.

This way, each app pool (perhaps each website, if they all use their own app pool) only has access to the corresponding database.

like image 108
Linus Caldwell Avatar answered Nov 02 '22 11:11

Linus Caldwell


It depends on how you want to authenticate in your app. Are you trying to use impersonation in your app?

What's happening right now is the identity of your app pool in IIS is getting passed when trying to access the database. You can change the identity of your app pool to be something that has access to the database or you could change your connection string to use a specific login instead of integrated security.

like image 45
squillman Avatar answered Nov 02 '22 09:11

squillman