Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Posts
    12

    Unanswered: Executing xp_cmdshell

    Hi,
    I'm trying to execute xp_cmdshell in SQL-2008 by sql user ‘Checker’.

    I’ve set sp_configure ‘xp_cmdshell’ to 1 and granted execute xp_cmdshell permissions to this user, but still getting error: 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.

    Online I found that I have to create a proxy credential like:
    EXEC sp_xp_cmdshell_proxy_account ‘domain\checker, 'password'

    The problem is that the last command is for OS user account only, and not for SQL login.
    Is there a way to grant permissions to execute xp_cmdshell to SQL login?

    Thanks

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    GRANT exec ON xp_cmdshell TO SQLLogin
    ??
    George
    Home | Blog

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Better yet, the EXECUTE AS clause can be used for this very task; EXECUTE AS Clause (Transact-SQL)

    Wrap your xp_cmdshell actions in to sprocs. This will allow you greater security and control over what commands can be run
    George
    Home | Blog

  4. #4
    Join Date
    Feb 2004
    Posts
    12
    Thank you George. This is exactly what I needed - EXECUTE AS. It worked perfectly!

  5. #5
    Join Date
    Nov 2004
    Posts
    1,427
    Provided Answers: 4
    Arka, can you show the code on how you did it using EXECUTE AS?
    With kind regards . . . . . SQL Server 2000/2005/2012
    Wim

    Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
    Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •