SSMS Windows Authentication and VPN
SSMS with Windows Authentication is problematic when using it in conjunction with a VPN. SSMS only uses the primary domain login (the local computer) and not the remote domain login (your authentication credentials from the VPN) to try to login. Because of this, you get the dreaded error “Login failed for user ‘(null)’. Reason: Not associated with a trusted SQL Server connection.”
This wasn’t a problem with the old Query Analyzer because it would automatically detect the right username and password to use even if you were connected to a VPN.
There are two ways around this.
- In Windows XP, SHIFT right-click on the program and select Run As. Enter in your username and password for the remote domain.
- Vista is a bit trickier since you can only select Run As Administrator. So I wrote a simple script that uses the command line runas program to work around it. The script appears below.
I’ve titled the script runassql.cmd.
runas /netonly /user:%1 “C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\SqlWb.exe -S %2 -E -nosplash”
Usage is: runassql.cmd DOMAIN\username SERVERNAME.
Once you run the script, you’ll be asked for your password and then it should work.