command
"C:\Windows\System32\runas.exe /user:username@domainname /netonly "C:\Program Files\Microsoft SQL Server\100\Tools\binn\VSShell\Common7\IDE\Ssms.exe -nosplash" "
Sometimes it is necessary to use Windows domain credentials to authenticate with a SQL Server from a non-domain joined machine. Here’s a trick from my coworker Martin Kastenbaum to pass Windows domain credentials from a non-domain joined machine. You can pass your Windows credentials to SQL Server Management Studio by making a simple modification to the shortcut you use to launch it. It's probably a wise idea to make a copy of your SSMS shortcut and make all changes to the copy, not the original.
Figure 1. SSMS 2005 shortcut on the left, SSMS 2008 shortcut on the right.
You need to modify the target, but first you should press the Change Icon… button and save the path to the icon. You’ll need to use it later.
Figure 2. Save the path for the icons.
Modify the shortcut’s target as follows:
SQL Server 2008 x64: C:\Windows\System32\runas.exe /user:YourDomain\YourUsername /netonly "C:\Program Files (x86)\Microsoft SQL Server\100\Tools\binn\VSShell\Common7\IDE\Ssms.exe -nosplash"
SQL Server 2008 x86: C:\Windows\System32\runas.exe /user:YourDomain\YourUsername /netonly "C:\Program Files\Microsoft SQL Server\100\Tools\binn\VSShell\Common7\IDE\Ssms.exe -nosplash"The –nosplash is optional. It slightly speeds up the SMSS startup time.
SQL Server 2005 x64: C:\Windows\System32\runas.exe /user:YourDomain\YourUsername /netonly "C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\VSShell\Common7\IDE\SqlWb.exe -nosplash"
SQL Server 2005 x86: C:\Windows\System32\runas.exe /user:YourDomain\YourUsername /netonly "C:\Program Files\Microsoft SQL Server\90\Tools\binn\VSShell\Common7\IDE\SqlWb.exe -nosplash"
Modifying the shortcut’s target messes up the icon. You’ll want to fix that by pressing the Change Icon… button again and restoring the path to the one you saved earlier. In case you didn’t save the path, the default values for the path to the icon are:
SQL Server 2008 x64: %ProgramFiles% (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe
SQL Server 2008 x86: %ProgramFiles%\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe
SQL Server 2005 x64: C:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\VSShell\Common7\IDE\SqlWb.exe
SQL Server 2005 x86: C:\Program Files\Microsoft SQL Server\90\Tools\binn\VSShell\Common7\IDE\SqlWb.exeWhen you start SSMS from a modified shortcut, you’ll be prompted for your domain password:
Figure 3. Password Prompt
Notice that the Connect to Server dialog is misleading after making this change. Although it properly shows I’m using Windows Authentication, it incorrectly indicates that my credentials are Win7L\John, which they are not. Once I click connect, I’m connected with the Domain\Username supplied in the modified shortcut.
Figure 4. Notice that the supplied domain and username do not appear in the dialog box.
This is a handy trick for consultants who use their own laptops to connect to a client’s domain joined SQL Server.
No comments:
Post a Comment