Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Thanks! Awesome group. I put out a simple question in the access/vba forum that I couldn't find answered on technet or anywhere else on the web and it was answered the same day!!..."

Geography

Where in the world do Tek-Tips members come from?
djj55 (Programmer)
9 May 12 9:40
Hello, SQL 2008 R2
We are changing our level of PCI certification and I have a question about SQL access security.

Is there a way to give someone (windows active directory logon) access to execute a stored procedure without giving them access to read and write to the database?  I was thinking of the stored procedure doing a run as, thus the user cannot directly edit the database.

Thanks

 

djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!

Qik3Coder (Programmer)
9 May 12 16:35
I had to do something similar to this for an audit finding.

We took away all but the most rudimentary access to the database.
The users have access to execute stored procedures, but not to read/write to the db.

The stored procs are treated as "sanctioned" code, and direct table access is prevented. You have to be careful if you have cross db or cross server queries, because you have to do things with the guest account.

In an app that took it one step further, the code actually assumed an APP ROLE, which had access to execute procedures. The users had basic login privileges, and little else.

Lodlaiden

You've got questions and source code. We want both!
Oh? That? That's not an important password. - IT Security Admin (pw on whiteboard)

djj55 (Programmer)
10 May 12 7:48
Thanks for the reply.  I have problems with SQL Server security.  
It never works for me like the MS instructions say it will.

djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!

SQLBill (MIS)
10 May 12 11:30

One option is to create a new database role:
CREATE ROLE db_runprocs AUTHORIZATION DBO

Then grant your users access to just that role.

Next, grant that role to all stored procedures:
GRANT EXECUTE ON <stored proc name> TO db_runprocs

-SQLBill

The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875

mrdenny (Programmer)
5 Jun 12 15:40
Yes. The default way that SQL Server security works is that users can execute stored procedures without needing access to the underlying tables.

The exception from this is if you are using dynamic SQL within the stored procedure. If you are using dynamic SQL within the stored procedure you'll need to either give the user access to do what ever the stored procedure is trying to do, or you'll need to use EXECUTE AS within the stored procedure and that user which the code within the procedure is executed as will need to have access to the base tables.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / SQL 2005 BI / SQL 2008 DBA / SQL 2008 DBD / SQL 2008 BI / MWSS 3.0: Configuration / MOSS 2007: Configuration)
MCITP (SQL 2005 DBA / SQL 2008 DBA / SQL 2005 DBD / SQL 2008 DBD / SQL 2005 BI / SQL 2008 BI)
MCM (SQL 2008)
MVP

My Site

djj55 (Programmer)
6 Jun 12 6:43
I have had trouble in the past where a user could not execute a stored procedure even with read/write access. Solved by creating an execute role for them.

As stated I have a lot of trouble working with security. Is there a simple to understand resource I can obtain to help an aparently slow learner? As I said when I follow the Microsoft instructions it does not work as the instructions indecate, thus I am either doing something wrong (quite likely) or the instructions assume too much (MS is good at that).

djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!

djj55 (Programmer)
24 Aug 12 9:06
Working on this again (finally). I have a question about the GRANT.
SQLBill said to use
GRANT EXECUTE ON <stored proc name> TO db_runprocs
My question is what is the difference between that and
GRANT EXECUTE TO db_runprocs

Thanks

djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!

MegaSQLBI (IS/IT--Management)
24 Aug 12 11:14
GRANT EXECUTE ON <stored proc name> TO db_runprocs - Gives access only to that specific procedure
djj55 (Programmer)
25 Aug 12 7:48
So if I want to give permission to all stored procedures I use GRANT EXECUTE TO db_runprocs?

djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!

Helpful Member!  MegaSQLBI (IS/IT--Management)
27 Aug 12 3:28
Yes, that's right.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close