使用 Windows 身份验证从非域计算机访问 SQL Server 2005 [英] Access to SQL Server 2005 from a non-domain machine using Windows authentication

查看:25
本文介绍了使用 Windows 身份验证从非域计算机访问 SQL Server 2005的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Windows 域,其中一台机器运行 SQL Server 2005,并且配置为仅支持 Windows 身份验证.我想在同一网络上但不在域上的机器上运行 C# 客户端应用程序,并访问 SQL Server 2005 实例上的数据库.

I have a Windows domain within which a machine is running SQL Server 2005 and which is configured to support only Windows authentication. I would like to run a C# client application on a machine on the same network, but which is NOT on the domain, and access a database on the SQL Server 2005 instance.

我认为做这样的事情很简单:

I thought that it would be a simple matter of doing something like this:

string connectionString = "Data Source=server;Initial Catalog=database;User Id=domainuser;Password=password";
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();

然而,这失败了:客户端错误是:

However, this fails: the client-side error is:

System.Data.SqlClient.SqlException: 用户域用户"登录失败并且服务器端错误是:错误 18456,严重性 14,状态 5

System.Data.SqlClient.SqlException: Login failed for user 'domainuser' and the server-side error is: Error 18456, Severity 14, State 5

我尝试了各种方法,包括将集成安全设置为 true 和 false,以及在用户 ID 中使用 而不是 ,但都没有成功.

I have tried various things including setting integrated security to true and false, and instead of in the User Id, but without success.

一般来说,我知道可以从非域机器连接到 SQL Server 2005 实例(例如,我正在使用一个基于 Linux 的应用程序,它很乐意这样做),但我似乎没有能够弄清楚如何在 Windows 机器上执行此操作.

In general, I know that it possible to connect to the SQL Server 2005 instance from a non-domain machine (for example, I am working with a Linux-based application which happily does this), but I don't seem to be able to work out how to do it from a Windows machine.

推荐答案

使用 Management Studio 当通过 Windows 身份验证连接到另一个域上的服务器时,您需要在启动应用程序时使用runas"工具.

With Management Studio when connecting to a server on another domain via Windows Authentication you need to use the "runas" Facility when starting the application.

 runas /user:OTHERDOMAINOTHERUSERNAME  /netonly 
"C:Program FilesMicrosoft SQL Server100ToolsBinnVSShellCommon7IDESsms.exe"

也许您可以在启动应用程序时尝试类似的方法?

Maybe you could try an analogous thing when starting your application?

这篇关于使用 Windows 身份验证从非域计算机访问 SQL Server 2005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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