I have a SP, which calls
xp_cmdshell
in it. This SP is being used in a MessageQueue.The SQL server and Agent services are configured using a Domain service account, and this service account has a login under the sysadmin server role as well.
When the MessageQueue is invoked, the SP returns the following exception :
The xp_cmdshell proxy account information cannot be retrieved or is
invalid. Verify that the ‘##xp_cmdshell_proxy_account##’ credential
exists and contains valid information.But when I execute the SP in SSSMS, under the service account login (which is a sysadmin), it successfully executes.
I even created the
##xp_cmdshell_proxy_account##
credential, but the Message Queue never stops giving this error.This is how the queue looks like :
CREATE QUEUE [dbo].[TestxmCmdshellQueue] WITH STATUS = ON , RETENTION = OFF , ACTIVATION ( STATUS = ON , PROCEDURE_NAME = [dbo].[SpWithxp_cmdshell_Init] , MAX_QUEUE_READERS = 5 , EXECUTE AS N'dbo' ), POISON_MESSAGE_HANDLING (STATUS = OFF)
The Service account is configured as a Local Administrator in the Local Server as well.
The Database owner is “Sa”
I am running SQL Server 2008 R2 Sp2 on a Windows Server 2008 R2 Enterprise Machine.
Answer
I Made TRUSTWORTHY = ON in the database and the SP executed without any problem by the Message Queue.
Thanks !!
Attribution
Source : Link , Question Author : user120612 , Answer Author : user120612