tags:

views:

22

answers:

1

At the bottom of most of our stored procedures we have a grant similar to

GRANT EXECUTE ON [dbo].[uspFOO] TO [DOMAIN\SQLServerUsers]

Luckily for me, our domain is changing and we now need to go through and change the permissions. Does anyone know of an easy way to do this using the DB metadata so I can pull out all the places where [DOMAIN\SQLServerUsers] is given permission to run and substitute it with [DOMAIN2\SQLServerUsers]?

Thanks.

For those asking, this is on SQL Server 2005.

+1  A: 

What version of SQL Server are you on??

In 2005 and up, you could

  • create a new database role "db_executor" and do

    GRANT EXECUTE TO db_executor
    
  • grant that database role to all necessary users

This will create a "catch all" role that has execute rights on every existing and future (!!) stored proc in your database. Yes, that does include future stored procs, too! Very handy indeed (at least as long as every user is allowed to execute all stored procs)

That way, you don't have to create separate GRANT EXECUTE statements for each and every stored proc.......

marc_s
We may go this way to ease our pain, but I know that we have specific stored procedures which we don't want users to have access to. If I understand you correctly, then this will give execute on all stored procs to the AD group which is not exactly what we want.
Rebthor
Not to an AD group - to a SQL database role. This role can be assigned to SQL Server logins as needed and as you want
marc_s
Ok, but if I have a stored proc named restricted_proc and have the above executor role created, can executor run restricted_proc or not? If yes, then haven't I opened a huge security hole when I assign my big AD group that role?Nonetheless, I'm marking this as accepted since it will get us up and running again quickly while we migrate permissions.
Rebthor
Yes, sure - the db role "executor" can run *any* stored proc. And if you assign that db executor role to a big AD group, of course, all those users can run the stored procs.
marc_s