SQL Agent Job 报“Access to the remote server is denied because the current security context is not trusted”

简介: SQL Server 2005(Microsoft SQL Server 2005 - 9.00.5000.00)下的一个作业执行一个存储过程,存储过程中动态SQL语句使用链接服务器(Linked Servers),从另外一台SQL Server服务器获取数据。

SQL Server 2005(Microsoft SQL Server 2005 - 9.00.5000.00)下的一个作业执行一个存储过程,存储过程中动态SQL语句使用链接服务器(Linked Servers),从另外一台SQL Server服务器获取数据。但是执行时报“Access to the remote server is denied because the current security context is not trusted”。但是在SSMS客户端手工执行存储过程却又是OK的。

 

遇到这个问题很是诡异,看似是一个权限和安全方面的原因,但是有不少作业也是这么做的,唯独这台服务器遇到这个问题。网上也有大把人遇到这个问题。官方都有一些资料。

 

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/512991fd-af88-4a87-8b3e-39e0e346040e/access-to-the-remote-server-is-denied-because-the-current-security-context-is-not-trusted?forum=sqlsecurity

 

https://blogs.msdn.microsoft.com/deepakbi/2010/03/02/job-fails-on-linked-server-access-to-the-remote-server-is-denied-because-the-current-security-context-is-not-trusted-sqlstate-42000-error-15274/

 

http://dba.stackexchange.com/questions/114723/current-security-context-is-not-trusted-for-job-running-as-a-sql-login-accessi

 

https://www.sqlservercentral.com/Forums/Topic579778-146-1.aspx

 

提供的解决方法也五花八门的。我都一一尝试了一下,结果都没有解决我的问题。最后按照下面这篇文章的介绍解决了问题。

 

http://stackoverflow.com/questions/10526198/access-to-the-remote-server-is-denied-because-the-current-security-context-is-no

 

修改作业的Owner,将作业Owner从sa改为链接服务器(Linked Server)的安全上下文( Current Security Context)所使用的账号(服务器两边都有该相同账号),问题解决。虽然问题解决了,但是还是没有明白root cause,跟一些人沟通都无解。暂时先记录一下这个问题。

 

----------------------------------------------------------------------------分割线---------------------------------------------------------

 

上面问题的原因已经弄清楚了,具体参考博客The server principal "sa" is not able to access the database "xxxx" under the current security context相同的原因)其实是因为在作业的步骤里面,有个高级选项,有个Run as User,里面设置了以某个特殊账户执行。所以遇到了上面问题, 而我上面阴错阳差的解决了,直到今天才找到Root Cause。

相关文章
|
SQL Oracle 数据库
使用访问指导(SQL Access Advisor)优化数据库业务负载
本文介绍了Oracle的SQL访问指导(SQL Access Advisor)的应用场景及其使用方法。访问指导通过分析给定的工作负载,提供索引、物化视图和分区等方面的优化建议,帮助DBA提升数据库性能。具体步骤包括创建访问指导任务、创建工作负载、连接工作负载至访问指导、设置任务参数、运行访问指导、查看和应用优化建议。访问指导不仅针对单条SQL语句,还能综合考虑多条SQL语句的优化效果,为DBA提供全面的决策支持。
450 11
|
XML Java 关系型数据库
IDEA 报错: java.sql.SQLException: Access denied for user ‘root ‘@‘localhost‘ (using password: YES)
IDEA 报错: java.sql.SQLException: Access denied for user ‘root ‘@‘localhost‘ (using password: YES)
3200 0
|
SQL 安全 数据库
|
SQL 数据库 Windows
【应用服务 App Service】当使用EntityFrameWorkCore访问Sql Server数据库时,在Azure App Service会出现Cannot create a DbSet for ** because this type is not included in the model for the context的错误
【应用服务 App Service】当使用EntityFrameWorkCore访问Sql Server数据库时,在Azure App Service会出现Cannot create a DbSet for ** because this type is not included in the model for the context的错误
355 0
|
SQL 存储 数据可视化
access sql 数据库,Access SQL
access sql 数据库,Access SQL
|
安全 关系型数据库 MySQL
java.sql.SQLException: null,message server: Host ora-rac2 is blocked because of many
java.sql.SQLException: null,message server: Host ora-rac2 is blocked because of many
261 0
解决java.sql.SQLException: Access denied for user ‘Lenovo‘@‘localhost‘ (using password: YES)问题~
解决java.sql.SQLException: Access denied for user ‘Lenovo‘@‘localhost‘ (using password: YES)问题~
650 0
QGS
|
SQL 监控 数据库
(Centos7-x86)zabix5.0-0 —agent2监控 SQL server数据库(Windows)
记(Centos7-x86)zabix5.0-0 —agent2监控 SQL server数据库(Windows)
QGS
788 0
(Centos7-x86)zabix5.0-0 —agent2监控 SQL server数据库(Windows)
|
SQL 安全 Oracle
MySQL&SQL server&Oracle&Access&PostgreSQL数据库sql注入详解
MySQL&SQL server&Oracle&Access&PostgreSQL数据库sql注入详解
1462 0
|
存储 人工智能 自然语言处理
AI经营|多Agent择优生成商品标题
商品标题中关键词的好坏是商品能否被主搜检索到的关键因素,使用大模型自动优化标题成为【AI经营】中的核心能力之一,本文讲述大模型如何帮助商家优化商品素材,提升商品竞争力。
1881 62
AI经营|多Agent择优生成商品标题