Skip to main content
added 5 characters in body; edited title
Source Link
marc_s
  • 9k
  • 6
  • 45
  • 52

SQL serverServer service broker related rights issue

CREATE PROCEDURE [dbo].[stproc_ssb_send]
  @iname varchar(20)
WITH EXECUTE AS 'xyz'
AS
BEGIN

DECLARE @DIALOG_HANDLE UNIQUEIDENTIFIER
DECLARE @MSG varchar(max) 

SET @MSG='<MESSAGE>
        <test>' + @iname + '</test>
        </MESSAGE>'

    BEGIN DIALOG CONVERSATION @DIALOG_HANDLE
    FROM SERVICE START_PROC_PROCESS_SERVICE
    TO SERVICE 'EXECUTE_PROC_PROCESS_SERVICE'
    ON CONTRACT [PROC_PROCESS_CONTRACT]
    WITH ENCRYPTION= OFF;

    SEND ON CONVERSATION @DIALOG_HANDLE
    MESSAGE TYPE PROC_PROCESS_MT(@MSG);

    END CONVERSATION @DIALOG_HANDLE
END

error:

Msg 15517, Level 16, State 1, Procedure [stproc_ssb_send], Line 0 

 Cannot execute as the database principal because the principal "xyz" does not exist, this type of principal cannot be impersonated, or you do not have permission.

XYZXYZ is db_ownerdb_owner /db_ddladmin db_ddladmin for this database.

Procedure is created using sa; error occurs while executing.

SQL server service broker related rights issue

CREATE PROCEDURE [dbo].[stproc_ssb_send]
  @iname varchar(20)
WITH EXECUTE AS 'xyz'
AS
BEGIN

DECLARE @DIALOG_HANDLE UNIQUEIDENTIFIER
DECLARE @MSG varchar(max) 

SET @MSG='<MESSAGE>
        <test>' + @iname + '</test>
        </MESSAGE>'

    BEGIN DIALOG CONVERSATION @DIALOG_HANDLE
    FROM SERVICE START_PROC_PROCESS_SERVICE
    TO SERVICE 'EXECUTE_PROC_PROCESS_SERVICE'
    ON CONTRACT [PROC_PROCESS_CONTRACT]
    WITH ENCRYPTION= OFF;

    SEND ON CONVERSATION @DIALOG_HANDLE
    MESSAGE TYPE PROC_PROCESS_MT(@MSG);

    END CONVERSATION @DIALOG_HANDLE
END

error:

Msg 15517, Level 16, State 1, Procedure [stproc_ssb_send], Line 0
 Cannot execute as the database principal because the principal "xyz" does not exist, this type of principal cannot be impersonated, or you do not have permission.

XYZ is db_owner/db_ddladmin for this database.

Procedure is created using sa; error occurs while executing.

SQL Server service broker related rights issue

CREATE PROCEDURE [dbo].[stproc_ssb_send]
  @iname varchar(20)
WITH EXECUTE AS 'xyz'
AS
BEGIN

DECLARE @DIALOG_HANDLE UNIQUEIDENTIFIER
DECLARE @MSG varchar(max) 

SET @MSG='<MESSAGE>
        <test>' + @iname + '</test>
        </MESSAGE>'

    BEGIN DIALOG CONVERSATION @DIALOG_HANDLE
    FROM SERVICE START_PROC_PROCESS_SERVICE
    TO SERVICE 'EXECUTE_PROC_PROCESS_SERVICE'
    ON CONTRACT [PROC_PROCESS_CONTRACT]
    WITH ENCRYPTION= OFF;

    SEND ON CONVERSATION @DIALOG_HANDLE
    MESSAGE TYPE PROC_PROCESS_MT(@MSG);

    END CONVERSATION @DIALOG_HANDLE
END

error:

Msg 15517, Level 16, State 1, Procedure [stproc_ssb_send], Line 0 
Cannot execute as the database principal because the principal "xyz" does not exist, this type of principal cannot be impersonated, or you do not have permission.

XYZ is db_owner / db_ddladmin for this database.

Procedure is created using sa; error occurs while executing.

added 7 characters in body
Source Link
Aaron Bertrand
  • 181.5k
  • 28
  • 402
  • 619
CREATE PROCEDURE [dbo].[stproc_ssb_send] 
 ( @iname varchar(20))
WITH EXECUTE AS 'xyz'
AS
BEGIN

DECLARE @DIALOG_HANDLE UNIQUEIDENTIFIER
DECLARE @MSG varchar(max) 

SET @MSG='<MESSAGE>
        <test>' + @iname + '</test>
        </MESSAGE>'

    BEGIN DIALOG CONVERSATION @DIALOG_HANDLE
    FROM SERVICE START_PROC_PROCESS_SERVICE
    TO SERVICE 'EXECUTE_PROC_PROCESS_SERVICE'
    ON CONTRACT [PROC_PROCESS_CONTRACT]
    WITH ENCRYPTION= OFF;

    SEND ON CONVERSATION @DIALOG_HANDLE
    MESSAGE TYPE PROC_PROCESS_MT(@MSG);

    END CONVERSATION @DIALOG_HANDLE
END

error:

Msg 15517, Level 16, State 1, Procedure [stproc_ssb_send], Line 0 Cannot execute as the database principal because the principal "xyz" does not exist, this type of principal cannot be impersonated, or you do not have permission.

Msg 15517, Level 16, State 1, Procedure [stproc_ssb_send], Line 0
Cannot execute as the database principal because the principal "xyz" does not exist, this type of principal cannot be impersonated, or you do not have permission.

XYZ is db_owner/db_ddladmin for this database.

ProcProcedure is created using "sa" & gettingsa; error occurs while exec the procexecuting.

CREATE PROCEDURE [dbo].[stproc_ssb_send] (@iname varchar(20))
WITH EXECUTE AS 'xyz'
AS
BEGIN

DECLARE @DIALOG_HANDLE UNIQUEIDENTIFIER
DECLARE @MSG varchar(max) 

SET @MSG='<MESSAGE>
        <test>' + @iname + '</test>
        </MESSAGE>'

    BEGIN DIALOG CONVERSATION @DIALOG_HANDLE
    FROM SERVICE START_PROC_PROCESS_SERVICE
    TO SERVICE 'EXECUTE_PROC_PROCESS_SERVICE'
    ON CONTRACT [PROC_PROCESS_CONTRACT]
    WITH ENCRYPTION= OFF;

    SEND ON CONVERSATION @DIALOG_HANDLE
    MESSAGE TYPE PROC_PROCESS_MT(@MSG);

    END CONVERSATION @DIALOG_HANDLE
END

error:

Msg 15517, Level 16, State 1, Procedure [stproc_ssb_send], Line 0 Cannot execute as the database principal because the principal "xyz" does not exist, this type of principal cannot be impersonated, or you do not have permission.

XYZ is db_owner/db_ddladmin for this database.

Proc created using "sa" & getting error while exec the proc

CREATE PROCEDURE [dbo].[stproc_ssb_send] 
  @iname varchar(20)
WITH EXECUTE AS 'xyz'
AS
BEGIN

DECLARE @DIALOG_HANDLE UNIQUEIDENTIFIER
DECLARE @MSG varchar(max) 

SET @MSG='<MESSAGE>
        <test>' + @iname + '</test>
        </MESSAGE>'

    BEGIN DIALOG CONVERSATION @DIALOG_HANDLE
    FROM SERVICE START_PROC_PROCESS_SERVICE
    TO SERVICE 'EXECUTE_PROC_PROCESS_SERVICE'
    ON CONTRACT [PROC_PROCESS_CONTRACT]
    WITH ENCRYPTION= OFF;

    SEND ON CONVERSATION @DIALOG_HANDLE
    MESSAGE TYPE PROC_PROCESS_MT(@MSG);

    END CONVERSATION @DIALOG_HANDLE
END

error:

Msg 15517, Level 16, State 1, Procedure [stproc_ssb_send], Line 0
Cannot execute as the database principal because the principal "xyz" does not exist, this type of principal cannot be impersonated, or you do not have permission.

XYZ is db_owner/db_ddladmin for this database.

Procedure is created using sa; error occurs while executing.

added 94 characters in body
Source Link
Remus Rusanu
  • 52k
  • 4
  • 95
  • 172

CREATE PROCEDURE [dbo].[stproc_ssb_send] (@iname varchar(20)) WITH EXECUTE AS 'xyz' AS BEGIN

DECLARE @DIALOG_HANDLE UNIQUEIDENTIFIER DECLARE @MSG varchar(max)

SET @MSG=' ' + @iname + ' '

CREATE PROCEDURE [dbo].[stproc_ssb_send] (@iname varchar(20))
WITH EXECUTE AS 'xyz'
AS
BEGIN

DECLARE @DIALOG_HANDLE UNIQUEIDENTIFIER
DECLARE @MSG varchar(max) 

SET @MSG='<MESSAGE>
        <test>' + @iname + '</test>
        </MESSAGE>'

    BEGIN DIALOG CONVERSATION @DIALOG_HANDLE
    FROM SERVICE START_PROC_PROCESS_SERVICE
    TO SERVICE 'EXECUTE_PROC_PROCESS_SERVICE'
    ON CONTRACT [PROC_PROCESS_CONTRACT]
    WITH ENCRYPTION= OFF;

    SEND ON CONVERSATION @DIALOG_HANDLE
    MESSAGE TYPE PROC_PROCESS_MT(@MSG);

    END CONVERSATION @DIALOG_HANDLE
END

END

error:

Msg 15517, Level 16, State 1, Procedure [stproc_ssb_send], Line 0 Cannot execute as the database principal because the principal "xyz" does not exist, this type of principal cannot be impersonated, or you do not have permission.

XYZ is db_owner/db_ddladmin for this database.

Proc created using "sa" & getting error while exec the proc

CREATE PROCEDURE [dbo].[stproc_ssb_send] (@iname varchar(20)) WITH EXECUTE AS 'xyz' AS BEGIN

DECLARE @DIALOG_HANDLE UNIQUEIDENTIFIER DECLARE @MSG varchar(max)

SET @MSG=' ' + @iname + ' '

BEGIN DIALOG CONVERSATION @DIALOG_HANDLE
FROM SERVICE START_PROC_PROCESS_SERVICE
TO SERVICE 'EXECUTE_PROC_PROCESS_SERVICE'
ON CONTRACT [PROC_PROCESS_CONTRACT]
WITH ENCRYPTION= OFF;

SEND ON CONVERSATION @DIALOG_HANDLE
MESSAGE TYPE PROC_PROCESS_MT(@MSG);

END CONVERSATION @DIALOG_HANDLE

END

error:

Msg 15517, Level 16, State 1, Procedure [stproc_ssb_send], Line 0 Cannot execute as the database principal because the principal "xyz" does not exist, this type of principal cannot be impersonated, or you do not have permission.

XYZ is db_owner/db_ddladmin for this database.

Proc created using "sa" & getting error while exec the proc

CREATE PROCEDURE [dbo].[stproc_ssb_send] (@iname varchar(20))
WITH EXECUTE AS 'xyz'
AS
BEGIN

DECLARE @DIALOG_HANDLE UNIQUEIDENTIFIER
DECLARE @MSG varchar(max) 

SET @MSG='<MESSAGE>
        <test>' + @iname + '</test>
        </MESSAGE>'

    BEGIN DIALOG CONVERSATION @DIALOG_HANDLE
    FROM SERVICE START_PROC_PROCESS_SERVICE
    TO SERVICE 'EXECUTE_PROC_PROCESS_SERVICE'
    ON CONTRACT [PROC_PROCESS_CONTRACT]
    WITH ENCRYPTION= OFF;

    SEND ON CONVERSATION @DIALOG_HANDLE
    MESSAGE TYPE PROC_PROCESS_MT(@MSG);

    END CONVERSATION @DIALOG_HANDLE
END

error:

Msg 15517, Level 16, State 1, Procedure [stproc_ssb_send], Line 0 Cannot execute as the database principal because the principal "xyz" does not exist, this type of principal cannot be impersonated, or you do not have permission.

XYZ is db_owner/db_ddladmin for this database.

Proc created using "sa" & getting error while exec the proc

Rollback to Revision 9
Source Link
Loading
Rollback to Revision 8
Source Link
Loading
Rollback to Revision 7
Source Link
Loading
Rollback to Revision 6
Source Link
Loading
Rollback to Revision 5
Source Link
Loading
Rollback to Revision 4
Source Link
Loading
Rollback to Revision 3
Source Link
Loading
improve formating, remove typo.
Source Link
Julien Vavasseur
  • 10.2k
  • 2
  • 28
  • 46
Loading
Rollback to Revision 1
Source Link
Loading
added 44 characters in body
Source Link
Philᵀᴹ
  • 31.9k
  • 10
  • 84
  • 108
Loading
Source Link
Loading