vim/dbext可以使用集成安全性而不是sql-login访问数据库 [英] Can vim/dbext use integrated security rather than a sql-login to access db
问题描述
当前,我可以使用带有标准dbext
插件的vim
访问我们的数据库.
Currently I can access our db using vim
with the standard dbext
plugin.
我正在使用我们的sql-server-logins之一的详细信息来实现此目的:
I'm using the details of one of our a sql-server-logins to achieve this:
type=SQLSVR:user=userName:psswd=userPwrd:dsnname=SQLOLEDB.1:srvname=boxname
我是否可以更改此连接字符串,以便它使用我的登录凭据来访问服务器-与SSMS
相似?这样,如果在此PC上安装了vim,它将使用登录该PC的任何人的详细信息来访问数据库,即,如果访问权限比我少的同事登录到此PC,则vim将使用其详细信息-他对以下计算机的访问权限因此数据将受到相应的限制.
Could I change this connection string so that it uses my login credentials to get access to the server - in a similar way to SSMS
? So that if vim is installed on this pc it will use the details of whoever logs in to this pc to access the db i.e. if a colleague with less access rights than me logs in to this pc then vim will use his details - his access to the data will thus be limited accordingly.
推荐答案
@whytheq的答案适用于集成Windows身份验证",但是如果要使用 SQL Server Management Studio ,则需要:
@whytheq's answer works for "Integrated Windows Authentication", but if you want to connect using Active Directory Integrated authentication, which is installed with SQL Server Management Studio, you'll need to:
-
通过打开PowerShell并键入
get-command sqlcmd
并确保源路径以C:\Program Files (x86)\
开头,确保32位版本的sqlcmd.exe
在您的搜索路径中.如果不是,则需要将C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn
添加到系统的Path环境变量中(当然,在包含64位SQLSRV.exe
的任何路径之前).
Make sure that the 32 bit version of
sqlcmd.exe
is on your search path by opening PowerShell and typingget-command sqlcmd
and making sure that the source path starts withC:\Program Files (x86)\
. If if doesn't you need to addC:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn
to your System's Path environment variable (before any paths which include the 64 bitSQLSRV.exe
, of course).
告诉dbext使用SQLSRV
而不是OSQL
来执行查询,方法是将其添加到您的_vimrc
中(最好在augroup
中作为
Tell dbext to use SQLSRV
instead of OSQL
to execute queries by adding this to your _vimrc
(ideally in an augroup
as the dbext readme suggests):
let g:dbext_default_SQLSRV_bin = 'sqlcmd'
let g:dbext_default_SQLSRV_cmd_options = '-b -G -N'
请注意,-G
告诉SQLSRV
使用Active Directory集成身份验证,并且-N
用于加密连接.
Note that the -G
tells SQLSRV
to use the Active Directory Integrated Authentication, and the -N
is for encrypting the connection.
在旁边:奇怪的是,从强制执行安全连接的服务器请求安全连接(-N
)可能会导致错误消息指出SSL Provider: The target principal name is incorrect
,在这种情况下,您需要放下-N
Aside: Oddly, requesting a secure connection (-N
) from a server that enforces a secure connection can result in an error message stating SSL Provider: The target principal name is incorrect
, in which case you'll want to drop the -N
这篇关于vim/dbext可以使用集成安全性而不是sql-login访问数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!