Re: Granting EXEC for read only SPs



BGL (BGL@xxxxxxxxxxxxxxxxxxxxxxxxx) writes:
Is there any way to grant EXEC on all SPs to a user or role where the SPs
don't modify user tables?

The only way to achieve exactly that is to grant access per procedure.

I created database role 'X' and granted EXEC permission for all SPs.
Then, I created a database user, added it to the role 'X' to inherit the
EXEC permissions, AND ALSO added the user to the fixed database role
'denydatawriter'.

This is because of ownership chaining. The rights of the procedure
owner applies, and not those of the current user. This works as long
as the procedure and the accessed tables has the same owner. Thus, if
you want the rights of the current user to apply, you can change the
owner of the procedure (or the tables) so that they are different.

The user will still be able to execute the procedures, but when the
procedures try to update, he will get a permission error.


--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.



Relevant Pages

  • Re: Is there a way to determine who created a stored procedure?
    ... determine who created a stored procedure? ... owner would reveal the answer, but the owner is by default always the ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.security)
  • Re: Cannot remove dbo rights from a user
    ... It showed the owner as our system ... account. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Row level security
    ... identify each row of tables against each users, so I add a column 'Owner' ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.security)
  • Re: Default User
    ... I can change the owner in each wizard, or create code, but I usually ... Which version of SQL Server are you on? ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.security)
  • Re: User names
    ... > With SP3 will tables created by upsizing from access also be dbo owned as ... >>dbo by default. ... byjust specifically giving the owner name in QA. ... >> SQL Server MVP ...
    (microsoft.public.sqlserver.server)