gpt4 book ai didi

sql - Dynamics CRM 2011 安全角色 SQL 查询

转载 作者:行者123 更新时间:2023-12-04 17:00:15 24 4
gpt4 key购买 nike

我是 Dynamics CRM 的新手,我正在尝试从 CRM 的 SQL 后端导出安全角色,以创建每个安全角色读取、写入、创建等权限的报告。有没有人以前做过这个,因为 CRM 表很模糊。

最佳答案

以下将列出每个安全角色、与其相关的实体 - 以及权限和访问级别:

SELECT  DISTINCT
r.Name
,COALESCE(e.OriginalLocalizedName, e.Name) AS [EntityName]
,CASE p.AccessRight
WHEN 32 THEN 'Create' /* or hex value 0x20*/
WHEN 1 THEN 'Read'
WHEN 2 THEN 'Write'
WHEN 65536 THEN 'Delete' /* or hex value 0x10000*/
WHEN 4 THEN 'Append'
WHEN 16 THEN 'AppendTo'
WHEN 524288 THEN 'Assign' /* or hex value 0x80000*/
WHEN 262144 THEN 'Share' /* or hex value 0x40000*/
ELSE 'None'
END AS [Privilege]
,CASE (rp.PrivilegeDepthMask % 0x0F)
WHEN 1 THEN 'User (Basic)'
WHEN 2 THEN 'Business Unit (Local)'
WHEN 4 THEN 'Parental (Deep)'
WHEN 8 THEN 'Organization (Global)'
ELSE 'Unknown'
END AS [PrivilegeLevel]
,(rp.PrivilegeDepthMask % 0x0F) as [PrivilegeDepthMask]
,CASE WHEN e.IsCustomEntity = 1 THEN 'Yes' ELSE 'No' END AS [IsCustomEntity]
FROM Role AS r
INNER JOIN RolePrivileges AS rp
ON r.RoleId = rp.RoleId
INNER JOIN Privilege AS p
ON rp.PrivilegeId = p.PrivilegeId
INNER JOIN PrivilegeObjectTypeCodes AS potc
ON potc.PrivilegeId = p.PrivilegeId
INNER JOIN MetadataSchema.Entity AS e
ON e.ObjectTypeCode = potc.ObjectTypeCode
ORDER BY r.Name, [EntityName]

关于sql - Dynamics CRM 2011 安全角色 SQL 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25201755/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com