How to view the roles and permissions granted to any database user in Azure SQL server instance?

前端 未结 4 441
遥遥无期
遥遥无期 2021-01-30 17:18

Could you guide me on how to view the current roles/permissions granted to any database user in Azure SQL Database or in general for a MSSQL Server instance?

I have thi

4条回答
  •  甜味超标
    2021-01-30 17:45

    Building on @tmullaney 's answer, you can also left join in the sys.objects view to get insight when explicit permissions have been granted on objects. Make sure to use the LEFT join:

    SELECT DISTINCT pr.principal_id, pr.name AS [UserName], pr.type_desc AS [User_or_Role], pr.authentication_type_desc AS [Auth_Type], pe.state_desc,
        pe.permission_name, pe.class_desc, o.[name] AS 'Object' 
        FROM sys.database_principals AS pr 
        JOIN sys.database_permissions AS pe ON pe.grantee_principal_id = pr.principal_id
        LEFT JOIN sys.objects AS o on (o.object_id = pe.major_id)
    

提交回复
热议问题