Re: broken ownership chains
From: BP Margolin (bpmargo@attglobal.net)
Date: 10/11/02
- Next message: Uttam Parui[MS]: "RE: SQL Server 7 SP4 security patch"
- Previous message: Netedix: "Re: Can't print Crystal Report from SQL"
- In reply to: sarathy: "broken ownership chains"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
From: "BP Margolin" <bpmargo@attglobal.net> Date: Fri, 11 Oct 2002 14:20:21 -0400
Sarathy,
This behavior has nothing to do with broken ownership chains. Rather,
dynamic SQL requires that the user calling the stored procedure have not
only EXEC permissions on the stored procedure, but appropriate permissions
on all the database objects referenced within the dynamic SQL. This is
documented in the SQL Server Books Online:
"Permissions to use the statement(s) within the EXECUTE string are checked
at the time EXECUTE is encountered, even if the EXECUTE statement is
included within a stored procedure. When a stored procedure is run that
executes a string, permissions are checked in the context of the user who
executes the procedure, not in the context of the user who created the
procedure."
You are "shooting yourself in the foot" by using dynamic SQL and denying
access to the table referenced in the dynamic SQL.
-------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.
"sarathy" <get_Sarathy@yahoo.com> wrote in message
news:24f901c27146$93c86b30$3aef2ecf@TKMSFTNGXA09...
> I have three objects with the same owner
> 1 table and 2 SPs
> both the SPs do a select * from the table -
> one directly and another dynamically
>
> I give exec permission to both SPs to an user and deny
> select on the table
>
> Now when the user executes the dynamic SP, the ownership
> chain seems to be broken . why is this so?
> eg:
>
> CREATE TABLE
> OnlyNumbers
> (
> a int
> )
> go
>
> insert into OnlyNumbers values (1)
> insert into OnlyNumbers values (2)
> insert into OnlyNumbers values (3)
> go
>
> go
> SELECT * from OnlyNumbers
>
> go
> CREATE PROC
> direct
> as
> SELECT * from OnlyNumbers
> go
> CREATE PROC
> dynamicProc
> as
> EXEC('SELECT * from OnlyNumbers')
>
> go
> GRANT EXECUTE
> ON direct
> TO <some user>
>
> go
> GRANT EXECUTE
> ON dynamicProc
> TO <some user>
>
> go
>
> DENY SELECT
> ON OnlyNumbers
> to <some user>
>
> Thanks
> Sarathy
- Next message: Uttam Parui[MS]: "RE: SQL Server 7 SP4 security patch"
- Previous message: Netedix: "Re: Can't print Crystal Report from SQL"
- In reply to: sarathy: "broken ownership chains"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|