Ron Sparks Solution Architect, Author, Poet

Running SQL Server Management Studio Aliased as a Different User

R

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.

About the author

Ron Sparks

Ron Sparks is a technology professional, science fiction and fantasy author and poet living in Zurich, Switzerland. His latest book "ONI: Satellite Earth Series Book 1" is available on Amazon.com.

Add Comment

By Ron Sparks
Ron Sparks Solution Architect, Author, Poet

Ron Sparks

Ron Sparks is a technology professional, science fiction and fantasy author and poet living in Zurich, Switzerland. His latest book "ONI: Satellite Earth Series Book 1" is available on Amazon.com.

Welcome

A man of many passions, I lay claim to a myriad of interests and hobbies. Among them, I am an amateur astronomer, an avid motorcycle rider, a whiskey aficionado, a (poor) surfer, a scuba diver, a martial artist, a student of philosophy, a proponent of critical thinking, a technologist, an entrepreneur, a cancer survivor, and I harbor a lifelong love of science fiction and fantasy. Feel free to strike up a conversation on the social networks below.

Select a Category to Browse

Follow me on Twitter