[英]Connecting to SQL Server on different domain using Windows Authentication
I am trying to connect to a SQL Server that is located on a different domain and does not have SQL Server authentication enabled. 我试图连接到位于其他域上且未启用SQL Server身份验证的SQL Server。 I am using this connection string but it doesn't work. 我正在使用此连接字符串,但不起作用。
Data Source=<Server\Instance>;User ID=<domain\username>;password=<password>;connection timeout=10
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身份验证,那么我认为您将无法执行您要求的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.