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


Table level permission


Table level permission

Author
Message
Dana
Dana
SSCertifiable
SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)

Group: General Forum Members
Points: 5968 Visits: 3453
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.
Erland Sommarskog
Erland Sommarskog
SSCertifiable
SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)

Group: General Forum Members
Points: 5344 Visits: 875
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
Dana
Dana
SSCertifiable
SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)

Group: General Forum Members
Points: 5968 Visits: 3453
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. Hehe

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
Erland Sommarskog
Erland Sommarskog
SSCertifiable
SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)

Group: General Forum Members
Points: 5344 Visits: 875
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
Dana
Dana
SSCertifiable
SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)

Group: General Forum Members
Points: 5968 Visits: 3453
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).
Erland Sommarskog
Erland Sommarskog
SSCertifiable
SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)SSCertifiable (5.3K reputation)

Group: General Forum Members
Points: 5344 Visits: 875
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
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