문제

If I have the following view:

CREATE VIEW [dbo].[vw_Sample]
AS
    SELECT  T1.Column1, 
            T1.Column2,
            Table2.Column1, 
            Table2.Column2
    FROM dbo.Table1 T1
    JOIN dbo.Table2 T2 ON T2.Column3 = T1.Column3
GO

And I want to grant a user access to SELECT from that view; do I need to either:

A - Give that user SELECT permissions on just the view:

GRANT SELECT ON [dbo].[vw_Sample] TO [MyUser]

or

B - Give that user SELECT permissions on view and underlying tables:

GRANT SELECT ON [dbo].[Table1] TO [MyUser]
GRANT SELECT ON [dbo].[Table2] TO [MyUser]
GRANT SELECT ON [dbo].[vw_Sample] TO [MyUser]
도움이 되었습니까?

해결책

Just the View (A). Granting Select on the underlying tables will give them more access than they may need. The link below has some helpful info on ownership of the view\table and the affects it may have on your access.

Grant SELECT permission on a view, but not on underlying objects

다른 팁

B. Each object you created (view, procedure or function) will be execute under caller permissions. So, trying to select from underlying tables without necessary permissions will cause permission error. Or you may use EXECUTE AS/SET USER statements: please refer to TechNet article: http://technet.microsoft.com/en-au/library/ms188268(v=sql.105).aspx

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top