首页 > 代码库 > SQL Agent Job 报“Access to the remote server is denied because the current security context is not trusted”
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服务器获取数据。但是执行时报“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,跟一些人沟通都无解。暂时先记录一下这个问题。
SQL Agent Job 报“Access to the remote server is denied because the current security context is not trusted”