Adding a user to SQL Server 2008 - denied access

I recently had some problems that, it seems to me, can help in debugging my ASP.NET MVC application in IIS instead of using ASP.NET Development as the default Server. However, when I try to do this, the application cannot access the database server (MS SQL Server 2008 Express) - it works fine on the development server.

The error I get is

Cannot open database 'myDbName' requested by the login. The login failed. Login failed for user 'NT INSTANCE/NETWORK SERVICE'.

I assume that it worked before, because the development server accessed the database through my user account, and not through a network service such as IIS .

I tried to add the NETWORK SERVICE user to the database, but it turned out that I do not have user rights for this - it does not matter that my Windows account with which I log in to the server is admin, or that I run the program in the administrator context. I just can't add another user to the database.

How to solve this problem?

+4
source share
3 answers

You can change the user with whom IIS works: this is the parameter in the properties of the ApplicationPool that your website runs on.

We do this all the time, as it gives us better control over user access - that the NT INSTANCE / NETWORK SERVICE account is too small for me ...

+3
source

NETWORK SERVICE is a special account. If your database server is located on another computer from your IIS server, you need to add an account:

\ $ as the user for the database. Therefore, if you are on an IIS server called LISA on the SPRINGFIELD network, you must provide access to the SPRINGFIELD \ LISA $ database. Pay attention to the dollar sign, which designates your user as a machine account, not the actual person.

If your database server and your IIS server are the same, provide access to the NT AUTHORITY \ NETWORK SERVICE account. This is all the account name. And that should work.

+1
source

Do you work on a non-English operating system?

For some reason, the NT / Network Service account name is localized in other languages.
Unfortunately, many programs have an account name that is hardcoded in English, and will not find the Network Service when working on other versions of Windows.

0
source

All Articles