Grant select on view...

Sybase ASE 12.5

sample code:

sp_addlogin ahoor, password, dbase1

use dbase1
sp_adduser ahoor

create view vw_test
as
select * from dbase2..table1

grant select on vw_test to ahoor

-> login as ahoor
-> select * from vw_test
-> error: user ahoor is not a valid user in database dbase2.

I think this is strange. You create a view in a different database but to use it you still have to copy the users from database 1 to database 2? What is the purpose of creating a view if you still have to do that?
Or is there a way to use aliasses or whatever to get around this?
LVL 3
ahoorAsked:
Who is Participating?
 
grant300Connect With a Mentor Commented:
The view is really just a stored query.  If you run the Select statement in the view definition, you have to have privs on the underlying tables; regardless of what database they are in.  If that were not the case, a DBO from on one database could completely circumvent the access controls of any other database.

Another way to do this is to create the views in the database with the target tables as dbo, then the dbo only has to grant privs on the views.  I believe the view inherits the privs of the creator.

Regards,
Bill
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.