创建 accessPackageResourceRequest

命名空间:microsoft.graph

创建新的 accessPackageResourceRequest 对象,以请求将资源添加到访问包目录、更新资源或从目录中删除资源。 必须先将资源包含在访问包目录中,然后才能 将该资源的角色 添加到访问包。

  • 若要将Microsoft Entra组作为资源添加到目录,请将 requestType 设置为 adminAdd,并将 resource 表示资源。 中 resourceoriginSystem 属性的值应为 AadGroup ,originId 的值是组的标识符。
  • 若要将Microsoft Entra应用程序作为资源添加到目录,请将 requestType 设置为 adminAdd,并将 表示resource资源。 中 resourceoriginSystem 属性的值应为 AadApplication ,originId 的值是 servicePrincipal 的标识符。
  • 若要将 SharePoint Online 网站作为资源添加到目录,请将 requestType 设置为 adminAdd,并将 表示 resource 资源。 中 resourceoriginSystem 属性的值应为 SharePointOnline ,originId 的值是站点的 URI。
  • 若要从目录中删除资源,请将 requestType 设置为 adminRemove,并将 resource 设置为 以包含 id 要删除 的资源 对象的 。 可以使用 列表资源检索资源对象。

此 API 可用于以下国家级云部署。

全局服务 美国政府 L4 美国政府 L5 (DOD) 由世纪互联运营的中国
✅ ✅ ✅ ✅

权限

为此 API 选择标记为最低特权的权限。 只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。

权限类型 最低特权权限 更高特权权限
委派(工作或学校帐户) EntitlementManagement.ReadWrite.All 不可用。
委派(个人 Microsoft 帐户) 不支持。 不支持。
应用程序 EntitlementManagement.ReadWrite.All 不可用。

提示

在具有工作或学校帐户的委托方案中,还必须通过以下选项之一为已登录用户分配具有支持的角色权限的管理员角色:

在仅限应用的情况下,可为调用应用分配上述受支持的角色之一,而不是 EntitlementManagement.ReadWrite.All 应用程序权限。 目录所有者角色的特权低于EntitlementManagement.ReadWrite.All应用程序权限。

此外,还必须对要添加的资源具有以下权限:

  • 将Microsoft Entra组作为资源添加到目录:
    • 如果使用委托的权限,则请求添加组的用户应是组的所有者或允许他们修改组的目录角色。
    • 如果使用应用程序权限,则还应为请求添加组的应用程序分配 Group.ReadWrite.All 权限。
  • 若要将Microsoft Entra角色作为资源添加到目录,请执行以下操作:
    • 如果使用委派权限,则想要将角色添加到目录的用户必须是全局管理员或具有目录所有者权限的特权角色管理员。
    • 具有权利管理.ReadWrite.All 权限的应用程序无法向目录添加Microsoft Entra角色,除非它们还具有全局管理员或特权角色管理员权限。
  • 若要将Microsoft Entra应用程序作为资源添加到目录,请执行以下操作:
    • 如果使用委托的权限,则请求添加应用程序的用户应是应用程序的所有者或允许他们修改应用程序角色分配的目录角色。
    • 如果使用应用程序权限,还应为请求添加 servicePrincipal 的应用程序分配 Application.ReadWrite.All 权限。
  • 将 SharePoint Online 网站作为资源添加到目录:

HTTP 请求

POST /identityGovernance/entitlementManagement/resourceRequests

请求标头

名称 说明
Authorization 持有者 {token}。 必填。 详细了解 身份验证和授权。
Content-Type application/json. 必需。

请求正文

在请求正文中,提供 accessPackageResourceRequest 对象的 JSON 表示形式。 将resource与 accessPackageResource 对象的关系作为请求的一catalog部分,以及包含其 id的 对象。

如果成功,此方法在响应正文中返回响应 201 Created 代码和新的 accessPackageResourceRequest 对象。

示例

示例 1:创建用于将组添加为资源的 accessPackageResourceRequest

请求

以下示例显示了一个请求。

POST https://graph.microsoft.com/v1.0/identityGovernance/entitlementManagement/resourceRequests
Content-type: application/json

{
  "requestType": "adminAdd",
  "resource": {
    "displayName": "Test group",
    "originId": "8ab659d0-3839-427d-8c54-5ae92f0b3e2e",
    "originSystem": "AadGroup"
  },
  "catalog": {
    "id": "beedadfe-01d5-4025-910b-84abb9369997"
  }
}

响应

以下示例显示了相应的响应。

注意:为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 201 Created
Content-type: application/json

{
  "id": "acc2294e-f37f-42d3-981d-4e83847ed0ce",
  "requestType": "adminAdd",
  "state": "delivered"
}

示例 2:创建 accessPackageResourceRequest 以将应用程序添加为资源

请求

以下示例显示了一个请求。

POST https://graph.microsoft.com/v1.0/identityGovernance/entitlementManagement/resourceRequests
Content-type: application/json

{
  "requestType": "adminAdd",
  "resource": {
    "originId": "e81d7f57-0840-45e1-894b-f505c1bdcc1f",
    "originSystem": "AadApplication"
  },
  "catalog": {
    "id": "beedadfe-01d5-4025-910b-84abb9369997"
  }
}

响应

以下示例显示了相应的响应。

注意:为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 201 Created
Content-type: application/json

{
  "id": "acc2294e-f37f-42d3-981d-4e83847ed0ce",
  "requestType": "adminAdd",
  "state": "delivered"
}

示例 3:创建用于将 SharePoint Online 网站添加为资源的 accessPackageResourceRequest

请求

以下示例显示了一个请求。

POST https://graph.microsoft.com/v1.0/identityGovernance/entitlementManagement/resourceRequests
Content-type: application/json

{
  "requestType": "adminAdd",
  "resource": {
    "originId": "https://microsoft.sharepoint.com/sites/Example",
    "originSystem": "SharePointOnline"
  },
  "catalog": {
    "id": "beedadfe-01d5-4025-910b-84abb9369997"
  }
}

响应

以下示例显示了相应的响应。

注意:为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 201 Created
Content-type: application/json

{
  "id": "acc2294e-f37f-42d3-981d-4e83847ed0ce",
  "requestType": "adminAdd",
  "state": "delivered"
}

示例 4:创建用于删除资源的 accessPackageResourceRequest

请求

以下示例显示了一个请求。

POST https://graph.microsoft.com/v1.0/identityGovernance/entitlementManagement/resourceRequests
Content-type: application/json

{
  "requestType": "adminRemove",
  "resource": {
    "id": "1d0bb962-5bb0-4b16-a488-fda7a788b9ec"
  },
  "catalog": {
    "id": "beedadfe-01d5-4025-910b-84abb9369997"
  }
}

响应

以下示例显示了相应的响应。

注意:为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 201 Created
Content-type: application/json

{
  "id": "acc2294e-f37f-42d3-981d-4e83847ed0ce",
  "requestType": "adminRemove",
  "state": "delivered"
}

示例 5:创建 accessPackageResourceRequest,以将应用程序更新为具有属性的资源

以下示例显示了一个请求,该请求更新目录中的资源,该应用程序已添加为资源,并具有两个属性。

请求

以下示例显示了一个请求。

POST https://graph.microsoft.com/v1.0/identityGovernance/entitlementManagement/resourceRequests
Content-type: application/json

{
  "requestType": "adminUpdate",
  "resource": {
    "originId": "e81d7f57-0840-45e1-894b-f505c1bdcc1f",
    "originSystem": "AadApplication",
    "attributes": [
      {
        "destination": {
          "@odata.type": "microsoft.graph.accessPackageUserDirectoryAttributeStore"
        },
        "name": "officeLocation",
        "source": {
          "@odata.type": "#microsoft.graph.accessPackageResourceAttributeQuestion",
          "question": {
            "@odata.type": "#microsoft.graph.accessPackageTextInputQuestion",
            "sequence": 1,
            "isRequired": true,
            "isAnswerEditable": true,
            "text": "What office do you work at?",
            "isSingleLineQuestion": true,
            "regexPattern": "[a-zA-Z]+[a-zA-Z\\s]*"
          }
        }
      },
      {
        "destination": {
          "@odata.type": "microsoft.graph.accessPackageUserDirectoryAttributeStore"
        },
        "name": "extension_e409fedc08ab4807a9eb53ebc0d6cc9f_Expense_CostCenter",
        "source": {
          "@odata.type": "#microsoft.graph.accessPackageResourceAttributeQuestion",
          "question": {
            "@odata.type": "#microsoft.graph.accessPackageTextInputQuestion",
            "isRequired": false,
            "text": "What is your cost center number?",
            "sequence": 0,
            "isSingleLineQuestion": true,
            "regexPattern": "[0-9]*"
          }
        }
      }
    ]
  },
  "catalog": {
    "id": "beedadfe-01d5-4025-910b-84abb9369997"
  }
}

响应

以下示例显示了相应的响应。

注意:为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 201 Created
Content-type: application/json

{
  "id": "acc2294e-f37f-42d3-981d-4e83847ed0ce",
  "requestType": "adminAdd",
  "state": "delivered"
}

示例 6:将管理组资源添加到目录

请求

以下示例演示了向目录添加管理组资源的请求。

POST https://graph.microsoft.com/v1.0/identityGovernance/entitlementManagement/resourceRequests
Content-type: application/json

{
    "requestType": "adminAdd",
    "resource": {
        "displayName": "test-mgmtgroup",
        "description": "test-mgmtgroup",
        "resourceType": "ManagementGroup",
        "originId": "/providers/Microsoft.Management/managementGroups/test-mgmtgroup",
        "originSystem": "AzureResources"
    },
    "catalog": {
        "id": "e8368470-afaf-44da-ba86-13a7318f1995"
    }
}

响应

以下示例显示了相应的响应。

注意:为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 201 Created
Content-type: application/json

{
  "id": "99e156fe-d152-4005-b019-6ba816f411ea",
  "requestType": "adminAdd",
  "state": "delivered"
}

示例 7:将订阅资源添加到目录

请求

以下示例演示了向目录添加订阅资源的请求。

POST https://graph.microsoft.com/v1.0/identityGovernance/entitlementManagement/resourceRequests
Content-type: application/json

{
    "requestType": "adminAdd",
    "resource": {
        "displayName": "Dev",
        "description": "Dev",
        "resourceType": "Subscription",
        "originId": "/subscriptions/828b526f-c769-4b19-9797-734b4843b978",
        "originSystem": "AzureResources"
    },
    "catalog": {
        "id": "e8368470-afaf-44da-ba86-13a7318f1995"
    }
}

响应

以下示例显示了相应的响应。

注意:为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 201 Created
Content-type: application/json

{
  "id": "13ac6518-0597-452c-98ff-59c52b391dae",
  "requestType": "adminAdd",
  "state": "delivered"
}