Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1183

Re: EXECUTE AS

From rollscanardly@att.net
Newsgroups comp.databases.ms-sqlserver
Subject Re: EXECUTE AS
Date 2012-07-26 15:52 -0700
Organization http://groups.google.com
Message-ID <106eb77d-821d-41d4-aa2a-e22f7643c225@googlegroups.com> (permalink)
References <f11aded3-5b85-4bbc-85cd-6e48ce852944@googlegroups.com> <XnsA09CEEAE6DFD1Yazorman@127.0.0.1>

Show all headers | View raw


On Thursday, July 26, 2012 5:27:47 PM UTC-4, Erland Sommarskog wrote:
> (rollscanardly@att.net) writes:
> &gt; I have a rather simple stored procedure for starting a batch 
> &gt; job in SQL Server 2008:
> &gt; 
> &gt; ALTER PROCEDURE [dbo].[BUGSTARTPOST] WITH EXECUTE AS OWNER 
> &gt; AS BEGIN
> &gt;      DECLARE @rc as int
> &gt;      SET NOCOUNT ON;
> &gt;      EXECUTE @rc=msdb.dbo.sp_start_job &#39;Budget Update&#39;
> &gt;      RETURN @rc
> &gt; END
> &gt; 
> &gt; where I am owner of the database containing the procedure and
> &gt; a have a sysadmin server role.  When a user, inlcuding me,
> &gt; with execute permission on this procedure, the result is a message
> &gt; that  EXECUTE permission was denied msdb.dbo.sp_start_job.  If I 
> &gt; execute the procedure without the WITH clause it runs for me.
> &gt; 
> &gt; How do I go about permitting a user to execute this stored procedure
> &gt; under my,or some other administrator&#39;s credetials so he or she can 
> &gt; run sp_start_job as controlled by this procedure?
>  
> I have an article on my web site that discusses why the approach
> above does not work, and which also includes two secure solutions for 
> this precise problem: http://www.sommarskog.se/grantperm.html
> 
> -- 
> Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
> 
> Links for SQL Server Books Online:
> SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
> SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

Thanks.  I haven't made it through it all, but can see  two workable alternatives already.

Fred.

Fred.

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Find similar


Thread

EXECUTE AS rollscanardly@att.net - 2012-07-26 12:54 -0700
  Re: EXECUTE AS Erland Sommarskog <esquel@sommarskog.se> - 2012-07-26 23:27 +0200
    Re: EXECUTE AS rollscanardly@att.net - 2012-07-26 15:52 -0700

csiph-web