开发者

SQL-Server: Impersonation

开发者 https://www.devze.com 2022-12-30 19:26 出处:网络
is there any way to make a certain session execute all commands as a开发者_StackOverflow社区 certain user? I cannot use the execute as clause because it mustn\'t be hardcoded.

is there any way to make a certain session execute all commands as a开发者_StackOverflow社区 certain user? I cannot use the execute as clause because it mustn't be hardcoded.

I need something along the lines of this pseudocode:

ALTER SESSION sessionid SET EXECUTING_USER=someuser


EXECUTE AS can accept variables (in 2008 at least) so you don't have to hardcode the name to use it.

DECLARE @username sysname = 'foobar'

EXECUTE AS USER = @username

SELECT SESSION_USER

0

精彩评论

暂无评论...
验证码 换一张
取 消