<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Strate SQL &#187; Security</title>
	<atom:link href="http://www.jasonstrate.com/index.php/category/security/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jasonstrate.com</link>
	<description>Questions, answers, opinions and scripts from a SQL Server DBA</description>
	<lastBuildDate>Tue, 31 Aug 2010 02:56:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Getting Rid of a Certificate</title>
		<link>http://www.jasonstrate.com/index.php/2010/03/getting-rid-of-a-certificate/</link>
		<comments>http://www.jasonstrate.com/index.php/2010/03/getting-rid-of-a-certificate/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 11:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQLServerSyndication]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/index.php/2010/03/getting-rid-of-a-certificate/</guid>
		<description><![CDATA[A couple days ago I was playing around with some Event Notifications and the Certificate that I’d created for them on my development machine.  Low and behold I’d made a classic mistake and forgotten to write down the password for the certificate.  Thus I was left without a critical component necessary for signing my procedures.  [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/12/does-your-stored-procedure-grant-itself-permissions/' rel='bookmark' title='Permanent Link: Does Your Stored Procedure Grant Itself Permissions?'>Does Your Stored Procedure Grant Itself Permissions?</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2008/06/transfer-logins-between-sql-server-2005-instances/' rel='bookmark' title='Permanent Link: Transfer Logins Between SQL Server 2005 Instances'>Transfer Logins Between SQL Server 2005 Instances</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/04/filesystemhelper-sql-server-clr-codeplex/' rel='bookmark' title='Permanent Link: FileSystemHelper SQL Server CLR &#8211; Codeplex'>FileSystemHelper SQL Server CLR &#8211; Codeplex</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F03%2Fgetting-rid-of-a-certificate%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2010%2F03%2Fgetting-rid-of-a-certificate%2F" height="61" width="51" /></a></div><p><a title="The Key to My Mind (11/12)" href="http://www.flickr.com/photos/22714323@N06/4040997860/"><img style="display: inline; margin-left: 0px; margin-right: 0px;" src="http://static.flickr.com/2439/4040997860_1cefc9649b.jpg" border="0" alt="The Key to My Mind (11/12)" width="136" height="111" align="right" /></a>A couple days ago I was playing around with some <a href="http://www.sqlservercentral.com/articles/Event+Notifications/68831/" target="_blank">Event Notifications</a> and the Certificate that I’d created for them on my development machine.  Low and behold I’d made a classic mistake and forgotten to write down the password for the certificate.  Thus I was left without a critical component necessary for signing my procedures.  Since this really wouldn’t do, I opted to drop the certificate from the server.</p>
<p>Now this shouldn’t be such a problem a siimple DROP CERTIFICATE statement and I should be good to go.  The statement I used look just like this:</p>
<pre class="brush: sql; ">
 IF EXISTS(SELECT * FROM sys.certificates WHERE name = ‘MyCertificate’)
    DROP CERTIFICATE [MyCertificate]
GO
</pre>
<h4>Yup, Didn’t Work</h4>
<p>There wouldn’t be much of a point to this if this worked as intended.  So here’s the rub, the statement ended up generating the following error:</p>
<blockquote><p><span style="color: #ff0000;">Msg 15352, Level 16, State 1, Line 1<br />
The certificate cannot be dropped because one or more entities are either signed or encrypted using it.</span></p></blockquote>
<p>Backing up a bit, the reason that I created this certificate is that I’ve been using it to sign stored procedures.  I was doing that so that the procedure can execute under that a login that has the permissions I want rather that just opening a big security hole in my development machine.</p>
<h4>What’s Signed By Your Certificate</h4>
<p>To find out what’s signed by the certificate, you can use the <a href="http://msdn.microsoft.com/en-us/library/ms189774.aspx" target="_blank">sys.certificates</a> and the <a href="http://msdn.microsoft.com/en-us/library/ms189536.aspx" target="_blank">sys.crypt_properties</a> system views.  The query I use for this is below:</p>
<pre class="brush: sql; ">
SELECT OBJECT_SCHEMA_NAME(co.major_id) + &#039;.&#039; + OBJECT_NAME(co.major_id)
FROM sys.certificates c
    INNER JOIN sys.crypt_properties co ON c.thumbprint = co.thumbprint
WHERE co.crypt_type_desc = &#039;SIGNATURE BY CERTIFICATE&#039;
AND c.name = &#039;MyCertificate&#039;
</pre>
<p>Hopefully, you won’t forget your certificate password like I did.  But you may need to remove a certificate from one of your systems some time and hopefully this get you passed that irritating error above.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/12/does-your-stored-procedure-grant-itself-permissions/' rel='bookmark' title='Permanent Link: Does Your Stored Procedure Grant Itself Permissions?'>Does Your Stored Procedure Grant Itself Permissions?</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2008/06/transfer-logins-between-sql-server-2005-instances/' rel='bookmark' title='Permanent Link: Transfer Logins Between SQL Server 2005 Instances'>Transfer Logins Between SQL Server 2005 Instances</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/04/filesystemhelper-sql-server-clr-codeplex/' rel='bookmark' title='Permanent Link: FileSystemHelper SQL Server CLR &#8211; Codeplex'>FileSystemHelper SQL Server CLR &#8211; Codeplex</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2010/03/getting-rid-of-a-certificate/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Does Your Stored Procedure Grant Itself Permissions?</title>
		<link>http://www.jasonstrate.com/index.php/2009/12/does-your-stored-procedure-grant-itself-permissions/</link>
		<comments>http://www.jasonstrate.com/index.php/2009/12/does-your-stored-procedure-grant-itself-permissions/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 13:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[DBA]]></category>
		<category><![CDATA[Deadlocks]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQLServerSyndication]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[T-SQL]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/index.php/2009/12/does-your-stored-procedure-grant-itself-permissions/</guid>
		<description><![CDATA[ It’s a very good question. One that might not seem to insidious. Nothing that should be able to bring down the system and cause failures. Or will it?
I’ve been to a number of clients and done it myself before where I start to check out a stored procedure with some performance issues and sitting [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/01/scripting-object-level-permissions/' rel='bookmark' title='Permanent Link: Scripting Object Level Permissions'>Scripting Object Level Permissions</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2006/05/room-with-a-view/' rel='bookmark' title='Permanent Link: Room with a View'>Room with a View</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/06/index-those-foreign-keys/' rel='bookmark' title='Permanent Link: Index Those Foreign Keys'>Index Those Foreign Keys</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F12%2Fdoes-your-stored-procedure-grant-itself-permissions%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F12%2Fdoes-your-stored-procedure-grant-itself-permissions%2F" height="61" width="51" /></a></div><p><a href="http://www.jasonstrate.com/images/DoesYourStoredProcedureGrantItselfPermis_DEA/hamsterwheel.jpg"><img style="border-bottom: 0px; border-left: 0px; margin: 0px; display: inline; border-top: 0px; border-right: 0px" title="hamster-wheel" border="0" alt="hamster-wheel" align="right" src="http://www.jasonstrate.com/images/DoesYourStoredProcedureGrantItselfPermis_DEA/hamsterwheel_thumb.jpg" width="109" height="159" /></a> It’s a very good question. One that might not seem to insidious. Nothing that should be able to bring down the system and cause failures. Or will it?</p>
<p>I’ve been to a number of clients and done it myself before where I start to check out a stored procedure with some performance issues and sitting all pretty at the bottom is a GRANT EXEC statement. When I script out the stored procedure I get something similar to the following:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">PROCEDURE</span> dbo.FooGetTableA</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    (</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    @<span style="color: #0000ff">Parameter</span> <span style="color: #0000ff">varchar</span>(4)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">AS</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">SELECT</span> Column1 </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">FROM</span> dbo.TableA</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">WHERE</span> Column2 = @<span style="color: #0000ff">Parameter</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">GRANT</span> <span style="color: #0000ff">EXEC</span> <span style="color: #0000ff">ON</span> dbo.FooGetTableA <span style="color: #0000ff">TO</span> ApplicationRole</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">GO</pre>
<p><!--CRLF--></div>
</div>
<p>But if you look carefully, there is something missing, or one could say included that shouldn’t be.&#160; Look again if you don’t see it. It’s hidden in plain sight.&#160; The permissions for the procedure are included in the body of the stored procedure.&#160; When the procedure was written, someone thought ahead to add permissions to the script but forgot the GO statement between the stored procedure </p>
<p>In a better world this script would have looked like this:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">PROCEDURE</span> dbo.FooGetTableA</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    (</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    @<span style="color: #0000ff">Parameter</span> <span style="color: #0000ff">varchar</span>(4)</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    )</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">AS</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">SELECT</span> Column1 </pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">FROM</span> dbo.TableA</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">WHERE</span> Column2 = @<span style="color: #0000ff">Parameter</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">GO</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">GRANT</span> <span style="color: #0000ff">EXEC</span> <span style="color: #0000ff">ON</span> dbo.FooGetTableA <span style="color: #0000ff">TO</span> ApplicationRole</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">GO</pre>
<p><!--CRLF--></div>
</div>
<h4>It’s Just a Permission Statement</h4>
<p>Who cares, right?&#160; So you are assigning some permissions every time that procedure executes.&#160; What harm could possibly come of it.&#160; I’ve seen this so many times and usually it’s one of things I’ll point out and say, “oops, you should take care of that”.&#160; When I should be saying, “yeah, fellas.&#160; You’ve got a time bomb there waiting for your business to take off.”</p>
<p>And the time bomb is deadlocks.&#160; Completely preventable deadlocks.</p>
<p>If you have procedures that grant themselves permissions, then as the volume of activity in your database increases you may start to see deadlock graphs similar to the following:</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">deadlock-list deadlock victim=process30108bac8  process-list   process id=processec55dd68 taskpriority=0 logused=0 waitresource=METADATA: database_id = 10 PERMISSIONS(<span style="color: #0000ff">class</span> = 1, major_id = 219199881) waittime=15000 ownerId=746424569 transactionname=<span style="color: #0000ff">Load</span> Permission <span style="color: #0000ff">Object</span> Cache lasttranstarted=2009-10-22T23:06:59.287 XDES=0x3712a8e98 lockMode=Sch-S schedulerid=1 kpid=5832 status=suspended spid=157 sbid=2 ecid=0 priority=0 transcount=1 lastbatchstarted=2009-10-22T23:06:59.287 lastbatchcompleted=2009-10-22T23:06:59.280 clientapp=.Net SqlClient <span style="color: #0000ff">Data</span> Provider hostname=PRDWB0111 hostpid=5640 loginname=portaluser isolationlevel=serializable (4) xactid=746424394 currentdb=10 lockTimeout=4294967295 clientoption1=671088672 clientoption2=128056    executionStack     frame procname=AdventureWorks2008.dbo.FooGetTableA line=1 sqlhandle=0x03000a0089b9100d0e527800669c00000100000000000000<span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">PROCEDURE</span> dbo.FooGetTableA    (    @<span style="color: #0000ff">Parameter</span> <span style="color: #0000ff">varchar</span>(4)    )<span style="color: #0000ff">AS</span>

<span style="color: #0000ff">SELECT</span> Column1 <span style="color: #0000ff">FROM</span> dbo.TableA<span style="color: #0000ff">WHERE</span> Column2 = @<span style="color: #0000ff">Parameter</span>

<span style="color: #0000ff">GRANT</span> <span style="color: #0000ff">EXEC</span> <span style="color: #0000ff">ON</span> dbo.FooGetTableA <span style="color: #0000ff">TO</span> ApplicationRole    inputbuf<span style="color: #0000ff">Proc</span> [<span style="color: #0000ff">Database</span> Id = 10 <span style="color: #0000ff">Object</span> Id = 219199881]       process id=process30108bac8 taskpriority=0 logused=0 waitresource=METADATA: database_id = 10 PERMISSIONS(<span style="color: #0000ff">class</span> = 1, major_id = 1746157316) waittime=2125 ownerId=746479249 transactionname=<span style="color: #0000ff">Load</span> Permission <span style="color: #0000ff">Object</span> Cache lasttranstarted=2009-10-22T23:07:12.180 XDES=0x3786c61c8 lockMode=Sch-S schedulerid=3 kpid=4048 status=suspended spid=69 sbid=2 ecid=0 priority=0 transcount=1 lastbatchstarted=2009-10-22T23:07:12.180 lastbatchcompleted=2009-10-22T23:07:12.167 clientapp=.Net SqlClient <span style="color: #0000ff">Data</span> Provider hostname=AMBER hostpid=568 loginname=portaluser isolationlevel=serializable (4) xactid=746372404 currentdb=10 lockTimeout=4294967295 clientoption1=671088672 clientoption2=128056    executionStack     frame procname=AdventureWorks2008.dbo.FooGetTableB line=1 sqlhandle=0x03000a00043f146882564201a09b00000100000000000000<span style="color: #0000ff">CREATE</span> <span style="color: #0000ff">PROCEDURE</span> dbo.FooGetTableB    (    @<span style="color: #0000ff">Parameter</span> <span style="color: #0000ff">varchar</span>(4)    )<span style="color: #0000ff">AS</span>

<span style="color: #0000ff">SELECT</span> Column1 <span style="color: #0000ff">FROM</span> dbo.TableB<span style="color: #0000ff">WHERE</span> Column2 = @<span style="color: #0000ff">Parameter</span>

<span style="color: #0000ff">GRANT</span> <span style="color: #0000ff">EXEC</span> <span style="color: #0000ff">ON</span> dbo.FooGetTableB <span style="color: #0000ff">TO</span> ApplicationRole    inputbuf<span style="color: #0000ff">Proc</span> [<span style="color: #0000ff">Database</span> Id = 10 <span style="color: #0000ff">Object</span> Id = 1746157316]      resource-list   metadatalock subresource=PERMISSIONS classid=<span style="color: #0000ff">class</span> = 1, major_id = 219199881 dbid=10 id=lock4153ec880 mode=Sch-M    owner-list     owner id=process30108bac8 mode=Sch-M    waiter-list     waiter id=processec55dd68 mode=Sch-S requestType=wait   metadatalock subresource=PERMISSIONS classid=<span style="color: #0000ff">class</span> = 1, major_id = 1746157316 dbid=10 id=lock415451780 mode=Sch-M    owner-list     owner id=processec55dd68 mode=Sch-M    waiter-list     waiter id=process30108bac8 mode=Sch-S requestType=wait</pre>
<p></div>
<h4>Breaking It Down</h4>
<p>When I first started looking at these there are a few things I noted right away:</p>
<ol>
<li>The procedures were access completely different tables with no common objects between them.&#160; In the sample above there is TableA and TableB and no relationship.</li>
<li>Looking at each of the processes in the deadlock both of them have the following attributes</li>
<ol>
<li>waitresource=METADATA: database_id = 10 PERMISSIONS</li>
<li>transactionname=Load Permission Object Cache</li>
</ol>
</ol>
<p>So nothing in common and a deadlock on a metadata resource for permissions.&#160; This made me start to re-think how the two procedures were related.&#160; With a metadata resource wait, there seems to be an issue above the data in the table.&#160; Since both procedures point to the Load Permission Object Cache, maybe there is an issue there.</p>
<p>If you take a look, each of the procedures has a GRANT EXEC permission statement in it.&#160; This is the area of commonality and where the two executions deadlocked.&#160; Removing the GRANT EXEC permissions statements stop this deadlock from occurring.</p>
<p>After going through and removing these permission statements from a number of procedures that had this issue, all of the deadlocks with these types of issues disappeared.&#160; And it is smooth sailing once again.</p>
<h4>Cautionary Tale</h4>
<p>Hopefully this is a scenario that only I’ve run into.&#160; But if it’s not then this should serve as a reminder that little details that seem like a little non-issue, could be the crack that breaks the damn when there’s enough water behind it.&#160; The thing that gets you on this issue is that it isn’t until execution start to really grow before it pops out and it will only hit when you’re the busiest.&#160; This is something I’ll be keeping an eye out for in the future and I’d recommend the same for others as well.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/01/scripting-object-level-permissions/' rel='bookmark' title='Permanent Link: Scripting Object Level Permissions'>Scripting Object Level Permissions</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2006/05/room-with-a-view/' rel='bookmark' title='Permanent Link: Room with a View'>Room with a View</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2010/06/index-those-foreign-keys/' rel='bookmark' title='Permanent Link: Index Those Foreign Keys'>Index Those Foreign Keys</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2009/12/does-your-stored-procedure-grant-itself-permissions/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Free SQL Server Security Book</title>
		<link>http://www.jasonstrate.com/index.php/2009/10/free-sql-server-security-book/</link>
		<comments>http://www.jasonstrate.com/index.php/2009/10/free-sql-server-security-book/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 04:00:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/?p=276</guid>
		<description><![CDATA[     I saw this post a few weeks back and got around to downloading it myself tonight.&#160; If you don’t know what it is.&#160; It’s a free SQL Server security book.
Best of both Worlds
There are two things I like about this e-book.&#160; The first, it is free.&#160; And the second, it’s [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/04/free-ebook-introducing-sql-server-2008-r2/' rel='bookmark' title='Permanent Link: Free eBook &#8211; Introducing SQL Server 2008 R2'>Free eBook &#8211; Introducing SQL Server 2008 R2</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2008/09/sql-server-virtual-conference/' rel='bookmark' title='Permanent Link: SQL Server Virtual Conference'>SQL Server Virtual Conference</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2008/06/sql-server-2008-release-candidate-0/' rel='bookmark' title='Permanent Link: SQL Server 2008 Release Candidate 0'>SQL Server 2008 Release Candidate 0</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F10%2Ffree-sql-server-security-book%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F10%2Ffree-sql-server-security-book%2F" height="61" width="51" /></a></div><p><a href="http://stratesql.com/images/0/0/5/8/4/157902-148500/defendius-door-lock_2.jpg">     <br /><img title="defendius-door-lock" border="0" alt="defendius-door-lock" align="right" src="http://stratesql.com/images/0/0/5/8/4/157902-148500/defendius-door-lock_thumb.jpg" width="144" height="140" /></a>I saw <a href="http://bradmcgehee.com/2009/09/free-book-protecting-sql-server-data/">this post</a> a few weeks back and got around to downloading it myself tonight.&#160; If you don’t know what <strong><em>it </em></strong>is.&#160; It’s a free SQL Server security book.</p>
<h6>Best of both Worlds</h6>
<p>There are two things I like about this e-book.&#160; The first, it is free.&#160; And the second, it’s a book on security which there will never be enough of.&#160; Sadly, security is one of those areas that seem to be overlooked until it is often too late.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2010/04/free-ebook-introducing-sql-server-2008-r2/' rel='bookmark' title='Permanent Link: Free eBook &#8211; Introducing SQL Server 2008 R2'>Free eBook &#8211; Introducing SQL Server 2008 R2</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2008/09/sql-server-virtual-conference/' rel='bookmark' title='Permanent Link: SQL Server Virtual Conference'>SQL Server Virtual Conference</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2008/06/sql-server-2008-release-candidate-0/' rel='bookmark' title='Permanent Link: SQL Server 2008 Release Candidate 0'>SQL Server 2008 Release Candidate 0</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2009/10/free-sql-server-security-book/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>May PASSMN Meeting (05/19/2009)</title>
		<link>http://www.jasonstrate.com/index.php/2009/05/may-passmn-meeting-05192009/</link>
		<comments>http://www.jasonstrate.com/index.php/2009/05/may-passmn-meeting-05192009/#comments</comments>
		<pubDate>Thu, 07 May 2009 14:15:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[PASSMN]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SSIS]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/?p=210</guid>
		<description><![CDATA[The topics and speakers for this months PASSMN meeting have been announced…
SSIS – Team Development, Deployment and Configuration &#38; Securing and Troubleshooting Service Broker
May 19, 2009   3:00 PM &#8211; 5:15 PM
SSIS – Team Development, Deployment and Configuration    Speaker: Dan English, Magenic
SQL Server Integration Services (SSIS) provides enterprise-class scalability, advanced data-integration [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/05/may-passmn-meeting-today/' rel='bookmark' title='Permanent Link: May PASSMN Meeting Today'>May PASSMN Meeting Today</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/03/april-passmn-meeting-04212009/' rel='bookmark' title='Permanent Link: April PASSMN Meeting (04/21/2009)'>April PASSMN Meeting (04/21/2009)</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/03/tonight-april-passmn-meeting-04212009/' rel='bookmark' title='Permanent Link: Tonight April PASSMN Meeting (04/21/2009)'>Tonight April PASSMN Meeting (04/21/2009)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F05%2Fmay-passmn-meeting-05192009%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F05%2Fmay-passmn-meeting-05192009%2F" height="61" width="51" /></a></div><p>The topics and speakers for this months PASSMN meeting have been announced…</p>
<p><a href="http://www.digitalconcourse.com/getdigi/dc4main.asp?p=210&amp;ConfCode=PASSEVT20090519">SSIS – Team Development, Deployment and Configuration &amp; Securing and Troubleshooting Service Broker</a></p>
<p>May 19, 2009   <br />3:00 PM &#8211; 5:15 PM</p>
<p><strong>SSIS – Team Development, Deployment and Configuration</strong>    <br /><em>Speaker: Dan English, Magenic</em></p>
<blockquote><p>SQL Server Integration Services (SSIS) provides enterprise-class scalability, advanced data-integration architecture, and high-performance processing. Many enterprise environments are developing centralized services and standards to support their SQL Server Integration Services platform. During this session you will learn considerations and solutions for team development and how to leverage the power of package configurations for deploying packages to multiple environments.</p>
<p><b>Dan English </b>- Dan is a Principal Consultant with Magenic and has been developing with Microsoft technologies for over 12 years and has over 5 years experience with Data Warehousing and Business Intelligence. He has been working with SQL Server since version 6.5 and now with 2008 looking towards the Kilimanjaro release. Dan has screencasts of SQL Server 2008 and PerformancePoint Server on YouTube and Soapbox ( keyword search &#8211; Magenic) and is an avid blogger (<a href="http://denglishbi.spaces.live.com">http://denglishbi.spaces.live.com</a>). Dan is fully certified with MS SQL Server 2005 and 2008 Business Intelligence. He enjoys keeping in contact with the community at large responding to forum postings on the Microsoft forums and SQL Server Central areas. Dan is also part of the PASSMN 2009 Executive Board.</p>
</blockquote>
<p> <u></u>
<p><strong>Securing and Troubleshooting Service Broker </strong>    <br /><em>Speaker: Eric Strom, RELS</em></p>
<blockquote><p>Tired of reading “Hello World” articles about Service Broker? Looking for more information but not finding good resources on securing and troubleshooting Service Broker applications? In this presentation, I will discuss some good security practices and share some lessons I learned while implementing and troubleshooting a medium-sized Service Broker application. Expect to learn about securing and troubleshooting Service Broker. A basic understanding of the Service Broker architecture is helpful.</p>
<p><b>Eric Strom </b>is a Senior Database Administrator at the RELS Companies and is a member of the PASSMN 2009 Executive Board. He has been a SQL Server DBA since 2001 and specializes in performance tuning. Eric studied database theory at the University of Minnesota to earn a B.S. in Computer Science. He loves exchanging ideas with peers and is always looking for a good discussion.</p>
</blockquote>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/05/may-passmn-meeting-today/' rel='bookmark' title='Permanent Link: May PASSMN Meeting Today'>May PASSMN Meeting Today</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/03/april-passmn-meeting-04212009/' rel='bookmark' title='Permanent Link: April PASSMN Meeting (04/21/2009)'>April PASSMN Meeting (04/21/2009)</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/03/tonight-april-passmn-meeting-04212009/' rel='bookmark' title='Permanent Link: Tonight April PASSMN Meeting (04/21/2009)'>Tonight April PASSMN Meeting (04/21/2009)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2009/05/may-passmn-meeting-05192009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Troubleshooting Permission Issues with CREDITIALS</title>
		<link>http://www.jasonstrate.com/index.php/2009/02/troubleshooting-permission-issues-with-creditials/</link>
		<comments>http://www.jasonstrate.com/index.php/2009/02/troubleshooting-permission-issues-with-creditials/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 22:54:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SSIS]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[White Paper]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/?p=163</guid>
		<description><![CDATA[    I keep hearing this story and similar variations…
”On a dark and stormy night, I developed a SQL Server Integration Services (SSIS) package.&#160; It worked wonderfully on my desktop development environment.&#160; All the files were properly accessed and the data was processed in a magnificent matter.”
”But suddenly I deployed the SSIS package [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2008/06/transfer-logins-between-sql-server-2005-instances/' rel='bookmark' title='Permanent Link: Transfer Logins Between SQL Server 2005 Instances'>Transfer Logins Between SQL Server 2005 Instances</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2008/01/upgrade-issues-when-sa-renamed/' rel='bookmark' title='Permanent Link: Upgrade Issues When &#8217;sa&#8217; Renamed'>Upgrade Issues When &#8217;sa&#8217; Renamed</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/05/may-passmn-meeting-05192009/' rel='bookmark' title='Permanent Link: May PASSMN Meeting (05/19/2009)'>May PASSMN Meeting (05/19/2009)</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F02%2Ftroubleshooting-permission-issues-with-creditials%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2009%2F02%2Ftroubleshooting-permission-issues-with-creditials%2F" height="61" width="51" /></a></div><p><img style="display: inline; margin-left: 0px; margin-right: 0px" align="right" src="http://www.air-and-space.com/LockettBooks%20prints/19911011%20Gaviota%2036%20Lightning%20Lulu%2011x14%20l.jpg" width="240" height="189" />    <br />I keep hearing this story and similar variations…</p>
<p>”On a dark and stormy night, I developed a SQL Server Integration Services (SSIS) package.&#160; It worked wonderfully on my desktop development environment.&#160; All the files were properly accessed and the data was processed in a magnificent matter.”</p>
<p>”But suddenly I deployed the SSIS package to production environment, or sometimes even the test environment first.&#160; And BAM! the SQL Agent job I created to execute the package would fail.”</p>
<p>”I laughed and cried and checked all of the settings and permissions and everything is <em>identical</em> to the development environment.&#160; I just don’t know what is going wrong.&#160; Help me <a href="http://en.wikipedia.org/wiki/Obi-Wan_Kenobi">Obi-Won</a>, you’re my only hope.”</p>
<p>The first thing I do any time I hear this story is to tell the developer that I think it’s really weird to actually say “open parenthesis” and “close parenthesis”.&#160; But, right after that I check the execution log for the package.&#160; The execution log will usually have all this verbiage around it not being able to this, that, or the other thing with some external resource that the SSIS package is referencing.</p>
<p>But the developer had stated that everything is <em>identical </em>to the development environment but this, of course, doesn’t mean that the SQL Agent account is actually the same between the two environments.&#160; And this is where the problem often lies.&#160; In the development environment the package was executed by a power user, the developer, that could access anything the developer wanted.&#160; In nice and secure SQL environments, the SQL Agent service account will have minimal permissions within SQL Server and no permissions outside of the server that it doesn’t require.</p>
<p><strong>New package.&#160; New requirements.&#160; New network permissions.&#160; New proxy.</strong></p>
<p>As I mentioned, the account executing the SSIS package has different between the environments.&#160; What if I could run the SSIS package on the production environment with the SAME permissions I ran the package with in the development environment.&#160; SQL Server 2005 and 2008 allows for this through the use of CREDENTIALS.&#160; Books Online defines CREDENTIALS as such:</p>
<blockquote><p><em>A credential is a record that contains the authentication information (credentials) required to connect to a resource outside SQL Server. This information is used internally by SQL Server. Most credentials contain a Windows user name and password.</em></p>
<p><em>The information stored in a credential enables a user who has connected to SQL Server by way of SQL Server Authentication to access resources outside the server instance. When the external resource is Windows, the user is authenticated as the Windows user specified in the credential. A single credential can be mapped to multiple SQL Server logins. However, a SQL Server login can be mapped to only one credential.</em></p>
</blockquote>
<p>To execute a SQL Agent job under the developers account the following four things need to be done:</p>
<p>1. Create the CREDENTIAL using <a href="http://msdn.microsoft.com/en-us/library/ms189522.aspx">CREATE CREDENTIAL</a>.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">-- Create a credential with the account Domain\User and its password</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">USE</span> [master]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">GO</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">CREATE</span> CREDENTIAL MyCredential <span style="color: #0000ff">WITH</span> <span style="color: #0000ff">IDENTITY</span> = N<span style="color: #006080">'Domain\User'</span>, SECRET = N<span style="color: #006080">'Password'</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">GO</pre>
<p><!--CRLF--></div>
</div>
<p>2. Create a proxy that references the CREDENTIAL using <a href="http://msdn.microsoft.com/en-us/library/ms188763.aspx">msdb.dbo.sp_add_proxy</a>.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">-- Create a proxy and assign the credential to it</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">USE</span> [msdb]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">GO</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">EXEC</span> msdb.dbo.sp_add_proxy @proxy_name=N<span style="color: #006080">'MySSISProxy'</span>,@credential_name=N<span style="color: #006080">'MyCredential'</span>,@enabled=1</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">GO</pre>
<p><!--CRLF--></div>
</div>
<p>3. Grant the proxy access to the SSIS subsystem using <a href="http://msdn.microsoft.com/en-us/library/ms186760.aspx">msdb.dbo.sp_grant_proxy_to_subsystem</a>.</p>
<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
<div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">-- Grant proxy access to the 'SSIS package execution' subsystem, aka #11</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">USE</span> [msdb]</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">GO</span></pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">EXEC</span> msdb.dbo.sp_grant_proxy_to_subsystem @proxy_name=N<span style="color: #006080">'MySSISProxy'</span>, @subsystem_id=11</pre>
<p><!--CRLF--></p>
<pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">GO</pre>
<p><!--CRLF--></div>
</div>
<p>4. Assign the Run As value for the SQL Agent Job Step to the proxy.</p>
<p><a href="http://stratesql.com/images/0/0/5/8/4/157902-148500/image_8.png"><img title="image" border="0" alt="image" src="http://stratesql.com/images/0/0/5/8/4/157902-148500/image_thumb_3.png" width="556" height="501" /></a></p>
<p>Often by going through these steps I’m able to show that the package that runs in the developer’s development environment under his login will also run in the production environment under his login.&#160;&#160; Now identical really means identical and through either adding permissions to the SQL Agent service account or, even better, creating a CREDENTIAL with the appropriate permissions that package can be executed as intended.</p>
<p><strong>Nice and Secure Environments</strong></p>
<p>I should note that using the developer’s login is a temporary troubleshooting technique.&#160; The developer’s login should not be used on an ongoing basis for the SQL Agent job.&#160; This will open up a whole host of issues such as password resets and proxy accounts that stop working with developers logins are disabled.</p>
<p>And as I mentioned above, some people like nice and secure SQL Agent environments.&#160; I am a big fan of those as well.&#160; CREDENTIALS are a great tool that should be used to keep SQL Agent secure.&#160; By limiting the scope of the SQL Agent service accounts, SQL Agent can be prevented from accessing resources and data that it shouldn’t normally access.&#160; I’m not going to get too much into security best practices around this other than to say if restricting SQL Agent permissions isn’t a current consideration you should read the <a href="http://download.microsoft.com/download/8/5/e/85eea4fa-b3bb-4426-97d0-7f7151b2011c/SQL2005SecBestPract.doc">SQL Server 2005 Security Best Practices &#8211; Operational and Administrative Tasks</a> white paper.</p>
<p><strong>Tagged</strong></p>
<p>I’ve been <a href="http://statisticsio.com/Home/tabid/36/articleType/ArticleView/articleId/334/Things-you-Know-Nowhellip.aspx">tagged</a>…&#160; <a href="http://statisticsio.com/">Jason Massie</a> tagged me this week and I’ll be responding to it in Monday’s blog.</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2008/06/transfer-logins-between-sql-server-2005-instances/' rel='bookmark' title='Permanent Link: Transfer Logins Between SQL Server 2005 Instances'>Transfer Logins Between SQL Server 2005 Instances</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2008/01/upgrade-issues-when-sa-renamed/' rel='bookmark' title='Permanent Link: Upgrade Issues When &#8217;sa&#8217; Renamed'>Upgrade Issues When &#8217;sa&#8217; Renamed</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/05/may-passmn-meeting-05192009/' rel='bookmark' title='Permanent Link: May PASSMN Meeting (05/19/2009)'>May PASSMN Meeting (05/19/2009)</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2009/02/troubleshooting-permission-issues-with-creditials/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transfer Logins Between SQL Server 2005 Instances</title>
		<link>http://www.jasonstrate.com/index.php/2008/06/transfer-logins-between-sql-server-2005-instances/</link>
		<comments>http://www.jasonstrate.com/index.php/2008/06/transfer-logins-between-sql-server-2005-instances/#comments</comments>
		<pubDate>Wed, 11 Jun 2008 07:54:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SSIS]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/?p=103</guid>
		<description><![CDATA[I&#8217;ve never been a fan of the SQL Server 2005 Integration Services task for transferring logins between servers.&#160; It seems that I always misconfigure it or something gets missed.&#160; And when I just want to move a single login its more effort to setup the task than it is worth.&#160; What I&#8217;m really saying here [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2006/08/sql-server-2005-books-online/' rel='bookmark' title='Permanent Link: SQL Server 2005 Books Online'>SQL Server 2005 Books Online</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2007/10/restoring-a-database-with-symmetric-encryption/' rel='bookmark' title='Permanent Link: Restoring a Database with Symmetric Encryption'>Restoring a Database with Symmetric Encryption</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/02/troubleshooting-permission-issues-with-creditials/' rel='bookmark' title='Permanent Link: Troubleshooting Permission Issues with CREDITIALS'>Troubleshooting Permission Issues with CREDITIALS</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2008%2F06%2Ftransfer-logins-between-sql-server-2005-instances%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2008%2F06%2Ftransfer-logins-between-sql-server-2005-instances%2F" height="61" width="51" /></a></div><p>I&#8217;ve never been a fan of the SQL Server 2005 Integration Services task for transferring logins between servers.&#160; It seems that I always misconfigure it or something gets missed.&#160; And when I just want to move a single login its more effort to setup the task than it is worth.&#160; What I&#8217;m really saying here is I&#8217;m not a fan of the task and I don&#8217;t plan to get &quot;gooder&quot; at using it. </p>
<p>Especially when there is a much better alternative&#8230; <a href="http://support.microsoft.com/kb/918992">scipting the login with the password</a>.&#160; The link has a script that creates a couple stored procedures that, when executed, provides either a single or all logins with their properties.</p>
<p>The output script looks something like this:</p>
<blockquote><p>&#8211; Login: ExistingUser     <br />CREATE LOGIN [ExistingUser]&#160; <br />WITH PASSWORD = 0&#215;0100DE1894107F53A6ABF5436BA4F2A6BFFC0C51C156760E70F2 HASHED,&#160; <br />SID = 0xDA25EBDBF88087D98B65D94B1DF3155B,&#160; <br />DEFAULT_DATABASE = [master],&#160; <br />CHECK_POLICY = OFF,&#160; <br />CHECK_EXPIRATION = OFF</p>
</blockquote>
<p> Very useful indeed&#8230;</p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2006/08/sql-server-2005-books-online/' rel='bookmark' title='Permanent Link: SQL Server 2005 Books Online'>SQL Server 2005 Books Online</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2007/10/restoring-a-database-with-symmetric-encryption/' rel='bookmark' title='Permanent Link: Restoring a Database with Symmetric Encryption'>Restoring a Database with Symmetric Encryption</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2009/02/troubleshooting-permission-issues-with-creditials/' rel='bookmark' title='Permanent Link: Troubleshooting Permission Issues with CREDITIALS'>Troubleshooting Permission Issues with CREDITIALS</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2008/06/transfer-logins-between-sql-server-2005-instances/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upgrade Issues When &#8217;sa&#8217; Renamed</title>
		<link>http://www.jasonstrate.com/index.php/2008/01/upgrade-issues-when-sa-renamed/</link>
		<comments>http://www.jasonstrate.com/index.php/2008/01/upgrade-issues-when-sa-renamed/#comments</comments>
		<pubDate>Sun, 13 Jan 2008 15:30:00 +0000</pubDate>
		<dc:creator>jstrate</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.jasonstrate.com/?p=127</guid>
		<description><![CDATA[I&#8217;ve not done recommended changing the sa account name at a client for quite a while.&#160; Since the account can be disabled there isn&#8217;t any good reason to rename it that I&#8217;ve been able to come up with.
But if you do and plan to upgrade to SQL Server 2008, beware of the following&#8230;
http://blogs.msdn.com/psssql/archive/2008/09/10/upgrade-for-sql-server-2008-can-fail-if-you-have-renamed-the-sa-account.aspx


Related posts:Troubleshooting Permission [...]


Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/02/troubleshooting-permission-issues-with-creditials/' rel='bookmark' title='Permanent Link: Troubleshooting Permission Issues with CREDITIALS'>Troubleshooting Permission Issues with CREDITIALS</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2008/09/sql-server-2008-cumulative-update-1/' rel='bookmark' title='Permanent Link: SQL Server 2008 Cumulative Update 1'>SQL Server 2008 Cumulative Update 1</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2008/11/upgrading-to-sql-server-2008/' rel='bookmark' title='Permanent Link: Upgrading to SQL Server 2008'>Upgrading to SQL Server 2008</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2008%2F01%2Fupgrade-issues-when-sa-renamed%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.jasonstrate.com%2Findex.php%2F2008%2F01%2Fupgrade-issues-when-sa-renamed%2F" height="61" width="51" /></a></div><p>I&#8217;ve not done recommended changing the sa account name at a client for quite a while.&#160; Since the account can be disabled there isn&#8217;t any good reason to rename it that I&#8217;ve been able to come up with.</p>
<p>But if you do and plan to upgrade to SQL Server 2008, beware of the following&#8230;</p>
<p><a href="http://blogs.msdn.com/psssql/archive/2008/09/10/upgrade-for-sql-server-2008-can-fail-if-you-have-renamed-the-sa-account.aspx">http://blogs.msdn.com/psssql/archive/2008/09/10/upgrade-for-sql-server-2008-can-fail-if-you-have-renamed-the-sa-account.aspx</a></p>


<p>Related posts:<ol><li><a href='http://www.jasonstrate.com/index.php/2009/02/troubleshooting-permission-issues-with-creditials/' rel='bookmark' title='Permanent Link: Troubleshooting Permission Issues with CREDITIALS'>Troubleshooting Permission Issues with CREDITIALS</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2008/09/sql-server-2008-cumulative-update-1/' rel='bookmark' title='Permanent Link: SQL Server 2008 Cumulative Update 1'>SQL Server 2008 Cumulative Update 1</a></li>
<li><a href='http://www.jasonstrate.com/index.php/2008/11/upgrading-to-sql-server-2008/' rel='bookmark' title='Permanent Link: Upgrading to SQL Server 2008'>Upgrading to SQL Server 2008</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.jasonstrate.com/index.php/2008/01/upgrade-issues-when-sa-renamed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
