SQL Server 2008中用户登录失败'NT AUTHORITY \\ NETWORK SERVICE' [英] sql server 2008 Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

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

问题描述

我想我的网站与.NET框架连接到我的SQL Server 2008 R2的Windows Server 2003上4

I am trying to connect my website to my sql server 2008 r2 on windows server 2003 with .net framework 4

这是连接字符串:

<add name="TestDbConnectionString" 
     connectionString="Data Source=(local);Initial Catalog=RESv5;integrated security=SSPI;"
     providerName="System.Data.SqlClient" />

我有一个例外,那就是:

I got an exception, which is:

用户登录失败'NT AUTHORITY \\ NETWORK SERVICE'。结果
  说明:执行当前Web请求的执行过程中发生未处理的异常。请检查堆栈跟踪有关该错误的详细信息以及它起源于code。

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

异常详细信息:System.Data.SqlClient.SqlException:登录失败,用户NT AUTHORITY \\ NETWORK SERVICE

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.

源错误:

当前Web请求的执行过程中生成了未处理的异常。可以使用异常堆栈跟踪下面确定有关异常原因和位置信息。

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

我看到了这个问题,<一个href=\"http://stackoverflow.com/questions/2251839/login-failed-for-user-nt-authority-network-service\">Login失败,用户NT AUTHORITY \\ NETWORK SERVICE',我试图做一个名为 NT AUTHORITY \\ NETWORK SERVICE用户,但我仍然有问题,

I saw this question Login failed for user 'NT AUTHORITY\NETWORK SERVICE' and I tried to make a user named as NT AUTHORITY\NETWORK SERVICE but I still have the problem,

我已经尝试使用用户名和密码。这是连接字符串

I have already tried to use a username and password. this is the connection string

<add name="TestDbConnectionString" 
     connectionString="Data Source=(local);Initial Catalog=RESv5;integrated security=SSPI;User Id=sa;Password=myPassword;"
     providerName="System.Data.SqlClient" />

但仍然有问题。

推荐答案

您正在使用Windows身份验证进入服务器,因此它使用来自客户端的Windows帐户访问验证访问/权限。当发展的客户是真正的VS开发服务器,但是当你部署到一个真正的web服务器,客户运行作为另一个帐户,用于启动其服务的人,不是你的。

You're using Windows authentication to enter the server, so it uses the Windows account access from the client to validate access/permissions. When in development, the "client" is really the VS development server, but when you deploy to a real web server, the "client" runs as another account, the one that is used to start the its service, NOT yours.

通常SQL服务器是在安装配置让自己系统管理员访问,但几乎没有任何东西给其他用户,这就是为什么你会得到拒绝访问。
一种选择是使用SQL身份验证与用户/密码。安全性的角度来看,如果同一Web服务器上运行多个网站(因为他们可以从彼此的数据的隔离),这将是最好的选择。

Often SQL Servers are configured at installation to allow yourself sysadmin access, but barely anything else to other users, that's why you get an access denied. One option would be to use SQL authentication with user/password. Security-wise, this would be the best option if the same web server runs many websites (as they may be isolated from each other data's).

如果你绝对要使用Windows身份验证,真正的解决办法是在SSMS授予权限的内置帐户 NT AUTHORITY \\ NETWORK SERVICE

If you absolutely want to use Windows authentication, the real solution would be to give permissions to the built-in account NT AUTHORITY\NETWORK SERVICE at SSMS:

CREATE LOGIN [NT AUTHORITY\NETWORK SERVICE] FROM WINDOWS WITH DEFAULT_DATABASE=[RESv5]
GO
USE [RESv5]
GO
CREATE USER [NT AUTHORITY\NETWORK SERVICE] FOR LOGIN [NT AUTHORITY\NETWORK SERVICE]
GO
ALTER ROLE [db_owner] ADD MEMBER [NT AUTHORITY\NETWORK SERVICE]
GO

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

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