3
I need help with a problem involving permissioning of objects in the database.
I have the following scenario:
1 Database
4 Schemes different with the following owners:
schemaA; proprietary dbo
schemaB; proprietary ownerX
schemaC; proprietary ownerX
schemaD; proprietary ownerX
I have a vision viewABC that is in schemaD and gathers information from tables and views of schemes schemaA, schemaB and schemaC.
A user userX will be allowed to SELECT
in viewABC.
To ensure such access ownerX uses:
GRANT SELECT ON schemaD.viewABC TO userX;
When userX tries to execute the SELECT
in the vision, so:
SELECT * FROM schemaD.viewABC;
We have the following error:
The SELECT permission has been denied in the 'table' object, database 'Mydatabase', schemaA schema'.
I understand that the error occurs because table is in a scheme where ownerX is not the owner and so the Sqlserver applies the permissions of userX to determine access. How userX does not have explicit access to tableA the execution of query returns the error.
If dbo give access to view, then the mistake will also happen by dbo not own the schemes schemaB and schemaC.
How to solve this without giving access to userX in table?
Remarks:
I believe this question relates to what you wish: (http://stackoverflow.com/q/4134740/2236741). The references you posted always involve more than one database, in which case you have only 1.
– cantoni
@Cantoni unfortunately not the case. If I change the view owner to dbo with
ALTER AUTHORIZATION ON schemaD.viewABC TO dbo
then the execution returns error because of schemaB and schemaC schema tables. And use the optionWITH GRANT OPTION
would only allow user userX to grant access to view to other users. Thanks for the help.– Emerson JS