Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Login failed. Login failed for user 'NT AUTHORITY\SYSTEM'

I have created a windows service & my service is dependent on the SQL server service. First, SQL started and then my service started when starting PC or restarting PC.

This works fine but the issue is database file can not be read by the Windows service, throwing the exception "Cannot open user default database. Login failed.Login failed for user 'NT AUTHORITY\SYSTEM' " when i am trying to read the database.

If I start the computer & login then it can not read the database, but if i have start the computer & wait for a few seconds and then log into the window service it reads the database.

like image 268
user847455 Avatar asked Aug 01 '11 05:08

user847455


People also ask

What is user NT Authority system?

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.

What is the password for NT Authority system?

A predefined local account that is used to start a service and provide the security context for that service. The name of the account is NT AUTHORITY\System. This account does not have a password, and any password information that you supply is ignored.

What is user NT Authority anonymous logon?

When the OS can't validate who you are, you are NT AUTHORITY\ANONYMOUS LOGON. You typically see this in double hop situations like when you have a client connecting to SSRS and SSRS isn't on the same server as the SQL Server where the DB is located.


1 Answers

I bet you have this in your connection string:

Integrated Security=SSPI

or something similar.

Now the account that service is running under (NT AUTHORITY\SYSTEM) tries to connect to the database - and can't since it's not authorized to do so.

You can:

  • either create a login for NT AUTHORITY\SYSTEM in your SQL Server and give it the necessary permissions it needs for your app

OR:

  • you create a specific application user account in SQL Server (login to SQL Server and user in your database) and change your connection string to:

    User ID=(your app account);pwd=YourPassword
    
like image 153
marc_s Avatar answered Sep 18 '22 15:09

marc_s