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

Table level permission Expand / Collapse
Author
Message
Posted Wednesday, June 25, 2014 11:57 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Yesterday @ 11:58 AM
Points: 229, Visits: 779
Hello,
I would like to give read/write permission to a handful of tables in a database. Do I just use something like:
USE MyDatabase;
GO
GRANT DELETE ON MyTable1 TO WindowsGroup;
GO
GRANT INSERT ON MyTable2 TO WindowsGroup;
GO
...

Notice that they do not need UPDATE.

I can create a login on the instance and give r/w to the database but that is more than I really want to give, as there are tables they should not touch. Not that they would know how to access any of the tables, but why leave it open.

Questions:
1) Do I leave the instance logins or do I change them?
2) If I change the instance logins what would the change be?
3) Do I GRANT the privilege as above for each table?
4) What about execute of stored procedure? - This is most likely not needed.

The data is coming from a stored procedure from a different server/instance of SQL server. I tried EXECUTE AS but was unsuccessful, with the message saying the login did not exist or did not have permissions. I need to look into this but needed a quick fix for now.
Post #1586033
Posted Wednesday, June 25, 2014 1:06 PM This worked for the OP Answer marked as solution


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Monday, August 18, 2014 3:19 PM
Points: 800, Visits: 713
If I understand this correctly, you have one instance A where some stored procedure inserts and deletes rows in a database on instance B by means of direct INSERT and DELETE statements with four-part notation. Now you are looking to how to solve the permissions on server B.

Seen from the perspective of server B, this scenario is no different from the users connecting directly from SSMS to run INSERT and DELETE statements. (Unless you set up a login-mapping on server A, but this has other issues.)

It is difficult to answer the questions what you should do with the instance logins, because I don't understand what the problem might be. But then again, I don't know your site. However, the paragraph above may give a clue: this is the same as direct access from SSMS or whatever.

You should of course not grant access directly to users, but to an SQL Server Role or a Windows group, but you seem to have grasped that already.

The GRANT statements would be those you listed, and you are right in granting minimal amount of permissions.

For the question about stored procedures, I am again puzzled why you ask. Is something more hiding here?


Erland Sommarskog, SQL Server MVP, www.sommarskog.se
Post #1586068
Posted Thursday, June 26, 2014 4:58 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Yesterday @ 11:58 AM
Points: 229, Visits: 779
Erland Sommarskog (6/25/2014)
If I understand this correctly, you have one instance A where some stored procedure inserts and deletes rows in a database on instance B by means of direct INSERT and DELETE statements with four-part notation. Now you are looking to how to solve the permissions on server B.

Seen from the perspective of server B, this scenario is no different from the users connecting directly from SSMS to run INSERT and DELETE statements. (Unless you set up a login-mapping on server A, but this has other issues.)

It is difficult to answer the questions what you should do with the instance logins, because I don't understand what the problem might be. But then again, I don't know your site. However, the paragraph above may give a clue: this is the same as direct access from SSMS or whatever.

You should of course not grant access directly to users, but to an SQL Server Role or a Windows group, but you seem to have grasped that already.

The GRANT statements would be those you listed, and you are right in granting minimal amount of permissions.

For the question about stored procedures, I am again puzzled why you ask. Is something more hiding here?
Thank you for the reply.
The stored procedure is not really a problem just me thinking about possible problems while writing without thinking about it.

For the main instance DB1 the user has permission through group wingroup1. On the second instance DB2 (which is called using the four-part notation) they had no permissions so I temporarily gave wingroup1 permission to the database. I will be taking that away today and giving the group GRANT permissions as suggested.

I seem to muddle though security and get confused when reading anything written by Microsoft on the subject. I find forums help there or maybe a good white paper. Since we do not need to adjust security very often, I do not work with it enough to remember all the ins and outs.

Thanks again,
djj
Post #1586355
Posted Thursday, June 26, 2014 1:28 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Monday, August 18, 2014 3:19 PM
Points: 800, Visits: 713
For the main instance DB1 the user has permission through group wingroup1. On the second instance DB2 (which is called using the four-part notation) they had no permissions so I temporarily gave wingroup1 permission to the database. I will be taking that away today and giving the group GRANT permissions as suggested.


Eh, they must of course be able to connect to the database. I don't know exactly what you mean with "gave permssion", but if you said "CREATE USER [Domain\Wingroup1]" you should not back out that.


Erland Sommarskog, SQL Server MVP, www.sommarskog.se
Post #1586636
Posted Thursday, June 26, 2014 1:34 PM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Yesterday @ 11:58 AM
Points: 229, Visits: 779
Erland Sommarskog (6/26/2014)
Eh, they must of course be able to connect to the database. I don't know exactly what you mean with "gave permssion", but if you said "CREATE USER [Domain\Wingroup1]" you should not back out that.


By gave permission I went to DB2\Security\Logins and right clicked choosing New Login...
After selecting the group I then went to "User Mapping"
For the database I checked Map then checked db_datareader and db_datawriter permission (leaving public).
Post #1586639
Posted Thursday, June 26, 2014 1:57 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Monday, August 18, 2014 3:19 PM
Points: 800, Visits: 713
You should keep the login and the group as a user. But you should drop the group from db_datawriter and db_datareader.

Which version (including service pack) does this server have?


Erland Sommarskog, SQL Server MVP, www.sommarskog.se
Post #1586645
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse