Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

Very recently I got a mail from a junior guy he faced a problem every time when he installed the SQL server database on his workstation. But he failed to understand what is the main reason behind this. The problem was that after installing SQL server database his working web sites were throws exception like this...

System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

The main reason behind this error occurs when you configured your web site with IIS. When any one tries to browse the site, IIS send the request to the SQL server with credentials. But unfortunately the credential do not have proper permission. So that it throws exception.

We can solve this problem in several ways....
First solution that resolved my problem was:

  1. Login to SQL server database via SQL Server Management Studio
  2. Go to the "Security" directory of desired database
  3. Right-click the Users directory
  4. Select "New User..."
  5. Add 'NT AUTHORITY\NETWORK SERVICE' as a new user
  6. In the Data Role Membership area, select db_owner
  7. Click OK

Second solution
If 'NT AUTHORITY\NETWORK SERVICE' user is already added on Users lists then we can move with this second workaround.

  1. Login to SQL server database via SQL Server Management Studio
  2. Go to "Security" directory 
  3. Select "Logins" directory under "Security" directory 
  4. Right click on NT AUTHORITY\NETWORK SERVICE and select Properties
  5. New popup window appear, select "User Mapping" tab
  6. Under  "User Mapping" tab select the desired database
  7. In the Database Role Membership for area, select db_owner role
  8. Click OK

For more information about sql server 2008 installation  please visits.


Thank you so much I had the same problem and your solution worked perfectly. Thanks!
Hire .NET Developer

Popular posts from this blog

How can I get a value of a property from an anonymous type (C#)

The model backing the 'MyDBContext' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data.

"This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet."