我在访问数据库时想要一个服务,我想访问数据库以使用调用身份凭证.
在我访问特定数据库之前,我会进行模拟
var winId = HttpContext.Current.User.Identity as WindowsIdentity;
var ctx = winId.Impersonate();
//Access Database
ctx.Undo();
Run Code Online (Sandbox Code Playgroud)
当服务在我的PC上本地运行时,此方案可以正常工作.但是,当部署在另一台远程PC上时,我收到错误:
用户"NT Authority\Anonymous Logon"登录失败
一旦它尝试访问数据库.
DBAdmin告诉我,SQL Server有一个SPN.
运行服务的帐户是域帐户.
请考虑以下情形:
我们有以下R脚本(DB.r):
lib.directory = "D:\\RTest"
install.packages("RODBC", repos = "http://cran.us.r-project.org", lib = lib.directory)
library(RODBC, lib.loc = lib.directory)
db.string <- "driver={ODBC Driver 13 for SQL Server};server=DBServer;database=Databse1;trusted_connection=Yes;"
db.channel <- odbcDriverConnect(db.string)
close(db.channel)
Run Code Online (Sandbox Code Playgroud)
Server1使用以下代码在R Server上远程执行R脚本:
PsExec.exe \\RServer "C:\Program Files\R\R-3.4.3\bin\Rscript.exe" "D:\RTest\DB.r"
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
[RODBC] ERROR: state 28000, code 18456, message [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.
Run Code Online (Sandbox Code Playgroud)
如何在不发送用户名和密码作为PsExec的一部分的情况下解决此错误?
我们愿意使用任何替代方法来取代PsExec.