Sql-server – Login failed for user ‘NT AUTHORITY\NETWORK SERVICE’

asp.netsql server

I tried to open the website from a broswer. The project is deployed at an IIS server.

I am getting this exception:

Exception information:

Exception type: SqlException

Exception message: Cannot open database "TestDB" requested by the login. The login failed.

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

Any solution?

Best Answer

Your IIS application runs under the NT AUTHORITY\NETWORK SERVICE account

You can use Windows Authentication and Impersonation http://msdn.microsoft.com/en-us/library/aa292118%28VS.71%29.aspx

Use Windows Authentication and a fixed account (either by adding the NT AUTHORITY\NETWORK SERVICE account to SQL Server or by creating a new account for that purpose and configuring the application pool in IIS to use that account)

Or you can use SQL authentication with user name and password in the (possibly encrypted) connection string in the web.config