use*_*248 7 sql-server execute-as
我创建了一个存储过程,它执行一系列需要特殊权限的操作,例如create database,restore database等.我创建了这个存储过程
execute as self
Run Code Online (Sandbox Code Playgroud)
...所以它作为SA运行.这是因为我想给一个没有任何权限的SQL用户只能运行我定义的这些命令.
但是当我运行这个存储过程时,我得到了
The server principal "sa" is not able to access the database "model" under the current security context.
Run Code Online (Sandbox Code Playgroud)
为什么SA无法访问模型数据库?我实际上在SA下运行存储过程中的代码,它运行正常.
在继续之前,请使用EXECUTE AS读取扩展数据库模拟.
使用EXECUTE AS USER语句模拟主体时,或者使用EXECUTE AS子句模拟数据库范围的模块时,默认情况下模拟的范围仅限于数据库.这意味着对数据库范围之外的对象的引用将返回错误.
| 归档时间: |
|
| 查看次数: |
14618 次 |
| 最近记录: |