dbuzerindeki bir userin yetkilerini bulma - find permission on user
Definition Description
SELECT dperm.class_desc AS [ObjectType], dperm.major_id [Asmajor_id] , @@SERVERNAME AS [ServerName], DB_NAME() AS [DatabaseName], CASE WHEN o.type_desc IS NOT NULL THEN 'Permission on OBJECT (TABLE,SP,FUNC..) level' ELSE 'Permission on Database Level' END AS [PermissionDesc], ISNULL(sch.name, osch.name) AS [SchemaName], ISNULL(o.name, '.') AS [ObjectName], o.type_desc AS [type_desc], dprin.NAME AS [Grantee], grantor.name AS [Grantor], dprin.type_desc AS [principal_type_desc], dperm.permission_name AS [permission_name], dperm.state_desc AS [permission_state_desc] FROM sys.database_permissions dperm INNER JOIN sys.database_principals dprin ON dperm.grantee_principal_id = dprin.principal_id INNER JOIN sys.database_principals grantor ON dperm.grantor_principal_id = grantor.principal_id LEFT OUTER JOIN sys.schemas sch ON dperm.major_id = sch.schema_id AND dperm.class = 3 LEFT OUTER JOIN sys.all_objects o ON dperm.major_id = o.OBJECT_ID AND dperm.class = 1 LEFT OUTER JOIN sys.schemas osch ON o.schema_id = osch.schema_id WHERE dprin.name <> 'public' AND dperm.type <> 'CO' AND dprin.type <> 'R' AND dprin.NAME <>'guest' AND dprin.NAME ='messaging'