0

I've been fighting with this all day looking for solutions, and I've come to a dead end. As soon as I put my application on IIS, I've been getting login errors. One of the errors that I fixed was similar to this one which said " Cannot open database "ClientInfo" requested by the login.

Now I'm getting this error, which is the same, but I'm not sure how to modify the permissions of the NT AUTHORITY\NETWORK SERVICE user for this particular DB.

Cannot open database "aspnet-ClientInfo-20140609140222" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

The full error message is here: s11.postimg.org/3x1vj1ezl/Untitled.png

Andrew Morton
  • 24,203
  • 9
  • 60
  • 84
Prock
  • 410
  • 1
  • 5
  • 20

1 Answers1

2

don't worry too much. This is always a headache when it doesn't work the way you expect. Before I get started, please note that Network Service is probably too high of privilege level for any web app. Check out this article to see how to add a corresponding app pool for a specific website to your SQL Server logins: Add IIS 7 AppPool Identities as SQL Server Logons

This is the way I've solved these types of problems:

1.) Make sure you have access to SQL Server Management Studio Express, and log into the database server. If you are running on SQLEXPRESS, set the server name as .\SQLEXPRESS, or whatever your instance name is.

2.) Go to the Security folder at the server level. Right click on "Logins" and select "New Login". To the right of the Login Name text box, select "Search", then "Advanced", then "Find Now" (without entering any search criteria). Scroll down and select "Network Service"

3.) Hit Ok. Then hit OK again. Your new login has been added for your network service.

4.) Go to the Security folder at the database level. Add a new user by right clicking the User folder under security at the database level. Click the 3 dots (ellipsis) next to the login name, and then click "Browse". Select the checkbox next to the login name you created in step 2. Hit ok. Then hit OK again.

5.) The last part is giving your new user a user name (first text box at the top) and then mapping that user to the right privileges. I'm sure some folks that know more than I do will shoot me, but I always select db_datareader and db_datawriter under "Database Role Membership". If you're using the ASP_NET membership schemas, you should select all the basic access roles as well.

6.) Hit Ok.

Depending on the version of SQL server you're using, you may need see a mild fluctuation between my steps above and what you actually need to do. This should get you close, though.

Community
  • 1
  • 1
  • And remember that you may need to `GRANT EXECUTE ON [yourStoredProcedureName] TO [IIS APPPOOL\yourAppPoolIdentity]` for stored procedures which are to be called from the ASP.NET application, and `GRANT EXECUTE ON TYPE::[dbo].[yourTypeName] TO [IIS APPPOOL\yourAppPoolIdentity]` for user-defined types which are to be used by it. – Andrew Morton Jun 09 '14 at 21:13