Does SQL Server Express support the use of a Windows proxy account for xp_cmdshell?

David MG 1 Reputation point
2021-04-20T15:47:26.583+00:00

I am attempting to use xp_cmdshell using a proxy user, however even when configuring this user using sp_xp_cmdshell_proxy_account I see this error:
Msg 15137, Level 16, State 1, Procedure sp_xp_cmdshell_proxy_account, Line 1
An error occurred during the execution of sp_xp_cmdshell_proxy_account. Possible reasons: the provided account was invalid or the '##xp_cmdshell_proxy_account##' credential could not be created. Error code: 0(null), Error Status: 0.

When looking at the server properties to see the proxy account specified it is showing it there, but when I run exec xp_cmdshell 'whoami.exe'; it always shows:
nt service\mssql$sqlexpress

This leads me to believe that SQL Server Express does not support a proxy user. I cannot find anything online about this but it seems to be the case. Can someone please confirm this for me or perhaps offer a workaround?

I am using:
Microsoft SQL Server 2016 (SP1-GDR) (KB4505219) - 13.0.4259.0 (X64) Jun 15 2019 19:20:12 Copyright (c) Microsoft Corporation Express Edition (64-bit) on Windows Server 2012 R2 Standard 6.3 <X64> (Build 9600: )

Thank you,

David

SQL Server Other
{count} votes

3 answers

Sort by: Most helpful
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2021-04-20T22:00:12.2+00:00

    I don't have an Express Edition handy to test on. Then again, when I try on Developer Edition that fails too...

    There is no reason why it would fail on Express Edition just because it is Express. But there can be many reasons why things can fail. I know, because I got different error messages when I tried. You get Error code 0 which is strange.

    I observe one thing though: you are way behind on the version. You should download and install Service Pack 2, and then apply the most recent Cumulative Update, which I think is CU17. Not that this is likely to resolve this particular issue. But I always point out when people are too far behind on the SP/CU level.

    0 comments No comments

  2. David Browne - msft 3,851 Reputation points
    2021-04-20T22:08:24.85+00:00

    Not sure, but when you configure the proxy account from SSMS it creates the credential directly, so you might try that. EG this is the action that configuring a proxy account in SSMS scripts:

    USE [master]
    GO
    CREATE CREDENTIAL [##xp_cmdshell_proxy_account##] WITH IDENTITY = N'theserver\cmdshell', SECRET = N'xxxxxxxx'
    GO
    
    0 comments No comments

  3. CathyJi-MSFT 22,396 Reputation points Microsoft External Staff
    2021-04-21T07:20:51.033+00:00

    Hi @David MG ,

    >Does SQL Server Express support the use of a Windows proxy account for xp_cmdshell?

    Yes. I test this in my environment. I have SQL 2017 Express. Please run the SSMS as administrator.

    89815-screenshot-2021-04-21-152028.jpg

    Refer to the blog Creating a SQL Server proxy account to run xp_cmdshell


    If the response is helpful, please click "Accept Answer" and upvote it, thank you.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.