Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Creating Logins Expand / Collapse
Author
Message
Posted Friday, September 4, 2009 7:00 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, August 1, 2013 2:51 AM
Points: 283, Visits: 312
Hi

I'm trying to create a sql server login with limited permissions as follows:

1. Database1 - tables read only.
2. Database2 - GRANT Select / Insert / Delete data
3. Database2 - GRANT Create / Alter procedure (delete action not required)
4. Database2 - Execute all procedure/functions
5. Database2 - User should not alter the table structure.

With the above mentioned details, can I create a ROLE so that I can create multiple logins with the same access/limitations as mentioned above for different databases.

Kindly provide me the code.

Regards
Mohan Kumar VS

Post #782869
Posted Friday, September 4, 2009 7:35 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 3:13 AM
Points: 2,704, Visits: 1,149
Mohan Kumar (9/4/2009)
Hi

I'm trying to create a sql server login with limited permissions as follows:

1. Database1 - tables read only.
2. Database2 - GRANT Select / Insert / Delete data
3. Database2 - GRANT Create / Alter procedure (delete action not required)
4. Database2 - Execute all procedure/functions
5. Database2 - User should not alter the table structure.

With the above mentioned details, can I create a ROLE so that I can create multiple logins with the same access/limitations as mentioned above for different databases.

Kindly provide me the code.

Regards
Mohan Kumar VS




yes you can create a role to do this. in fact you will need two separate roles. One for each database.

I find that BOL (Books online) is the best way of finding this information out.


--------------------------------------------------------------------------------------
Recommended Articles on How to help us help you and
solve commonly asked questions

Forum Etiquette: How to post data/code on a forum to get the best help by Jeff Moden
Managing Transaction Logs by Gail Shaw
How to post Performance problems by Gail Shaw
Help, my database is corrupt. Now what? by Gail Shaw
Post #782892
Posted Friday, September 4, 2009 8:09 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Yesterday @ 5:38 PM
Points: 31,368, Visits: 15,834
I'd agree that you need two roles.

Create a role in each db, then assign the permissions needed with the GRANT statement. If you don't grant rights, as in control of the schema or db_owner, the role will not be able to do things, like alter the tables.








Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #782936
Posted Friday, September 4, 2009 9:34 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 2:35 PM
Points: 12,962, Visits: 32,498
i don't get to play with permissions much, so this post intrigued me;
does db_datareader automatically bring in EXECUTE permissions on views
or db_datawriter automatically bring in EXECUTE permissions on procs/functions?

can someone confirm that the OP requirements for needing CREATE/ALTER EXECUTE on all procs , but denying DDL to tables means you have to resolve this way?


If cannot give db_ddladmin to the role, would you instead loop thru every proc, and grant each individually?

would that allow him to create a proc that does not exist? or is it more correct to do the reverse, grant db_ddladmin , but then loop thru every table and explicitly DENY?

it seems like i'm missing something where i might expect to be able to do something at the "object type" level,

I've seen the GRANT VIEW ANY DEFINITION to allow people to see the DDL of views and procs.
it seems like the granularity is missing bewtween schema and individual objects, or am i missing the command on how todo it?like this:
DATABASE
--SCHEMA--
----{OBJECTTYPES?}
----INDIVIDUAL OBJECTS
is there a similar command like GRANT CREATE ANY PROCEDURE, or are you stuck looping thru objects

I looked in BOL, but the actual examples for GRANT EXECUTE all use objects, and no schemas



--1. Database1 - tables read only.
USE Database1
CREATE ROLE [ReallyReadOnly]
--give reader writes to this group
ALTER AUTHORIZATION ON SCHEMA::[db_datareader] TO [ReallyReadOnly]
--explicitly DENY access to writing
ALTER AUTHORIZATION ON SCHEMA::[DB_DenyDataWriter] TO [ReallyReadOnly]

--2. Database2 - GRANT Select / Insert / Delete data
USE Database2
CREATE ROLE [ProcWriter]
ALTER AUTHORIZATION ON SCHEMA::[db_datareader] TO [ProcWriter]
ALTER AUTHORIZATION ON SCHEMA::[db_datawriter] TO [ProcWriter]
--3. Database2 - GRANT Create / Alter procedure (delete action not required)
ALTER AUTHORIZATION ON SCHEMA::[db_ddladmin] TO [ProcWriter]
--4. Database2 - Execute all procedure/functions
--auto granted with datawriter?
--5. Database2 - User should not alter the table structure.
--loop thru all tables to "DENY ALTER ON [dbo].[eachtable] TO [ProcWriter]"



Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #783019
Posted Saturday, September 5, 2009 2:49 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, August 1, 2013 2:51 AM
Points: 283, Visits: 312
I thank all of you for your help. I will try & let you know.

Rgds
Mohan Kumar VS
Post #783286
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse