Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Service Broker Stored Procedure Can't Create Job


Service Broker Stored Procedure Can't Create Job

Author
Message
Stuart Pearson
Stuart Pearson
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 137
I have a service broker queue that is serviced by a stored procedure which calls another stored procedure to run an SSIS package.
This second procedure runs the SSIS package by creating a Job and running it (see Calling a SSIS Package from a Stored Procedure).

The problem I'm having is that when the queue is serviced I get an error saying that the user does not have execute permissions for the sp_add_job procedure.

The user running the process is in the SQLAgentOperator role in msdb

When running the second stored procedure directly (the one that creates the job) it works perfectly.
It's just when that procedure is run from the service broker procedure that it fails.

The code to set up the procedure to service the queue is
ALTER QUEUE ProcessUploadQueue
WITH ACTIVATION
( STATUS = ON,
PROCEDURE_NAME = Upload,
MAX_QUEUE_READERS = 1,
EXECUTE AS 'SPUser'
)
GO



Does anyone have any ideas what I might be doing wrong.

Thanks

Stuart
Nils Gustav Stråbø
Nils Gustav Stråbø
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2013 Visits: 3575
Is your service broker target queue in msdb? The user running the activation procedure will not be impersonated across databases, so if your service broker objects are in Database1, then the activation procedure cannot execute procedures in other databases (like msdb).

I found an article explaining this a little bit better :

http://www.databasejournal.com/features/mssql/article.php/3800181/Security-Context-of-Service-Broker-Internal-Activation.htm
Stuart Pearson
Stuart Pearson
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 137
Thanks Nils
The Service broker artefacts are NOT in the msdb they're in my database.

I've read the article you linked to and if I understand it right then setting my database to trustworthy and granting my user authentication rights to msdb should resolve the problem.

Unfortunately after doing this it is still not working.

Am I still missing something?

Stuart
Stuart Pearson
Stuart Pearson
Grasshopper
Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)Grasshopper (17 reputation)

Group: General Forum Members
Points: 17 Visits: 137
Sorted.
Needed to set the stored proc that serviced the queue to run as owner and made sure that owners was in the SQL Agent USer role in msdb and also had rights to run the stored procedure in msdb
Also had to digitally sign the stored procedure in my source database and use the certificate to create a user in msdb
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search