简体   繁体   中英

Connect to SQL Server with Management Studio using Windows Authentication

I am working with Management studio and I want to log in to databases located on another server in another domain. The only login I have for such is with Windows credentials.

I want to be able to log in via Management Studio on my local PC. I have found the only way to do so is using a command similar to:

runas /netonly /user:domain\username "C:\Progr...\IDE\Ssms.exe"

While this works, it isn't the easiest or nicest way. Is there a better way? Any way I can do it within Management Studio?

The only elegant ways to connect to a SQL Server in another domain but still use Windows Authentication are:

  • What you're already doing: runas /netonly
  • Connecting via remote desktop and opening SSMS locally on the remote server

In addition to the other answers you've received, you can also shift-right click on an executable or a shortcut to one and in the resulting context menu, there should be an option to run as a different user. I tried this on my Win 7 machine. I seem to recall that in XP, I had to install ShellRunAs for these options to show up.

You can get a graphical password prompt by downloading ShellRunAs or better yet, the entire Sysinternals Suite .

  • Store the executable(s) for ShellRunAs or the Sysinternals Suite in a location of your choice. I recommend:

     C:\\Program Files\\Sysinternals 
  • You can then enable a "Run as different user..." context menu option for all applications/shortcuts by running

     shellrunas /reg 

    以不同用户身份运行

  • If you want to only enable this for SQL Server Management Studio, you can create a shortcut to it and pass the path the management studio like so:

     "C:\\Program Files\\Sysinternals\\ShellRunas.exe" "C:\\Program Files (x86)\\Microsoft SQL Server\\100\\Tools\\Binn\\VSShell\\Common7\\IDE\\Ssms.exe" 

If you download the entire Sysinternal Suite, I would recommend you add the directory to your PATH environment variable .

Please note that you will need to adjust the paths above based on your SQL Server Management Studio version and whether you're running 64 bit or 32 bit Windows.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM