Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
dbradish
Starting Member
24 Posts |
Posted - 2011-10-22 : 15:32:08
|
Question: How do I allow CREATE rights on "Schema A" but deny CREATE rights on "Schema B"?Additional Information:On "Schema A" owned by dbo, the user should have all rights on all schema A bound objects (insert, update, delete, create, alter, drop)On "Schema B" owned by dbo, the user should only be able to Insert, Update and Delete data rows. They should not be able to alter, drop or create schema B bound objects.Current Setup: Server Level Role: public Database Level Roles: db_backupoperator (user must be able to backup DB) db_ddladmin (user must be able to create, alter, drop objects on Schema A) db_datawriter (user must be able to insert/update/delete rows in all schemas) db_datareader (user must be able to select from all schemas) Schema A Permissions: all Schema B Permissions: DENY alter, references, & take ownership GRANT delete, execute, insert, select, & updateIf I DENY control on Schema B, my user cannot CREATE objects, but neither can they INSERT, UPDATE or DELETE data.Please advise."Challenge me. I will not give up. I will not succumb to any situation. I will not be afraid to be great." ~ D. M. Abrashoff |
|
Sachin.Nand
2937 Posts |
Posted - 2011-10-23 : 08:40:29
|
Not sure what are you doing wrong.Its working for me.Please try the code belowCreate User Usr without LoginGoCreate schema A authorization dboGoCreate schema B authorization dboGoGrant Create Table To usrGoGrant Control on Schema:: A to usrGoDeny Alter on Schema:: B to usrGoGrant Insert,Update,Delete on Schema ::B to usrGo--The block below will create and drop a table under schema AExecute As User = 'Usr'GoCreate Table A.t (id INT)Insert Into A.tSelect 1Drop Table A.tRevertGo--The following block will error out as User 'usr' does not have permission to create a object under schema BExecute As User = 'Usr'GoCreate Table B.t (id INT)GoRevertGo-- This will create a table under schema B using the original login contextCreate Table B.t (id INT)Go--The following block will insert a value of 1 in table under schema B using user 'usr' context who has the rights for inserts for objects of schema BExecute As User = 'Usr'GoInsert Into B.tSelect 1RevertGoSelect * From B.t PBUH |
 |
|
|
|
|
|
|