Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 context of procedure call that results in trigger

Author  Topic 

BitShift
Yak Posting Veteran

98 Posts

Posted - 2008-05-08 : 10:44:15
If an application makes a connection under a given user, performs the following:
- calls a stored procedure which performs an insert,
- the insert causes a trigger to be fired
- the trigger causes a sql statement to execute against a different
database

Questions:
* Does the user who called the procedure, also need permissions to this 2nd database ?
* What security context does this trigger get executed ?


I have a stored procedure that is being called by my .Net application. The user account that makes the connection has execute permission to the procedure. However, the procedure does an insert which causes a trigger to fire. This trigger does a sql statement against a table in a different database, which the user who is calling the procedure, does not have permissions to access. Im getting an exception when I call the procedure, and it basically says there was a permission error with the user accessing this other database.

pootle_flump

1064 Posts

Posted - 2008-05-08 : 11:01:19
* Yes
* The context of the how the login used is mapped on the second server

Basically, granting permissions to a sproc allows all the included DML actions on tables within the same schema. OUtside of schema scope (let alone instance scope) and this no longer applies.
Go to Top of Page

pootle_flump

1064 Posts

Posted - 2008-05-08 : 11:02:35
You could look at EXECUTE AS syntax perhaps. You also might want to think hard before using it.
Go to Top of Page
   

- Advertisement -