Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

I'm trying to publish an asp.net website on a remote server. When my code tries to connect to the database, I get the error message described in the question title. Now, I've gone into the Microsoft SQL Server Management Studio for SSE 2008 and can see the list of logins. NT AUTHORITY\NETWORK SERVICE is there, but I'm not sure what settings I need to change to allow this user to access the database. I've tried using impersonation in my web.config file using the windows login credentials for the server, but that just brings up the same error message, with my windows username instead of NETWORK SERVICE.

My connection string is as follows:

connectionString="Data Source=MECHTRONICRND\SQLEXPRESS;Initial Catalog='C:\Inetpub\aspnettest\App_Data\FLEETMANAGERDB.MDF';Integrated Security=True"

Any ideas?

Thanks

--Amr

like image 486
Amr Bekhit Avatar asked Mar 11 '10 01:03

Amr Bekhit


People also ask

What is NT Authority Network service?

NT AUTHORITY\NetworkService ( S-1-5-20 ; also displayed as simply "NETWORK SERVICE") "is a predefined local account used by the service control manager.. has minimum privileges on the local computer and acts as the computer on the network."

How do I add NT Authority to my network?

go to the Services page and select your service. in the Service Properties page set the "User Name" field to NT AUTHORITY\NetworkService and leave the "Password" field empty. check Set "Log on as a service" policy for selected username option.

What is NT Authority system account?

The account NT AUTHORITY\System which is a Local System account.. It is a powerful account that has unrestricted access to all local system resources. It is a member of the Windows Administrators group on the local computer, and is therefore a member of the SQL Server sysadmin fixed server role.


2 Answers

Thanks for your replies. After looking at this tutorial, I found out how to allow users access to a database. Once I had allowed NETWORK SERVICE read and write access to the database, my website worked fine with the original connection string.

--Amr

like image 196
Amr Bekhit Avatar answered Oct 18 '22 03:10

Amr Bekhit


Your connection string should be:

"Data Source=MECHTRONICRND\SQLEXPRESS;Initial Catalog=FLEETMANAGERDB;Integrated Security=True"

Also, this is trying to connect to the database as the account that's used by the web server. You could run the web service (configure IIS accordingly) as a domain user, and then create a login and database user for that account. Otherwise, you will have to create a database user (in FleetManagerDB) for the Network Service account, which isn't recommended. Or yourself if you are impersonating yourself.

like image 1
Rob Farley Avatar answered Oct 18 '22 02:10

Rob Farley