current security context

  • I created a view in db1 database that points to tables in db2 database.

    However when I try to run a select against the view in db1 database I get following error:

    The server principal "usera" is not able to access the database "db2" under the current security context.

    Both db1 and db2 databases are on the same instance. usera doesnt have direct access to db2 database.

    Is there a way for usera to view the data in the view in db1 without granting direct access to db2 database.

    Thanks

  • sqlstar2011 (6/17/2015)


    I created a view in db1 database that points to tables in db2 database.

    However when I try to run a select against the view in db1 database I get following error:

    The server principal "usera" is not able to access the database "db2" under the current security context.

    Both db1 and db2 databases are on the same instance. usera doesnt have direct access to db2 database.

    Is there a way for usera to view the data in the view in db1 without granting direct access to db2 database.

    Thanks

    I would create a user in db2 for the same login as the user in db1. Then, grant select on the tables in db2 to the user you just created. The only permissions the user will have in db2 are the ones you grant it.

    You could use impersonation on a stored procedure, but that's not an option for a view.

  • If you have any doubt just come with college paper writing service reviews. Its a complete solution for you

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply