从非域机器连接到域 SQL Server 2005

时间:2023-02-19
本文介绍了从非域机器连接到域 SQL Server 2005的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我前几天问了一个问题(从使用 Windows 身份验证的非域计算机访问 SQL Server 2005) 获得了一些有趣但不可用的建议.我想再次问这个问题,但要明确我的限制是什么:

I asked a question a few days ago (Access to SQL Server 2005 from a non-domain machine using Windows authentication) which got some interesting, but not usable suggestions. I'd like to ask the question again, but make clear what my constraints are:

我有一个 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.

我不能在任何一台机器上创建或修改操作系统或 SQL Server 用户,我不能对权限或模拟进行任何更改,我不能使用 runas.

I CANNOT create or modify OS or SQL Server users on either machine, and I CANNOT make any changes to permissions or impersonation, and I CANNOT make use of runas.

我知道我可以编写仅使用以下四个参数即可连接到 SQL Server 数据库的 Perl 和 Java 应用程序:服务器名称、数据库名称、用户名(以域用户的形式)和密码.

I know that I can write Perl and Java applications that can connect to the SQL Server database using only these four parameters: server name, database name, username (in the form domainuser), and password.

在 C# 中,我尝试了各种方法:

In C# I have tried various things around:

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

并尝试将集成安全设置为 true 和 false,但似乎没有任何效果.我在 C# 中尝试做的事情是不可能的吗?

and tried setting integrated security to true and false, but nothing seems to work. Is what I am trying to do simply impossible in C#?

感谢您的帮助,马丁

推荐答案

正如您所说,Linux 机器上的 JDBC 或 Perl 都可以使用 Windows 身份验证和不同的凭据连接到 SQL Server来自当前登录的用户.顺便说一下,同样适用于 Windows CE 设备.

As you correctly say, JDBC or Perl on a Linux machine can both connect to an SQL Server using Windows authentication and credentials which differ from the currently logged on user. The same is true for Windows CE devices, by the way.

我认为这不是 C# 的问题,而是 SQL Server OLE DB 驱动程序的问题.我猜上面提到的方法在网络级别上假装是使用某些特定凭据的 Windows 机器";SQL Server OLE DB 驱动程序缺少的一项功能.因此,我的建议是寻找可以访问 SQL Server 数据库的替代(可能是商业的?)OLE DB 驱动程序.不过,我不确定是否存在这样的东西.

I think that this is that this is not an issue of C# but of the SQL Server OLE DB driver. I guess the methods mentioned above "pretend to be a Windows machine using some specific credentials" on the network level; a feature, which the SQL Server OLE DB driver lacks. Thus, my suggestion would be to look for an alternative (maybe commercial?) OLE DB driver that can access SQL Server databases. I'm not sure if such a thing exists, though.

这篇关于从非域机器连接到域 SQL Server 2005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:使用 C#,如何检查活动目录中是否禁用了计算机 下一篇:C# - 查找 Active Directory 用户的所有电子邮件地址

相关文章

最新文章