Dynamic CRM 导出角色权限SQL

SELECT
FilteredRole.name,
EntityView.PhysicalName,
Privilege.Name,
AccessLevel =
CASE Privilege.AccessRight
WHEN 1 THEN 'READ'
WHEN 2 THEN 'WRITE'
WHEN 4 THEN 'APPEND'
WHEN 16 THEN 'APPENDTO'
WHEN 32 THEN 'CREATE'
WHEN 65536 THEN 'DELETE'
WHEN 262144 THEN 'SHARE'
WHEN 524288 THEN 'ASSIGN'
END,
SecurityLevel =

CASE PrivilegeDepthMask

WHEN 1 THEN 'User'

WHEN 2 THEN 'Business Unit'

WHEN 4 THEN 'Parent: Child Business Unit'

WHEN 8 THEN 'Organisation'

END
FROM
RolePrivileges inner join FilteredRole on RolePrivileges.RoleId = FilteredRole.roleid
Inner Join PrivilegeObjectTypeCodes on RolePrivileges.PrivilegeId = PrivilegeObjectTypeCodes.PrivilegeId
Inner Join Privilege on RolePrivileges.PrivilegeId = Privilege.PrivilegeId
Inner Join EntityView on EntityView.ObjectTypeCode = PrivilegeObjectTypeCodes.ObjectTypeCode
WHERE FilteredRole.roletemplateid is null
ORDER BY FilteredRole.name, EntityView.PhysicalName, Privilege.AccessRight

 

转载:

posted @ 2020-03-23 11:52  木子易  Views(395)  Comments(0Edit  收藏  举报