Click here to Skip to main content
16,004,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working with visual studio 2010, ms SQLserver 2012, IIS 7.5,I have deployed my application in IIS and when I am trying to connect to the database the following error appear every time I try to open the connection with the server:
Cannot open database "Db" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

Please assist
Thanks in advance

What I have tried:

SQL SERVER - FIX : ERROR : Cannot open database requested by the login. The login failed. Login failed for user 'NT AUTHORITYNETWORK SERVICE'. - Journey to SQL Authority with Pinal Dave[^]
Posted
Updated 2-Mar-16 4:34am
v2
Comments
CHill60 2-Mar-16 10:29am    
Did you really do everything on that blog? It's not often that guy is wrong and he claims that fix "always works"
David Belmont 2-Mar-16 10:31am    
Could you add the connection string to the question? It would help to understand what is the source of the problem.

1 solution

This means that your code is running as the account NT AUTHORITY\NETWORK SERVICE. This is because in IIS your application pool's identity is set to NT AUTHORITY\NETWORK SERVICE and your web.config is using a trusted connection.

I recommend creating a sql account and then changing your connection string to use that account. Or, you can do as the blog post suggest and grant NT AUTHORITY\NETWORK SERVICE the proper security rights.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900