Re: Execute permission on xp_cmdshell

From: Andrés Taylor (andres@rotselleri.com)
Date: 07/18/02


From: "Andrés Taylor" <andres@rotselleri.com>
Date: Thu, 18 Jul 2002 13:15:25 +0200


Ron,

You'll have to set up the proxy account. You do this in T-SQL like this:

EXECUTE msdb.dbo.sp_set_sqlagent_properties @sysadmin_only = 0

EXEC master.dbo.xp_sqlagent_proxy_account N'SET',
             N'NETDOMAIN', -- agent_domain_name
             N'ralph', -- agent_username
             N'RalphPwd', – agent password

This is the account under which xp_cmdshell will run.

HTH,

--
Andrés Taylor
visit me @
http://www.sql.nu/
"Ron Broekhuizen" <ron_broekhuizen@hotmail.com> wrote in message
news:OBGPm#jLCHA.1740@tkmsftngp10...
> I've written a stored procedure that uses xp_cmdshell to export data to a
> textfile:
>
> CREATE Procedure dbo.usp_OutputToTextFile
> (
>  @SQL varchar(8000),
>  @FileName varchar(250)
> )
> as
> Declare @bcpCommand varchar(8000)
> SET @bcpCommand = 'bcp "' + @SQL + '" queryout '
> SET @bcpCommand = @bcpCommand + '"' + @FileName + '" -c -T '
> --print @bcpCommand
> execute master.dbo.xp_cmdshell @bcpCommand
> GO
>
> I've granted users permission to execute this Sproc. When these users try
to
> execute the Sproc they get a message that they have no permissions to
> execute the xp_cmdshell.
>
> I suspected xp_cmdshell would be executed with the permissions of the
> calling Procedure: dbo. But this is not the case. Why is that??
>
> I don't want to grant users permissions to the master-DB.
>
> Any ideas??
>
>
>
>


Relevant Pages

  • Re: Execute permission on xp_cmdshell
    ... I alwas get: "Error executing extended stored procedure: Specified user can ... > I've granted users permission to execute this Sproc. ...
    (microsoft.public.sqlserver.security)
  • Execute permission on xp_cmdshell
    ... Declare @bcpCommand varchar ... I've granted users permission to execute this Sproc. ...
    (microsoft.public.sqlserver.security)
  • Re: SQL Server Agent Proxy Account / XP_CMDSHELL
    ... The proxy account is unrelated to SQL Server object permissions. ... must have xp_cmdshell execute permissions when xp_cmdshell executed ... execute permissions on xp_cmdshell. ...
    (microsoft.public.sqlserver.security)
  • Re: xp_cmdshell default path (system32) problem
    ... I've used the proxy account several times before. ... SQL script that contains the xp_cmdShell is executed while logged in as 'sa' ... - specify the full path in the del command ... I'm use xp_cmdShell to execute "erase" command like ...
    (microsoft.public.sqlserver.programming)
  • Re: How can I grant user run cmdexec
    ... Unable to set the SQL Agent proxy account because of the reason listed ... > First you can give grant execute on xp_cmdshell (gtrant execute on ... >> grant the user have the rights to run this DTS but not ...
    (microsoft.public.sqlserver.security)

Quantcast