使用Windows身份验证使用Management Studio连接到SQL Server

时间:2021-12-29 01:44:43

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.

我正在与Management studio合作,我想登录位于另一个域中另一台服务器上的数据库。我唯一的登录是使用Windows凭据。

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:

我希望能够通过本地PC上的Management Studio登录。我发现唯一的方法是使用类似于的命令:

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?

虽然这有效,但它并不是最简单或最好的方式。有没有更好的办法?我能在Management Studio中做到这一点吗?

3 个解决方案

#1


3  

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

连接到另一个域中的SQL Server但仍使用Windows身份验证的唯一优雅方法是:

  • What you're already doing: runas /netonly
  • 你在做什么:runas / netonly

  • Connecting via remote desktop and opening SSMS locally on the remote server
  • 通过远程桌面连接并在远程服务器上本地打开SSMS

#2


1  

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.

除了您收到的其他答案之外,您还可以右键单击可执行文件或快捷方式,然后在生成的上下文菜单中,应该有一个以不同用户身份运行的选项。我在Win 7机器上试过这个。我似乎记得在XP中,我必须安装ShellRunAs才能显示这些选项。

#3


0  

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

您可以通过下载ShellRunAs或更好的整个Sysinternals Suite来获得图形密码提示。

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

    将ShellRunAs或Sysinternals Suite的可执行文件存储在您选择的位置。我建议:

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

    然后,您可以通过运行为所有应用程序/快捷方式启用“以不同用户身份运行...”上下文菜单选项

    shellrunas /reg
    

    使用Windows身份验证使用Management Studio连接到SQL Server

  • 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:

    如果只想为SQL Server Management Studio启用此功能,可以创建它的快捷方式并传递管理工作室的路径,如下所示:

    "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.

如果您下载整个Sysinternal Suite,我建议您将目录添加到PATH环境变量中。

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.

请注意,您需要根据SQL Server Management Studio版本调整上述路径,以及是否运行64位或32位Windows。

#1


3  

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

连接到另一个域中的SQL Server但仍使用Windows身份验证的唯一优雅方法是:

  • What you're already doing: runas /netonly
  • 你在做什么:runas / netonly

  • Connecting via remote desktop and opening SSMS locally on the remote server
  • 通过远程桌面连接并在远程服务器上本地打开SSMS

#2


1  

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.

除了您收到的其他答案之外,您还可以右键单击可执行文件或快捷方式,然后在生成的上下文菜单中,应该有一个以不同用户身份运行的选项。我在Win 7机器上试过这个。我似乎记得在XP中,我必须安装ShellRunAs才能显示这些选项。

#3


0  

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

您可以通过下载ShellRunAs或更好的整个Sysinternals Suite来获得图形密码提示。

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

    将ShellRunAs或Sysinternals Suite的可执行文件存储在您选择的位置。我建议:

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

    然后,您可以通过运行为所有应用程序/快捷方式启用“以不同用户身份运行...”上下文菜单选项

    shellrunas /reg
    

    使用Windows身份验证使用Management Studio连接到SQL Server

  • 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:

    如果只想为SQL Server Management Studio启用此功能,可以创建它的快捷方式并传递管理工作室的路径,如下所示:

    "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.

如果您下载整个Sysinternal Suite,我建议您将目录添加到PATH环境变量中。

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.

请注意,您需要根据SQL Server Management Studio版本调整上述路径,以及是否运行64位或32位Windows。