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'
Reason
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.
Solution
We can solve this problem in several ways....
First solution that resolved my problem was:
Second solution
If 'NT AUTHORITY\NETWORK SERVICE' user is already added on Users lists then we can move with this second workaround.
System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'
Reason
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.
Solution
We can solve this problem in several ways....
First solution that resolved my problem was:
- Login to SQL server database via SQL Server Management Studio
- Go to the "Security" directory of desired database
- Right-click the Users directory
- Select "New User..."
- Add 'NT AUTHORITY\NETWORK SERVICE' as a new user
- In the Data Role Membership area, select db_owner
- Click OK
Second solution
If 'NT AUTHORITY\NETWORK SERVICE' user is already added on Users lists then we can move with this second workaround.
- Login to SQL server database via SQL Server Management Studio
- Go to "Security" directory
- Select "Logins" directory under "Security" directory
- Right click on NT AUTHORITY\NETWORK SERVICE and select Properties
- New popup window appear, select "User Mapping" tab
- Under "User Mapping" tab select the desired database
- In the Database Role Membership for area, select db_owner role
- Click OK
For more information about sql server 2008 installation please visits.
1 comment:
Thank you so much I had the same problem and your solution worked perfectly. Thanks!
Hire .NET Developer
Post a Comment