用户分配了SQL azure角色



我试图确保所有用户都被分配了一个特定的角色。是否有任何视图或SQL查询来获取这些信息?

视图已经更改了名称,但以下内容应该适用于SQL Azure

select m.name as Member, r.name as Role
from sys.database_role_members
inner join sys.database_principals m on sys.database_role_members.member_principal_id = m.principal_id
inner join sys.database_principals r on sys.database_role_members.role_principal_id = r.principal_id

我认为下面列出的查询应该列出单个数据库的用户和角色

select b.name as USERName, c.name as RoleName  from dbo.sysmembers a   join dbo.sysusers b   on a.memberuid = b.uid join dbo.sysusers c  on a.groupuid = c.uid

或者对于一个SQL实例上的所有数据库,可以使用sp_MSForEachDB

Exec dbo.sp_MSForEachDB 'select ''?'' as DB, b.name as USERName, c.name as RoleName  from dbo.sysmembers a   join dbo.sysusers b   on a.memberuid = b.uid join dbo.sysusers c  on a.groupuid = c.uid'

相关内容

  • 没有找到相关文章

最新更新