views:

47

answers:

2

I need to set some users up to be able to create stored procedures with READ access only. Also, in production they cannot have SELECT, only EXECUTE on the procs they created. In development they would have SELECT so they could create their procedures.

I've set up a schema called Reports. The owner of that schema is a login - Report_Admin. That user has select access to tables. I then gave alter and execute on the Reports schema to my report writer account. Dbo owns the table - so it works if dbo also owns the Reporting schema - but then a delete will also work in the procedure!

We are using reporting services and would like to have all the SQL in the database for maintainability.

Thanks!

A: 

You can assign permissions to roles and users, no need for separate schema's. So I'd only use one schema: "dbo" (the default)

Create a database role for the users. Grant data_reader to that role on development. On both development and production, grant execute rights on the stored procedures. As far as I know, you'll have to grant the execute right for each stored procedure.

Andomar
The second schema is needed exactly to be able to rant EXECUTE ann all procedures at one. Having two completely separate machines is not exactly the same think as having a separation of SELECT permission for procedure writers and EXECUTE only for users running the report. Quite different, I'd say.
Remus Rusanu
Ok, is there a reason you can't grant execute to all procedures in the dbo schema? Btw the question does mention a separate development system.
Andomar
+2  A: 

You're not going to succeed using ownership chaining, as you already discovered. A solution would be like this: report_writer must create its reports with an EXECUTE AS SELF clause so they get executed under the report_writer priviledges. Then the report_reader group will be able to leverage the EXECUTE permission on reports schema to execute said reports, and the reports will be able to read the data because of the execute as clause.

Remus Rusanu
Not sure if I understand the question right, but it seems in production the report_writer user does not have select rights. So EXECUTE AS SELF would prevent the stored procedures from selecting anything.
Andomar
@Andomar: report_writer has SELECT permission. In the OP is Report_Admin.
Remus Rusanu