Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restrict a user to access objects of only one schema in SQL Server 2008?

I want to restrict a user to only one schema and to only Select privilege in that schema in SQL Server 2008.

like image 770
Rohit Avatar asked Sep 02 '11 13:09

Rohit


People also ask

How do I give access to a specific schema in SQL Server?

The U1 user has the CREATE VIEW permission on the database and the SELECT permission on the S1 schema. Therefore, the U1 user can create a view in the S1 schema to query data from the denied object T1, and then access the denied object T1 by using the view.

How do you grant permission to a schema?

Only an authorization ID with ACCESSCTRL or SECADM can grant the following privileges on schema names starting with SYS: SELECTIN privilege on SYSCAT, SYSFUN, SYSSTAT or any schema names starting with SYSIBM (SQLSTATE 42501). SELECTIN, CREATEIN and DROPIN privileges on SYSPROC, SYSPUBLIC or SYSTOOLS schemas.

What is schema separation?

User-schema separation allows for more flexibility in managing database object permissions. A schema is a named container for database objects, which allows you to group objects into separate namespaces.

How do I restrict access to SQL database?

You can restrict access to data at the following levels: You can use the GRANT and REVOKE statements to give or deny access to the database or to specific tables, and you can control the kinds of uses that people can make of the database.


1 Answers

A combination of DENYs and a GRANT. For example:

DENY SELECT ON schema::[dbo] TO [user_name]
DENY SELECT ON schema::[other_schema] TO [user_name]
GRANT SELECT ON schema::[safe_schema] TO [user_name]
like image 145
Ben Thul Avatar answered Oct 26 '22 15:10

Ben Thul