使用Microsoft CDS Web API设置PrivilegeDepth



我正试图仅使用Web API为我的公共数据服务环境创建一个应用程序用户及其安全角色。我已经创建了用户和角色,并将一些特权与角色关联起来。我唯一不能做的就是设置RolePrivilege关联的PrivilegeDepth。这是我用来创建具有一些权限的角色的请求负载:

{
"businessunitid@odata.bind": "/businessunits(6efad0b7-160b-eb11-a812-000d3ab2a6be)",
"name": "Security Role Test",
"iscustomizable": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "iscustomizableanddeletable"
},
"canbedeleted": {
"Value": true,
"CanBeChanged": true,
"ManagedPropertyLogicalName": "canbedeleted"
},
"roleprivileges_association@odata.bind": [
"/privileges(2493b394-f9d7-4604-a6cb-13e1f240450d)",
"/privileges(707e9700-19ed-4cba-be06-9d7f6e845383)",
"/privileges(e62439f6-3666-4c0a-a732-bde205d8e938)",
"/privileges(e3f45b8e-4872-4bb5-8b84-01ee8f9c9da1)",
"/privileges(f36ff7e9-72b9-4882-afb6-f947de984f72)",
"/privileges(886b280c-6396-4d56-a0a3-2c1b0a50ceb0)"
]
}

RolePrivileges都是以最低深度(User(创建的。有人知道如何设置不同的深度吗?

此外,是否有更好的方式为角色分配权限?比如,将具有所需权限的XML上传到将其与角色关联的端点?有没有更好的方法可以在不必知道GUID的情况下指定特权?

如果你能帮我做这件事,我将不胜感激。谢谢

这应该是设置深度(如用户、本地等(的有效负载。请确保测试它,我现在没有机会测试它。阅读更多

"roleprivileges_association@odata.bind": [
{
"privilegeid@odata.bind" : "/privileges(2493b394-f9d7-4604-a6cb-13e1f240450d)",
"depth" : 1
},
]

关于动态guid值,而不是硬编码,只需进行另一个服务调用即可获取所有权限并对其进行迭代。阅读更多

所以我找到了设置特权深度的解决方案。有一个操作,AddPrivelegesRole。

示例:

POST https://org12345.crm4.dynamics.com/api/data/v9.0/roles(1b3df93a-070f-eb11-a813-000d3a666701)/Microsoft.Dynamics.CRM.AddPrivilegesRole
{
"Privileges": [
{
"Depth": "0",
"PrivilegeId": "886b280c-6396-4d56-a0a3-2c1b0a50ceb0",
"BusinessUnitId": "6efad0b7-160b-eb11-a812-000d3ab2a6be"
},
{
"Depth": "1",
"PrivilegeId": "7863e80f-0ab2-4d67-a641-37d9f342c7e3",
"BusinessUnitId": "6efad0b7-160b-eb11-a812-000d3ab2a6be"
},
{
"Depth": "2",
"PrivilegeId": "d26fe964-230b-42dd-ad93-5cc879de411e",
"BusinessUnitId": "6efad0b7-160b-eb11-a812-000d3ab2a6be"
},
{
"Depth": "3",
"PrivilegeId": "ca6c7690-c935-46b3-bfd2-abb306c2acc0",
"BusinessUnitId": "6efad0b7-160b-eb11-a812-000d3ab2a6be"
}
]
}

最新更新