使用 DBI::dbConnect() 和 MS SQL Windows 身份验证时指定会话帐户之外的另一个 Windows 帐户吗?
我在公司环境中。
借助 DBI 和 odbc 包,我可以轻松地在 R 和 SQL 数据库之间建立连接:
con <- DBI::dbConnect(
odbc::odbc(),
driver = SQL.driver,
server = SQL.server,
database = SQL.database,
encoding = SQL.encoding
)
这隐式使用“Windows 身份验证”方法。但是,必须运行上述 R 代码的服务器将不会使用实际有权访问 MS SQL DB 的 Windows 帐户。
因此,我想知道如何在上述代码之前或内部明确指定另一个 Windows 帐户?
任何帮助将不胜感激。
换句话说,我想在 R 中通过以下手动过程重现以下行为(在使用不允许连接到 SQL DB 的凭据的 Windows 会话上):
- SHIFT+右键单击 MSSSM,
- “以其他用户身份运行”,
- 输入 Windows 帐户#2(实际有权访问数据库的帐户),
- 使用 Windows 身份验证连接到 SQL DB(#2 帐户,而不是 Windows 会话帐户,因为 Windows 会话帐户没有权限)
希望上下文清晰。
由于一些模糊的公司原因,无法创建本地 SQL 帐户。否则,由于 DBI/odbc 的 UID/PWD,理论上它会很简单。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论