登录失败。登录失败,用户NT AUTHORITY \ SYSTEM“ [英] Login failed. Login failed for user 'NT AUTHORITY\SYSTEM'

查看:3336
本文介绍了登录失败。登录失败,用户NT AUTHORITY \ SYSTEM“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个窗口服务与;我的服务依赖于SQL Server服务。首先,SQL启动,然后启动电脑或重新启动电脑时,我的服务启动。

这工作正常,但问题是数据库文件不能被Windows服务读,抛出异常无法打开用户默认数据库。登录failed.Login失败,用户NT AUTHORITY \ SYSTEM当我试图读取数据库。

如果我启动计算机与;登录就不能读取数据库,但如果我有启动计算机与;等待几秒钟,然后登录到它读取数据库中的窗口服务。

解决方案

我敢打赌,你有这样的连接字符串:

 集成安全性= SSPI
 

或类似的东西。

现在该服务是根据( NT AUTHORITY \ SYSTEM )试图连接到数据库运行的帐户 - 并不能因为它无权这样做<。 / P>

您可以:

  • 无论是在您的SQL Server创建一个登录名 NT AUTHORITY \ SYSTEM ,并给它需要必要的权限,您的应用程序

  • 您在SQLServer,创建一个特定的应用程序的用户帐户(登录到SQL Server和用户数据库),并改变你的连接字符串:

     用户ID =(你的应用程序的帐户); PWD =你的密码
     

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.

解决方案

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
    

这篇关于登录失败。登录失败,用户NT AUTHORITY \ SYSTEM“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆