Question

Currently I can access our db using vim with the standard dbext plugin.

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

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.

Was it helpful?

Solution 2

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

  1. Make sure that the 32 bit version of sqlcmd.exe is on your search path by opening PowerShell and typing get-command sqlcmd and making sure that the source path starts with C:\Program Files (x86)\. If if doesn't you need to add C:\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 bit SQLSRV.exe, of course).

  2. 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'
    

    Note that the -G tells SQLSRV to use the Active Directory Integrated Authentication, and the -N is for encrypting the connection.


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

OTHER TIPS

This string works fine:

type=SQLSRV:integratedlogin=1:dsnname=SQLOLEDB.1:srvname=boxname
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top