Running SQL Server Management Studio Aliased as a Different User

Running SQL Server Management Studio Aliased as a Different User

I connect to a client VPN often to work on their servers, their code, and their databases. My development machine is not a part of their domain, although I do have a domain account on their VPN. My problem; when I connect SQL Server Management Studio to a client database on their domain I cannot get in. They do not have SQL Authentication (which is a good thing) and rely on Windows auth.

My credentials get sent as “\\BinaryBiker-PC\BinaryBiker” and not as the user I am using over the VPN.

I solved the problem with the MS-DOS RunAs command. RunAs enables a user to execute a program as another user.

SYNTAX

RUNAS [/profile] [/env] [/netonly] /user:program

/profile if the user’s profile needs to be loaded
/env to use current environment instead of user’s.
/netonly use if the credentials specified are for remote access only.
/user <UserName> should be in form USER@DOMAIN or DOMAIN\USER
program command line for EXE. See below for examples

I created a BAT file on my desktop called “LaunchSQLRunAs.bat” with the following line in it (edited for brevity):

C:\Windows\System32\runas.exe /netonly /user:clientdomain\vpnusername 
     "C:\Program Files (x86)\<path to>\Ssms.exe"

That’s it. Now, when I am connected to the client VPN I can use my local SQL Management tools to log in and manage the databases – even though my machine is not on the domain.  I get prompted for my VPN password on the command prompt when I launch the batch file, but then I am in and able to work normally.

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: