<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Analyzing SQL Server Permissions</title>
	<atom:link href="http://www.sql-server-performance.com/2009/analyzing-sql-server-permissions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sql-server-performance.com/2009/analyzing-sql-server-permissions/</link>
	<description>SQL Server Performance Tuning</description>
	<lastBuildDate>Fri, 17 May 2013 13:31:24 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Howard Rothenburg</title>
		<link>http://www.sql-server-performance.com/2009/analyzing-sql-server-permissions/#comment-2620</link>
		<dc:creator>Howard Rothenburg</dc:creator>
		<pubDate>Fri, 07 Dec 2012 17:15:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.sql-server-performance.com/?=1548#comment-2620</guid>
		<description><![CDATA[--SQL Server Permissions
SELECT [UserName] = ulogin.[name],
       [UserType]             = CASE princ.[type]
                         WHEN &#039;S&#039; THEN &#039;SQL User&#039;
                         WHEN &#039;U&#039; THEN &#039;Windows User&#039;
                         WHEN &#039;G&#039; THEN &#039;Windows Group&#039;
                    END,
       [DatabaseUserName]     = princ.[name],
       [Role]                 = NULL,
       [PermissionState]      = perm.[state_desc],
       [PermissionType]       = perm.[permission_name],
       [ObjectType]           = CASE perm.[class]
                           WHEN 1 THEN obj.type_desc -- Schema-contained objects
                           ELSE perm.[class_desc] -- Higher-level objects
                      END,
       [ObjectName]           = CASE perm.[class]
                           WHEN 1 THEN OBJECT_NAME(perm.major_id) -- General objects
                           WHEN 3 THEN schem.[name] -- Schemas
                           WHEN 4 THEN imp.[name] -- Impersonations
                      END,
       [ColumnName]           = col.[name]
FROM   --database user
       sys.database_principals princ
       LEFT JOIN --Login accounts
            sys.server_principals ulogin
            ON  princ.[sid] = ulogin.[sid]
       LEFT JOIN --Permissions
            sys.database_permissions perm
            ON  perm.[grantee_principal_id] = princ.[principal_id]
       LEFT JOIN --Table columns
            sys.columns col
            ON  col.[object_id] = perm.major_id
            AND col.[column_id] = perm.[minor_id]
       LEFT JOIN sys.objects obj
            ON  perm.[major_id] = obj.[object_id]
       LEFT JOIN sys.schemas schem
            ON  schem.[schema_id] = perm.[major_id]
       LEFT JOIN sys.database_principals imp
            ON  imp.[principal_id] = perm.[major_id]
WHERE  princ.[type] IN (&#039;S&#039;, &#039;U&#039;, &#039;G&#039;)
       AND -- No need for these system accounts
           princ.[name] NOT IN (&#039;sys&#039;, &#039;INFORMATION_SCHEMA&#039;)
ORDER BY
       ulogin.[name],
       [UserType],
       [DatabaseUserName],
       [Role],
       [PermissionState],
       [PermissionType],
       [ObjectType],
       [ObjectName],
       [ColumnName]]]></description>
		<content:encoded><![CDATA[<p>&#8211;SQL Server Permissions</p>
<p>SELECT [UserName] = ulogin.[name],<br />
       [UserType]             = CASE princ.[type]<br />
                         WHEN &#8216;S&#8217; THEN &#8216;SQL User&#8217;<br />
                         WHEN &#8216;U&#8217; THEN &#8216;Windows User&#8217;<br />
                         WHEN &#8216;G&#8217; THEN &#8216;Windows Group&#8217;<br />
                    END,<br />
       [DatabaseUserName]     = princ.[name],<br />
       [Role]                 = NULL,<br />
       [PermissionState]      = perm.[state_desc],<br />
       [PermissionType]       = perm.[permission_name],<br />
       [ObjectType]           = CASE perm.[class]<br />
                           WHEN 1 THEN obj.type_desc &#8212; Schema-contained objects<br />
                           ELSE perm.[class_desc] &#8212; Higher-level objects<br />
                      END,<br />
       [ObjectName]           = CASE perm.[class]<br />
                           WHEN 1 THEN OBJECT_NAME(perm.major_id) &#8212; General objects<br />
                           WHEN 3 THEN schem.[name] &#8212; Schemas<br />
                           WHEN 4 THEN imp.[name] &#8212; Impersonations<br />
                      END,<br />
       [ColumnName]           = col.[name]<br />
FROM   &#8211;database user<br />
       sys.database_principals princ<br />
       LEFT JOIN &#8211;Login accounts<br />
            sys.server_principals ulogin<br />
            ON  princ.[sid] = ulogin.[sid]<br />
       LEFT JOIN &#8211;Permissions<br />
            sys.database_permissions perm<br />
            ON  perm.[grantee_principal_id] = princ.[principal_id]<br />
       LEFT JOIN &#8211;Table columns<br />
            sys.columns col<br />
            ON  col.[object_id] = perm.major_id<br />
            AND col.[column_id] = perm.[minor_id]<br />
       LEFT JOIN sys.objects obj<br />
            ON  perm.[major_id] = obj.[object_id]<br />
       LEFT JOIN sys.schemas schem<br />
            ON  schem.[schema_id] = perm.[major_id]<br />
       LEFT JOIN sys.database_principals imp<br />
            ON  imp.[principal_id] = perm.[major_id]<br />
WHERE  princ.[type] IN (&#8216;S&#8217;, &#8216;U&#8217;, &#8216;G&#8217;)<br />
       AND &#8212; No need for these system accounts<br />
           princ.[name] NOT IN (&#8216;sys&#8217;, &#8216;INFORMATION_SCHEMA&#8217;)<br />
ORDER BY<br />
       ulogin.[name],<br />
       [UserType],<br />
       [DatabaseUserName],<br />
       [Role],<br />
       [PermissionState],<br />
       [PermissionType],<br />
       [ObjectType],<br />
       [ObjectName],<br />
       [ColumnName]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Edward</title>
		<link>http://www.sql-server-performance.com/2009/analyzing-sql-server-permissions/#comment-627</link>
		<dc:creator>Edward</dc:creator>
		<pubDate>Thu, 22 Sep 2011 15:34:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.sql-server-performance.com/?=1548#comment-627</guid>
		<description><![CDATA[The database_permissions table shows all permissions that have been granted to the user explicitly but not those rights derived from being a member any of the built in roles.]]></description>
		<content:encoded><![CDATA[<p>The database_permissions table shows all permissions that have been granted to the user explicitly but not those rights derived from being a member any of the built in roles.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee</title>
		<link>http://www.sql-server-performance.com/2009/analyzing-sql-server-permissions/#comment-363</link>
		<dc:creator>Lee</dc:creator>
		<pubDate>Thu, 09 Jun 2011 13:25:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.sql-server-performance.com/?=1548#comment-363</guid>
		<description><![CDATA[Hi,
There is an error in the script that tries to match server logins with their corresponding database user.
As it was shown above, the UserA user was added to the bulkadmin server role. However, since the join between the sys.database_principal and sys.server_principals table was done on the principal_id, it shows that the UserA was added to the serveradmin role.
In order to correct this, instead of joining the tables by the principal_id, the sid has to be used.]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>There is an error in the script that tries to match server logins with their corresponding database user.</p>
<p>As it was shown above, the UserA user was added to the bulkadmin server role. However, since the join between the sys.database_principal and sys.server_principals table was done on the principal_id, it shows that the UserA was added to the serveradmin role.</p>
<p>In order to correct this, instead of joining the tables by the principal_id, the sid has to be used.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
