I'm trying to execute SSIS package from service broker activation procedure.
When SP is located in my database, I get following error:
"The current security context cannot be reverted. Please switch to the original database where 'Execute As' was called and try it again."
When the same SP is located in SSISDB, it works fine, but for consistency reasons I would prefer to have this procedure in my database.
To emulate this error we we can use following SP:
ALTER PROCEDURE [dbo].[ExecutePackage] WITH EXECUTE AS 'dbo' AS BEGIN DECLARE @execution_id BIGINT; EXEC [SSISDB].[catalog].[create_execution] @package_name=N'Loader_DynamicPool.dtsx', @execution_id=@execution_id OUTPUT, @folder_name=N'SSIS Concurent', @project_name=N'SSIS Concurent', @use32bitruntime=False, @reference_id=Null; DECLARE @var0 SMALLINT = 1; EXEC [SSISDB].[catalog].[set_execution_parameter_value] @execution_id, @object_type=50, @parameter_name=N'LOGGING_LEVEL', @parameter_value=@var0; exec [SSISDB].[catalog].[set_execution_parameter_value] @execution_id, @object_type=50, @parameter_name=N'SYNCHRONIZED', @parameter_value=1; EXEC [SSISDB].[catalog].[start_execution] @execution_id; END;
and then call:
EXEC [dbo].[ExecutePackage]
Works in SSISDB, fails in user database.