SQL Server执行模拟 [英] SQL Server Execute Impersonation
问题描述
...之间的区别是什么
What is the diffrence between...
execute as user = 'testuser'
AND
execute as login = 'testuser'
我正在这些登录名下执行跨数据库过程,并且它以exececute作为登录名而不是作为用户执行.据说服务器主体"testuser"在安全性上下文下不能访问数据库"xxx".
I am executing a cross database procedure under these logins and it works with the exececute as login but not the execute as user. It is saying the server principal "testuser" is nt able to access the database "xxx" under the securty context.
当我在两个命令后都SELECT SYSTEM_USER
时,我看到它已设置为'testuser'
When i SELECT SYSTEM_USER
after both commands I see that it is set to 'testuser'
推荐答案
execute as login
为整个服务器提供了模拟.由于用户是按数据库定义的,因此execute as user
模拟仅适用于特定的数据库,这就是为什么您在跨数据库时看到错误的原因.
execute as login
provides impersonation to the entire server, since logins are on a server level. Since users are defined per database, execute as user
impersonation applies only to a specific database, which is why you see the error when you cross databases.
这篇关于SQL Server执行模拟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!