1 year ago

#298421

test-img

yeahman269

Specify another Windows account than session one when using DBI::dbConnect() and MS SQL Windows Authentication?

I am in a corporate environment.

I can easily establish a connection between R and a SQL database thanks to DBI and odbc packages this way:

con <- DBI::dbConnect(
  odbc::odbc(),
  driver = SQL.driver,
  server = SQL.server,
  database = SQL.database,
  encoding = SQL.encoding
)

This implicitely uses the "Windows Authentication" method. However, the server that will have to run the above R code will not be using a Windows Account that has actually access to the MS SQL DB.

Therefore, I would like to know how can I explicitely specify another Windows Account prior to or within the code above?

Any help would be greatly appreciated.

In other words, I would like to reproduce following behavior in R the following manual process (on a Windows session that uses credentials not allowed to connect to the SQL DB):

  • SHIFT+right click on MSSSM,
  • "Run as a different user",
  • Enter Windows Account #2 (the one that actually has access to the DB),
  • Connect to SQL DB using Windows Authentication (the #2 one, not the Windows session one which does not)

Hope the context is clear.

For obscure corporate reasons, creating a local SQL account is not possible. Otherwise, thanks to UID/PWD of DBI/odbc it would be theoritically straighforward.

r

sql-server

odbc

dbi

0 Answers

Your Answer

Accepted video resources