Connect to SQL Server using domain account from remote machine

Tags: sql server, ssms, domain

As most of production databases don’t use the SQL Server integrated logon and leverage the existing AD domain accounts instead, there exists an issue with connecting to them from outside the domain. Unfortunately SSMS do not allow you to specify the domain account used in the connection directly (only SQL or Windows Integrated authentication are the options). It means that you can’t access such DB directly eg. when connecting to corporate VPN network from your own laptopIrytacja

I’m not keen on RDPing to the DB server every time to make a bunch of queries, so I found this workaroundUśmiech

From the command line you can specify the account that will be impersonated in all network-related communication of a given executable:

runas /netonly /user:DOMAIN\account "<path to your exe>"

Cool!Szeroki uśmiech

So to impersonate your domain account when using SSMS simply write:

runas /netonly /user:DOMAIN\account “C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe”

You’ll be asked for domain password and… That’s it! Choose “Windows Integrated” in SSMS connection screen and you can work with your DB from outside!Uśmiech

Remember the /netonly switch – it ensures that the account provided will be used in the network-related stuff only. It won’t work without supplying it, though.


kick it on

blog comments powered by Disqus