1

I'm getting Error when running my website on host.

error: Cannot open database "Dog24" requested by the login. The login failed. Login failed for user 'NT AUTHORITY\NETWORK SERVICE

connection string :

<add name="Dog24ConnectionString" connectionString="Data Source=199.26.84.130\sqlexpress;Initial Catalog=Dog24;User Id=myusername;Password=mypassword;Integrated Security=True" providerName="System.Data.SqlClient"/>

I'm struggling to fix it for hours but I can't.

Thanks in advance

farhang67
  • 759
  • 2
  • 14
  • 27
  • Hi check this old question http://stackoverflow.com/questions/2583815/login-failed-for-user-nt-authority-network-service – Ryuzaki Nov 12 '13 at 13:59

2 Answers2

2

You either need to add a login for NETWORK SERVICE and grant it access to the database you want, or you need to use SQL authentication.

Mike Perrenoud
  • 66,820
  • 29
  • 157
  • 232
  • How could I use SQL authentication? I'm so beginner in asp.net – farhang67 Nov 12 '13 at 14:02
  • 1
    @farhang67: Set `Integrated Security=False`. In the connection string above you're already providing SQL authentication values with `User ID` and `Password`. Just don't use `Integrated Security`. – Mike Perrenoud Nov 12 '13 at 14:03
0

you need to add the NT Service users in the database security and grant them access to the database. This is what is used when you are calling from an ASP.NET application since this is the app pool creds its using by default so the user it is calling out on is NT Service.

take a look here:

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

Community
  • 1
  • 1
Ahmed ilyas
  • 5,722
  • 8
  • 44
  • 72