Connecting To A Database Using Windows Authentication With Different Credentials Using SQL Server Management Studio

November 3, 2010

This info courtesy of inotekgroup and Paulo Morgado:

The problem

You want to use a different username and password to connect to a SQL Server but the Windows Authentcation Username/Password are greyed out / disabled!

When connecting to a SQL Server using Windows Authentication, there is no way to type in an alternate domain/username through the user interface. It will default to the user that you are currently logged into the computer as.

How to Fix it

We’ll have to use the runas command to impersonate the user running SQL Server Management Studio (this comes with SQL Server ).

To connect using an alternate windows domain name, run the following command line script (alter the path to SSMS.EXE based on your computer’s configuration).

runas /netonly /user:[DOMAIN]\[USERNAME] “C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe”

This will open the tool. You can connect to any SQL Server that the user has access to – however, the domain\username that you typed in will not actually appear in the SQL Credential window. Don’t be confused – this will work, even though it doesn’t appear to.

Problems?

if you are on vista or above please run this command from an administrator command prompt

Some commands that you can run using Command Prompt might require elevated or administrative privileges. To run these commands, you can use the Run as administrator command:

  1. Click the Start button Picture of the Start button.
  2. In the Search box, type command prompt.
  3. In the list of results, right-click Command Prompt, and then click Run as administrator. Administrator permission required If you are prompted for an administrator password or confirmation, type the password or provide confirmation.