查看 SQL Azure 上的自定义角色属性
Viewing custom role properties on SQL Azure
我通过 Management Studio 连接到 SQL Azure 数据库。我已经创建了一个角色并设置了角色的权限:
CREATE ROLE [DepartmentReadOnly] AUTHORIZATION [dbo]
GO
GRANT SELECT ON Table1 TO DepartmentReadOnly
GRANT SELECT ON Table2 TO DepartmentReadOnly
现在我无法通过右键单击并编写角色脚本或转到属性来查看我已授予或未授予角色的权限。我的问题是如何查看我授予角色的所有权限(可能比上面更多)?
这可以帮助获取所有主体和权限,如果需要可以按角色名称过滤
SELECT DB_NAME() as databaseName,
p.[name] as 'Principal_Name',
p.[type_desc] as 'Principal_Type',
principals2.[name] as 'Grantor',
dbpermissions.[permission_name],
dbpermissions.[state_desc],
so.[Name] as 'ObjectName',
so.[type_desc] as 'ObjectType'
FROM [sys].[database_permissions] dbpermissions LEFT JOIN
[sys].[objects] so ON dbpermissions.[major_id] = so.[object_id]
LEFT JOIN [sys].[database_principals] p
ON dbpermissions. [grantee_principal_id] = p.[principal_id]
LEFT JOIN [sys].[database_principals] principals2
ON dbpermissions.[grantor_principal_id] = principals2.[principal_id]
我通过 Management Studio 连接到 SQL Azure 数据库。我已经创建了一个角色并设置了角色的权限:
CREATE ROLE [DepartmentReadOnly] AUTHORIZATION [dbo]
GO
GRANT SELECT ON Table1 TO DepartmentReadOnly
GRANT SELECT ON Table2 TO DepartmentReadOnly
现在我无法通过右键单击并编写角色脚本或转到属性来查看我已授予或未授予角色的权限。我的问题是如何查看我授予角色的所有权限(可能比上面更多)?
这可以帮助获取所有主体和权限,如果需要可以按角色名称过滤
SELECT DB_NAME() as databaseName,
p.[name] as 'Principal_Name',
p.[type_desc] as 'Principal_Type',
principals2.[name] as 'Grantor',
dbpermissions.[permission_name],
dbpermissions.[state_desc],
so.[Name] as 'ObjectName',
so.[type_desc] as 'ObjectType'
FROM [sys].[database_permissions] dbpermissions LEFT JOIN
[sys].[objects] so ON dbpermissions.[major_id] = so.[object_id]
LEFT JOIN [sys].[database_principals] p
ON dbpermissions. [grantee_principal_id] = p.[principal_id]
LEFT JOIN [sys].[database_principals] principals2
ON dbpermissions.[grantor_principal_id] = principals2.[principal_id]