创建 accessPackageResourceRequest

命名空间:microsoft.graph

重要

Microsoft Graph /beta 版本下的 API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。

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

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

HTTP 请求

POST /identityGovernance/entitlementManagement/accessPackageResourceRequests

请求标头

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

请求正文

在请求正文中,提供 accessPackageResourceRequest 对象的 JSON 表示形式。 将与 accessPackageResource 对象的关系作为请求的一部分包括在内accessPackageResource。

若要将 Microsoft Entra 组作为资源添加到目录中,请将 catalogId 设置为目录的 ID,将 requestType 设置为 AdminAdd,并accessPackageResource表示资源。 其中 originSystem 属性 accessPackageResource 的值应该是 AadGroup , originId 的值是组的标识符。 如果使用委派权限,则请求添加组的用户应是组的所有者或允许他们修改组的目录角色。 如果使用应用程序权限,则还应为请求添加组的应用程序分配 Group.ReadWrite.All 权限。

若要将 Microsoft Entra 应用程序作为资源添加到目录,请将 catalogId 设置为目录的 ID,requestType 设置为 AdminAdd,并accessPackageResource表示资源。 其中accessPackageResource的 originSystem 属性的值应该是AadApplication,originId 的值是 servicePrincipal 的标识符。 如果使用委派的权限,则请求添加应用程序的用户应该是应用程序的所有者,或者是允许他们修改应用程序角色分配的目录角色。

要将 SharePoint Online 网站作为资源添加到目录,请将 catalogId 设置为目录的 ID,requestType 设置为 AdminAdd,以及表示资源的 。accessPackageResource 其中的 originSystem 属性 accessPackageResource 的值应该是 SharePointOnline , originId 的值是 站点的 URI。 如果使用委派权限,则用户应处于 SharePoint 管理员角色中。 如果使用应用程序权限,则还应为请求添加站点的应用程序分配 Sites.FullControl.All 权限。 若要为多地理位置 SharePoint Online 资源分配地理位置环境,请在对象中accessPackageResource包括 accessPackageResourceEnvironment 关系。 这可以通过两种方式完成:

  • 使用注释将 @odata.bind 的accessPackageResourceEnvironmentaccessPackageResourceEnvironment分配给id对象。
  • 指定originId对象中 accessPackageResourceEnvironment 的accessPackageResourceEnvironment参数。

要从目录中删除资源,请将 catalogId 设置为目录的 ID,requestType 设置为 AdminRemove, accessPackageResource 以及要删除的资源对象。 可以使用 列表 accessPackageResources 检索资源对象。

响应

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

示例

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

请求

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

POST https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackageResourceRequests
Content-type: application/json

{
  "catalogId":"26ac0c0a-08bc-4a7b-a313-839f58044ba5",
  "requestType": "AdminAdd",
  "justification": "",
  "accessPackageResource": {
     "displayName": "Sales",
     "description": "https://contoso.sharepoint.com/sites/Sales",
     "url": "https://contoso.sharepoint.com/sites/Sales",
     "resourceType": "SharePoint Online Site",
     "originId": "https://contoso.sharepoint.com/sites/Sales",
     "originSystem": "SharePointOnline"
  }
}

响应

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

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

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

{
  "catalogId": "26ac0c0a-08bc-4a7b-a313-839f58044ba5",
  "id": "1fe272f0-d463-42aa-a9a8-b07ab50a1c4d",
  "isValidationOnly": false,
  "justification": "",
  "requestState": "Delivered",
  "requestStatus": "Fulfilled",
  "requestType": "AdminAdd"
}

示例 2:创建 accessPackageResourceRequest 以将站点添加为资源,并使用 @odata.bind

请求

以下示例显示了一个请求。 在此示例中,@odata.bind注释用于将 的accessPackageResourceEnvironmentaccessPackageResourceEnvironment分配给id对象。

POST https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackageResourceRequests
Content-type: application/json

{
    "catalogId": "de9315c1-272b-4905-924b-cc112ca180c7",
    "accessPackageResource": {
        "displayName": "Community Outreach",
        "description": "https://contoso.sharepoint.com/sites/CSR",
        "resourceType": "SharePoint Online Site",
        "originId": "https://contoso.sharepoint.com/sites/CSR",
        "originSystem": "SharePointOnline",
        "accessPackageResourceEnvironment@odata.bind": "accessPackageResourceEnvironments/615f2218-678f-471f-a60a-02c2f4f80c57"
    },
    "requestType": "AdminAdd"
}

响应

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

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

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#identityGovernance/entitlementManagement/accessPackageResourceRequests/$entity",
    "catalogId": "de9315c1-272b-4905-924b-cc112ca180c7",
    "executeImmediately": false,
    "id": "d3f800d5-0dd6-47f3-9e90-ef562c7551dc",
    "requestType": "AdminAdd",
    "requestState": "Delivered",
    "requestStatus": "Fulfilled",
    "isValidationOnly": false,
    "expirationDateTime": null,
    "justification": null
}

示例 3:创建 accessPackageResourceRequest,用于将站点添加为资源,并使用 originId 分配 accessPackageResourceEnvironment

请求

以下示例显示了一个请求。 在此示例中,对象中accessPackageResourceEnvironment指定了 的accessPackageResourceEnvironment参数。

POST https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackageResourceRequests
Content-type: application/json

{
    "catalogId": "de9315c1-272b-4905-924b-cc112ca180c7",
    "accessPackageResource": {
        "displayName": "Community Outreach",
        "description": "https://contoso.sharepoint.com/sites/CSR",
        "resourceType": "SharePoint Online Site",
        "originId": "https://contoso.sharepoint.com/sites/CSR",
        "originSystem": "SharePointOnline",
        "accessPackageResourceEnvironment": {
            "originId": "https://contoso-admin.sharepoint.com/"
        }
    },
    "requestType": "AdminAdd"
}

响应

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

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

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#identityGovernance/entitlementManagement/accessPackageResourceRequests/$entity",
    "catalogId": "de9315c1-272b-4905-924b-cc112ca180c7",
    "executeImmediately": false,
    "id": "eadf3fbb-668c-4c3a-8d84-7c8bd73dc3e4",
    "requestType": "AdminAdd",
    "requestState": "Delivered",
    "requestStatus": "Fulfilled",
    "isValidationOnly": false,
    "expirationDateTime": null,
    "justification": null
}

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

请求

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

POST https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackageResourceRequests
Content-type: application/json

{

  "catalogId":"beedadfe-01d5-4025-910b-84abb9369997",
  "requestType": "AdminAdd",
  "accessPackageResource": {
     "originId": "c6294667-7348-4f5a-be73-9d2c65f574f3",
     "originSystem": "AadGroup"
  }
}

响应

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

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

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

{
  "catalogId": "beedadfe-01d5-4025-910b-84abb9369997",
  "id": "acc2294e-f37f-42d3-981d-4e83847ed0ce",
  "requestType": "AdminAdd",
  "requestState": "Delivered",
  "requestStatus": "Fulfilled"
}

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

请求

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

POST https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackageResourceRequests
Content-type: application/json

{
  "catalogId": "beedadfe-01d5-4025-910b-84abb9369997",
  "requestType": "AdminRemove",
  "accessPackageResource": {
    "id": "354078e5-dbce-4894-8af4-0ab274d41662"
  }
}

响应

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

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

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

{
  "catalogId": "beedadfe-01d5-4025-910b-84abb9369997",
  "id": "65c3340d-defb-49a9-8930-63841fda0e68",
  "requestType": "AdminRemove",
  "requestState": "Delivered",
  "requestStatus": "Fulfilled"
}

示例 6:创建用于添加应用程序的 accessPackageResourceRequest

请求

下面的示例显示了将应用程序添加到目录的请求,包括指定该应用程序的必需属性。

POST https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackageResourceRequests
Content-type: application/json

{
  "catalogId": "26ac0c0a-08bc-4a7b-a313-839f58044ba5",
  "requestType": "AdminAdd",
  "justification": "",
  "accessPackageResource": {
      "displayName": "Faculty cafeteria ordering",
      "description": "Example application",
      "url": "https://myapps.microsoft.com/example.com/signin/Faculty%20cafeteria%20ordering/f1e3b407-942d-4934-9a3f-cef1975cb988/",
      "resourceType": "Application",
      "originId": "2f1099a6-d4fc-4cc9-a0ef-ddd3f1bf0b7e",
      "originSystem": "AadApplication",
      "attributes": [
        {
          "attributeName": "extension_2b676109c7c74ae2b41549205f1947ed_personalTitle",
          "isEditable": true,
          "isPersistedOnAssignmentRemoval": true,
          "attributeSource": {
              "@odata.type": "#microsoft.graph.accessPackageResourceAttributeQuestion",
              "question": {
                  "@odata.type": "#microsoft.graph.accessPackageTextInputQuestion",
                  "isRequired": false,
                  "sequence": 0,
                  "isSingleLineQuestion": true,
                  "text": {
                      "defaultText": "Title",
                      "localizedTexts": []
                  }
              }
          },
          "attributeDestination": {
              "@odata.type": "#microsoft.graph.accessPackageUserDirectoryAttributeStore"
          }
        }
      ]
  }
}

响应

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

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

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

{
  "id": "f0e632ed-afd2-41d3-8d6e-ccefda457e5e",
  "requestType": "AdminAdd",
  "requestState": "Delivered",
  "requestStatus": "Fulfilled"
}

示例 7:创建 accessPackageResourceRequest,以便将 SAP IAG 访问权限添加为资源

请求

以下示例显示了将外部源资源连接器添加到目录的请求,包括指定该资源连接器的必需属性。

POST https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackageResourceRequests
Content-type: application/json

{
  "catalogId": "bcb19bf7-cdf7-4a70-a106-f6543620b2a5",
  "accessPackageResource": {
    "id": "88eb460d-ca08-4eb9-afae-8d60a8b00377",
    "displayName": "SAP IAG Access Rights",
    "description": "This resource represents the business roles of SAP IAG",
    "resourceType": "Business role",
    "originId": "https://iagintgorg-iag-intg-space-java-rest-arqapi.cfapps.sap.hana.ondemand.com",
    "originSystem": "External",
    "accessPackageResourceScopes": [],
    "externalOriginResourceConnector": {
      "id": "1a53cea5-48bd-467c-af81-a24245b0df2b",
      "displayName": "SAP IAG 10.0",
      "description": "SAP IAG 10.0.0",
      "connectorType": "sapIag",
      "connectionInfo": {
        "@odata.type": "microsoft.graph.externalTokenBasedSapIagConnectionInfo",
        "url": "https://iagigorg-iag-intg-space-java-rest-arqapi.cfapps.sap.hana.ondemand.com",
        "subscriptionId": "8e072eb5-73f5-4ed2-9324-a734dcb9728",
        "resourceGroup": "SAPResourceGroup",
        "accessTokenUrl": "https://entra-docu-intg-mrrd3gv.authentication.sap.hana.ondemand.com/oauth/token",
        "clientId": "sb-72062308-a7ae-456f-b9a4-24302b8a4aa!b247012|iagapi-iag-intg-space!b11378",
        "keyVaultName": "SAPIAG-KV",
        "secretName": "ClientSecret"
      }
    },
    "accessPackageResourceEnvironment": null
  },
  "requestType": "AdminAdd",
  "history": [],
  "executeImmediately": true
}

响应

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

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

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

{
  "id": "0e37f047-c6b9-4d5c-99cd-e3fab4007be4",
  "requestType": "AdminAdd",
  "requestState": "Delivered",
  "requestStatus": "Fulfilled"
}

示例 8:向目录添加管理组资源

请求

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

POST https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackageResourceRequests
Content-type: application/json

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

响应

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

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

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

{
    "catalogId": "e8368470-afaf-44da-ba86-13a7318f1995",
    "id": "99e156fe-d152-4005-b019-6ba816f411ea",
    "justification": "",
    "requestState": "Delivered",
    "requestStatus": "Fulfilled",
    "requestType": "AdminAdd",
}

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

请求

以下示例显示了将订阅资源添加到目录的请求。

POST https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackageResourceRequests
Content-type: application/json

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

响应

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

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

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

{
    "catalogId": "e8368470-afaf-44da-ba86-13a7318f1995",
    "id": "13ac6518-0597-452c-98ff-59c52b391dae",
    "justification": "",
    "requestState": "Delivered",
    "requestStatus": "Fulfilled",
    "requestType": "AdminAdd",
}