SQL Server 2008 - 触发器是否以与登录名/用户相同的权限运行?

只是一个简单的问题:

假设我在数据库中的一个表上放置了一个插入触发器.

如果数据是通过登录名/用户foobar"插入到该表中的.

触发器是否以与foobar"相同的访问权限/权限执行?

非常感谢.

解决方案

是.

您可以使用

控制此行为

EXECUTE AS

create 语句的子句,如在此处解释.>

触发器的默认值是

作为调用者执行

我们在哪里找到

<块引用>

来电者

指定模块内部的语句在上下文中执行模块的调用者.执行模块的用户不仅必须对模块本身具有适当的权限,而且也适用于模块引用的任何数据库对象.CALLER 是除队列之外的所有模块的默认设置,与 SQL Server 2005 的行为相同.

Just a quick question:

Say I put an insert trigger on a table in my database.

If data is inserted into that table through a login/user "foobar".

Does the trigger execute with the same access rights / permissions as "foobar"?

Many thanks.

解决方案

Yes.

You can control this behaviour with the

EXECUTE AS

clause of the create statement, as explained here.

The default for triggers is

EXECUTE AS CALLER

where we find

CALLER

Specifies the statements inside the module are executed in the context of the caller of the module. The user executing the module must have appropriate permissions not only on the module itself, but also on any database objects that are referenced by the module. CALLER is the default for all modules except queues, and is the same as SQL Server 2005 behavior.

相关文章