简体   繁体   中英

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. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM