微软elearning sql2005 有这段,Alice可以执行sp,可是Eve怎么有权限呢?
Using the EXECUTE AS Clause
In this example, you will learn how to use the EXECUTE AS clause.
In the AdventureWorks database, a user named Bob has created a table named sales.orders and granted Alice SELECT permission on it. Bob has not granted any permissions to Eve.
Eve has created a stored procedure named sales.getorders by executing the following Transact-SQL code:
CREATE PROCEDURE sales.getOrdersWITH EXECUTE AS SELFASSELECT * FROM sales.orders
Note that the EXECUTE AS SELF clause causes the stored procedure to run using Alice’s credentials. This means that Eve can retrieve data from the sales.order table by executing sales.getorders, even though she has no explicit permissions on the table and there is a break in the ownership chain.
EXECUTE AS SELF is equivalent to EXECUTE AS user_name, where the specified user is the person creating or altering the module
如果是Alice 创建的 sales.getorders，而且给了Eve执行 sales.getorders的权限，那么就对了，这样Eve是能获取数据的，尽管她没有访问其中数据表的权限