I'm trying to migrate a website from SQL Server 2008 Express to SQL Server Web, and the website is having trouble accessing the database. In truth, Express was only ever used by running the website from Visual Studio's builtin web server, so I'm not sure about the configuration working all that well under full-blown IIS 7. At any rate, when I try to access a page that uses Linq to Entities (requiring the website to connect to the database), I get the error "Login failed for 'IIS AppPool\ASP.NET v4.0'". So, I opened SQL Server Management Studio, and I attempted to add a login for the user, but I just get a message stating "Windows NT or user group '*****\Asp.Net v4.0' not found". This happens even after I ask Management Studio to check the name of the user, which it does successfully. Can someone tell me what I'm doing wrong? Also, I'm open to alternative suggestions as well… Everything's running on the same server, so there are no remote connections. For this reason, I'd love to use Windows Authentication if at all possible.
Sql-server – Login failed for “IIS AppPool\ASP.NET v4.0” – SQL Server Web
asp.netloginsql server
Related Topic
- Sql-server – SQL Server 2000 + ASP.NET: Login failed for user ‘NT AUTHORITY\ANONYMOUS LOGON’
- Sql-server – Set a login with username/password for SQL Server 2008 Express
- How to configure MS SQL Server 2008 R2 (login failed for user)
- Sql-server – How to view the SQL Server database created by an ASP.NET MVC web application
Best Answer
IIS 7 is trying to use the IIS application pool identity to access your SQL database.
So you must first grant the IIS 7 apppool access to SQL server.
To do that, go in SQL Server Management Studio -> Server Instance -> Security -> Logins -> New Login
Login name will be "IIS APPPOOL\ASP.NET v4.0". This is because everytime you create an application pool in IIS7, it will create an identity which uses the same name as your app pool. In your case, you are using the default app pool which comes with asp.net 4.
Then on your database, go to Security -> Logins -> New login , give it a alias name, then select your user object you added in your previous step (IIS APPPOOL\ASP.NET v4.0) then give it db_owner (or whatever your needs are) schemas/role privileges.