我有DB1,并添加了链接服务器DB2,并具有从DB2执行的存储过程。我的应用程序使用繁琐的连接来接收存储过程。我的配置使用的是Windows帐户,该帐户对DB1具有本地管理员权限,对DB2具有只读权限
const {Request} = require('tedious');
const TYPES = require('tedious').TYPES;
const ConnectionPool = require('tedious-connection-pool');
//const dbConfig = require('./dbconfig');
const client = require("mssql/msnodesqlv8");
const poolConfig = {
min: 1,
max: 1,
log: true
};
const config = {
userName: "WindowsUsername",
password: "Password",
server: "localhost",
domain: "US",
options: {
instance: "SQLEXPRESS",
database: "DB1",
encrypt: false,
rowCollectionOnDone: true,
useColumnNames: true
}
};
const pool = new ConnectionPool(poolConfig, config);
我的sql查询在db1下的存储过程中的相同Windows帐户上的sql管理中执行,但是在应用程序上运行时出现错误
SELECT *
FROM [SERVERNAME].[DB2].[SCHEMA].[TABLE]
在DB1中执行存储过程时出错
message: 'Login failed for user \'NT AUTHORITY\\ANONYMOUS LOGON\'.',
code: 'EREQUEST',
number: 18456,
state: 1,
class: 14,
serverName: 'DB2',
procName: '',
lineNumber: 1 }