20 Nov 2009
Use DBC.RoleMembers
Select RMM.Grantee As UserName
, RMM.RoleName
, ARR.AccessRight
, ARR.Databasename
, ARR.Tablename
From DBC.RoleMembers RMM
Join DBC.AllRoleRights ARR
ON RMM.RoleName = ARR.RoleName
Where ARR.Databasename = '?DBName'
And ARR.Tablename = '?TblName'
Union
Select ALR.Username
, Null
, ALR.Accessright
, ALR.Databasename
, ALT.Tablename
Where ARR.Databasename = '?DBName'
And ARR.Tablename = '?TblName'
Order By 4,5,1,3,2
;
Hi All
What I want oto know
Iam intrested to know all the explicit access rights on a given table covering individual and role privileges.
Say for eg - UserA and RoleA have insert rights on Table1.
Then what should I query to get the resultset showing UserA and RoleA with their access.
What I know
1.Using DBC.ALLRIGHTS and DBC.ALLROLERIGHTS , by providing a username , we can get all the explicit rights granted to user either directly or via role.
2.Specifying tablename in WHERE clause of DBC.ALLRIGHTS , the resultset gives us the user name and its rights having automatic access.
Above question is similar but the focus is explicit rights on an an object covering individual users and roles.