角色/权限概述CRM

时间:2012-02-28 08:23:22

标签: dynamics-crm roles crm dynamics-crm-4 privileges

我正在研究MS CRM 4.0。

是否有可能显示每个实体的所有角色及其特权的概述? 我需要它,例如,在excel中向客户展示它。 它应该像这样构建:

  • ROLENAME
    • 实体名称
      • 创建:组织
      • 阅读:组织
      • 写:业务部门
      • ...

这是否有功能? 我使用了很多角色和自定义实体,手动完成它需要我很多工作。

1 个答案:

答案 0 :(得分:1)

我在MSDN上找到了这个例子,它可以让你得到你想要的东西。 http://archive.msdn.microsoft.com/CrmSecurityReports

单击下载选项卡。该zip包含四个报告,用于显示安全角色和/或业务部门的权限。按角色分为2份报告,用户分为2份报告。

这是来自名为RolePrivileges.sql的文件,可以满足您的需求:

-- Query on entity roles, consolidating records
select RoleName, BusinessUnitName, EntityName
, max([Read]) as [Read], max([Write]) as [Write], max([Append]) as [Append], max([AppendTo]) as [AppendTo]
, max([Create]) as [Create], max([Delete]) as [Delete], max([Share]) as [Share], max([Assign]) as [Assign] 
from                                                                                                
-- Use sub query to split rights into columns, then outer query gets the Depth
(select r.name as RoleName, r.businessunitidname as BusinessUnitName, e.Name as EntityName
, isnull(case when p.AccessRight & 1  0 then max(rp.PrivilegeDepthMask) end, 0) as [Read]         
-- Use AccessRight to determine action
, isnull(case when p.AccessRight & 2  0 then max(rp.PrivilegeDepthMask) end, 0) as [Write]
, isnull(case when p.AccessRight & 4  0 then max(rp.PrivilegeDepthMask) end, 0) as [Append]
, isnull(case when p.AccessRight & 16  0 then max(rp.PrivilegeDepthMask) end, 0) as [AppendTo]
, isnull(case when p.AccessRight & 32  0 then max(rp.PrivilegeDepthMask) end, 0) as [Create]
, isnull(case when p.AccessRight & 65536  0 then max(rp.PrivilegeDepthMask) end, 0) as [Delete]
, isnull(case when p.AccessRight & 262144  0 then max(rp.PrivilegeDepthMask) end, 0) as [Share]
, isnull(case when p.AccessRight & 524288  0 then max(rp.PrivilegeDepthMask) end, 0) as [Assign]
from 
    dbo.FilteredRole r
    join dbo.RolePrivileges rp on r.roleid = rp.roleid
    join dbo.FilteredPrivilege p on rp.privilegeid = p.privilegeid
    join dbo.PrivilegeObjectTypeCodes potc on p.privilegeid = potc.privilegeid
    join MetadataSchema.Entity e on potc.ObjectTypeCode = e.ObjectTypeCode
group by 
    r.name, r.businessunitidname, e.Name, p.AccessRight) as Role
group by 
    RoleName, BusinessUnitName, EntityName