简体   繁体   English

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

[英]SQL Server 2008 - Does a trigger run with the same permissions as the login/user?

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".如果数据通过登录/用户“foobar”插入到该表中。

Does the trigger execute with the same access rights / permissions as "foobar"?触发器是否以与“foobar”相同的访问权限/权限执行?

Many thanks.非常感谢。

Yes.是的。

You can control this behaviour with the您可以使用以下命令控制此行为

EXECUTE AS

clause of the create statement, as explained here . create 语句的子句,如此处所述

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. CALLER 是除 queues 之外的所有模块的默认值,并且与 SQL Server 2005 行为相同。

by default yes, but you can change that using默认情况下是,但您可以使用

WITH EXECUTE AS

on the trigger definition在触发定义上

http://msdn.microsoft.com/en-us/library/ms188354(v=sql.100).aspx http://msdn.microsoft.com/en-us/library/ms188354(v=sql.100).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM