SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Creating Logins


Creating Logins

Author
Message
Mohan Kumar VS
Mohan Kumar VS
Old Hand
Old Hand (396 reputation)Old Hand (396 reputation)Old Hand (396 reputation)Old Hand (396 reputation)Old Hand (396 reputation)Old Hand (396 reputation)Old Hand (396 reputation)Old Hand (396 reputation)

Group: General Forum Members
Points: 396 Visits: 344
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
Silverfox
Silverfox
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4184 Visits: 1161
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
Steve Jones
Steve Jones
SSC Guru
SSC Guru (84K reputation)SSC Guru (84K reputation)SSC Guru (84K reputation)SSC Guru (84K reputation)SSC Guru (84K reputation)SSC Guru (84K reputation)SSC Guru (84K reputation)SSC Guru (84K reputation)

Group: Administrators
Points: 84458 Visits: 19224
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
My Blog: www.voiceofthedba.com
Lowell
Lowell
SSC-Dedicated
SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)SSC-Dedicated (37K reputation)

Group: General Forum Members
Points: 37075 Visits: 40280
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

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Mohan Kumar VS
Mohan Kumar VS
Old Hand
Old Hand (396 reputation)Old Hand (396 reputation)Old Hand (396 reputation)Old Hand (396 reputation)Old Hand (396 reputation)Old Hand (396 reputation)Old Hand (396 reputation)Old Hand (396 reputation)

Group: General Forum Members
Points: 396 Visits: 344
I thank all of you for your help. I will try & let you know.

Rgds
Mohan Kumar VS
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search