Login failed for user ‘IIS APPPOOLmyAppPool

I having the following error message:

Cannot open database “SmallBakery” requested by the login. The login failed. Login failed for user ‘IIS APPPOOLMyAppPool’

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

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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 APPPOOLMyAppPool 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.

Method 2

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.

Method 3

Check this post out. Your problem sounds similar to one I was running into, with the same exact error message.

http://blogs.msdn.com/b/sqlexpress/archive/2011/12/09/using-localdb-with-full-iis-part-2-instance-ownership.aspx

Method 4

Like others said so far you need to take your app pool system user (IIS AppPoolmyapppool) and add it as database user for that database with appropriate permissions.

Note that this will work just find on your IIS/Server but if you plan on migrating application to a different IIS/Sql server it will require changes in both SQL Server and IIS. I’d suggest you also consider sql server authentication – it may be more convenient for your specific case.

Method 5

In my case these steps lead me to successfully handle this error.Hope it will help you also

enter image description here


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x