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

Comments

  1. Gravatar Justin says:

    Re : # 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!
  2. Gravatar lucazav says:

    Re : # 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
  3. Gravatar lucazav says:

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

    Enjoy with this small trick! :)
  4. Gravatar colinr says:

    Re : # 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.


  5. Gravatar lucazav says:

    Re : # 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!
  6. Gravatar lucazav says:

    Re : # 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.
  7. Gravatar Cayle says:

    Re : # 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.
  8. Gravatar Tim Cares says:

    Re : # 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.
  9. Gravatar lucazav says:

    Re : # 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
  10. Gravatar Sekhar says:

    Re : # 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
  11. Gravatar lucazav says:

    Re : # 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.
Comments have been closed on this topic.