Luca Zavarella Blog

Running your SSMS client as a domain user even if you’re not in a domain

I wonder if it is possible to use the SQL Server Management Studio (SSMS) client on my machine with a specific domain user when my machine wasn’t in that domain. In fact, many developers use some SSMS add-ons installed on their machine (with appropriate licenses), which greatly simplify their daily work.

For example, I’m a Red Gate SQL Prompt addicted Smile, so it’d be convenient for me to work on customers’ SQL Server instances with this tool. After reading Davide Mauri’s post, a friend and collegue of mine, I created a batch file in order to specify a domain and a user for SSMS:

@echo off
echo ***************************************
echo *** Run SSMS 2008 R2 as domain user ***
echo ***************************************
echo.

set /P user="Type the domain\username: "

C:\Windows\System32\runas.exe /netonly /user:%user% "C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe"

Then, you can create on your desktop a shortcut to the file batch previously developed and you can also change the shortcut icon, using the same SSMS icon (get it from the Ssms.exe file). Now if you double-click on the shortcut, you can set domain and user for the SSMS client on-the-fly:

So enjoy using your “personal” SSMS client on your preferred domain Smile

Legacy Comments


Justin
2011-08-30
re: Running your SSMS client as a domain user even if you’re not in a domain
I actually ran into a situation a couple of weeks ago where this would have been very useful. I needed to connect to another sql server instance on another domain. I ended up installing SSMS on another machine in that domain. It was a hassle.

I have to give this a try. Thanks so much!

lucazav
2011-08-30
re: Running your SSMS client as a domain user even if you’re not in a domain
You're welcome Justin :) Let me know if it works

lucazav
2011-09-02
re: Running your SSMS client as a domain user even if you’re not in a domain
Enjoy with this small trick! :)

colinr
2011-09-06
re: Running your SSMS client as a domain user even if you’re not in a domain
or you can just use the normal method, Hold Down shift key and right click when starting Management Studio and use the "Run as differant user" option.



lucazav
2011-09-06
re: Running your SSMS client as a domain user even if you’re not in a domain
Thank you for this shortcut, colinr! I didn't know it!

lucazav
2011-09-07
re: Running your SSMS client as a domain user even if you’re not in a domain
Using the colinr's shortcut, the prompted domain user has to be configured on your machine.
Using the batch I showed in my post, this constraint disappears, so you can use whatever domain user you need.

Cayle
2011-11-08
re: Running your SSMS client as a domain user even if you’re not in a domain
I told my kids we'd play after I found what I nedeed. Damnit.

Tim Cares
2011-12-29
re: Running your SSMS client as a domain user even if you’re not in a domain
I could not get this to work. SMSS.exe launches but still has my current domain\username (not the one in the .bat file), which are grayed out.

lucazav
2012-01-04
re: Running your SSMS client as a domain user even if you’re not in a domain
Hi Tim. After you launch SSMS thru the .bat, you'll always see the SQL Server service's domain/user near the SQL Server instance node, but the effective domain/user will be the ones you provided in the .bat.
I hope this can help you. Let me know

Sekhar
2012-04-04
re: Running your SSMS client as a domain user even if you’re not in a domain
I am using this script in xp, its not prompting fro password and exiting the script, Please let me know, if i am missing any thing
Thanks

lucazav
2012-04-04
re: Running your SSMS client as a domain user even if you’re not in a domain
Hi Sekhar,

I suppose the path "C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe" is wrong. Have you a 32-bit Windows XP? If so, removing the " (x86)" string from the previous path should be enough.

In order to check the error you receive, save the batch file (e.g. my_batch.bat) in C: and than follow the next steps:
1. Click on "Run..." and type "cmd"
2. Change your current directory typing "cd c:\"
3. Launch the bat file typing "my_batch.bat"

If an error occurs, you'd be able to read the error message into the console.

Hope this can help you.
Let me know.