使用Windows身份验证非域计算机访问到SQL Server 2005 [英] Access to SQL Server 2005 from a non-domain machine using Windows authentication
问题描述
我在其中一台机器运行SQL Server 2005和它被配置为只支持Windows身份验证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=domain\user;Password=password";
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
不过,这种失败:客户端的错误是:
However, this fails: the client-side error is:
System.Data.SqlClient.SqlException:用户登录失败domain\user'
和服务器端错误是:错误18456,严重性14,状态5
System.Data.SqlClient.SqlException: Login failed for user 'domain\user' and the server-side error is: Error 18456, Severity 14, State 5
我已经在用户ID尝试了各种事情,包括集成的安全级别设置为true和false,而\而不是\,但没有成功。
I have tried various things including setting integrated security to true and false, and \ instead of \ in the User Id, but without success.
在一般情况下,我知道这可能2005实例从非域计算机连接到SQL Server(例如,我有一个工作基于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身份验证另一个域你启动应用程序时需要使用运行方式基金的时候。
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:OTHERDOMAIN\OTHERUSERNAME /netonly
"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe"
也许你可以开始你的应用程序时,尝试类似的事情?
Maybe you could try an analogous thing when starting your application?
这篇关于使用Windows身份验证非域计算机访问到SQL Server 2005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!