使用Windows身份验证连接到不同域上的SQL Server

时间:2021-09-12 02:39:58

I am trying to connect to a SQL Server that is located on a different domain and does not have SQL Server authentication enabled. I am using this connection string but it doesn't work.

我正在尝试连接到位于不同域上的SQL Server,并且未启用SQL Server身份验证。我正在使用此连接字符串,但它不起作用。

Data Source=<Server\Instance>;User ID=<domain\username>;password=<password>;connection timeout=10

1 个解决方案

#1


1  

If the domains are joined together in some way (part of the same forest, domain trusts, forest trusts etc.), you should be able to grant the domain user you're running as permissions on the database.

如果域以某种方式连接在一起(部分相同的林,域信任,林信任等),您应该能够授予您作为数据库权限运行的域用户。

Alternatively, you could run the connection in the security context of an authorised domain user by using impersonation. This would rely on that user having the correct permissions to log into the machine your code is running on.

或者,您可以使用模拟在授权域用户的安全上下文中运行连接。这将依赖具有正确权限的用户登录运行代码的计算机。

If there is no trust between the domains then you are going to have to go with SQL Auth as I don't believe that it is possible to impersonate a domain user from a non-trusted computer.

如果域之间没有信任,那么您将不得不使用SQL Auth,因为我不相信可以从不受信任的计算机模拟域用户。

If you aren't able to enable SQL auth then I don't think you'll be able to do what you ask.

如果您无法启用SQL身份验证,那么我认为您无法按照自己的要求执行操作。

#1


1  

If the domains are joined together in some way (part of the same forest, domain trusts, forest trusts etc.), you should be able to grant the domain user you're running as permissions on the database.

如果域以某种方式连接在一起(部分相同的林,域信任,林信任等),您应该能够授予您作为数据库权限运行的域用户。

Alternatively, you could run the connection in the security context of an authorised domain user by using impersonation. This would rely on that user having the correct permissions to log into the machine your code is running on.

或者,您可以使用模拟在授权域用户的安全上下文中运行连接。这将依赖具有正确权限的用户登录运行代码的计算机。

If there is no trust between the domains then you are going to have to go with SQL Auth as I don't believe that it is possible to impersonate a domain user from a non-trusted computer.

如果域之间没有信任,那么您将不得不使用SQL Auth,因为我不相信可以从不受信任的计算机模拟域用户。

If you aren't able to enable SQL auth then I don't think you'll be able to do what you ask.

如果您无法启用SQL身份验证,那么我认为您无法按照自己的要求执行操作。