创建 accessPackageAssignmentRequest

命名空间:microsoft.graph

重要

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

在 Microsoft Entra 权利管理中,创建新的 accessPackageAssignmentRequest 对象。 此操作用于将用户分配给访问包、更新分配或删除访问包分配。

API 可用性

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

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

权限

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

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

提示

使用工作或学校帐户 requestType 进行委派访问所需的角色和权限取决于所提交的请求。

最终用户请求 — userAdd、、userExtend、userUpdateuserRemove和approverRemove:

  • 登录用户 不需要 管理员角色。
  • 最低特权权限为 EntitlementMgmt-SubjectAccess.ReadWrite。
  • 仅仅保留权限是不够的 - 最终用户是否可以提交请求还受相应的 accessPackageAssignmentPolicy 的约束,该策略控制谁可以分配给访问包以及谁可以请求它 (requestorSettings) 。

管理员请求 — adminAdd、 adminUpdate、和 adminRemove:

  • 最低特权权限为 EntitlementManagement.ReadWrite.All。
  • 必须为登录用户分配受支持的管理员角色。 支持的角色,从最小特权到最高特权:

在仅限应用的情况下,可为调用应用分配上述支持的角色之一,而不是 EntitlementManagement.ReadWrite.All 应用程序权限。 访问包分配管理员角色的特EntitlementManagement.ReadWrite.All权低于应用程序权限。

有关详细信息,请参阅 权利管理中的委派和角色以及如何 将 访问治理委托给权利管理中的访问包管理员。

HTTP 请求

POST /identityGovernance/entitlementManagement/assignmentRequests

请求标头

名称 说明
Authorization 持有者 {token}。 必填。
Content-Type application/json. 必需。

请求正文

在请求正文中,提供 accessPackageAssignmentRequest 对象的 JSON 表示形式。

若要让管理员请求为用户创建作业,requestType 属性的值为 adminAdd,且分配属性包含具有要分配用户 ID 的 targetId、标识 accessPackageAssignmentPolicy 的 assignmentPolicyId 属性和标识 accessPackage 的 accessPackageId 属性。

管理员请求更新作业 (例如扩展作业或更新问题的答案 ) ,requestType 属性的值为 adminUpdate,并且分配属性包含标识要更新的 accessPackageAssignment 的 ID 属性。

若要让管理员请求删除作业,requestType 属性的值为 adminRemove,且分配属性包含标识要删除的 accessPackageAssignment 的 ID 属性。

若要使非管理员用户请求为第一个作业或续订作业创建自己的作业, requestType 属性的值为 userAdd。 赋值属性包含一个对象,该targetIdid对象具有 的 与 的。 assignmentPolicyId 属性标识 accessPackageAssignmentPolicy。 accessPackageId 属性标识 accessPackage。 发出请求的用户必须已存在于目录中。

若要使非管理员用户请求更新自己的作业, requestType 属性的值为 userUpdate。 分配属性包含用户的。targetIdid assignmentPolicyId 属性标识 accessPackageAssignmentPolicy。 accessPackageId 属性标识 accessPackage。 发出请求的用户必须已存在于目录中。

响应

如果成功,此方法将在响应正文中返回 200 系列响应代码和新的 accessPackageAssignmentRequest 对象。

如果请求类型用于 adminAdd 此请求,则还会创建 accessPackageAssignment ,如果需要,还会创建 accessPackageSubject 。 列出 accessPackageAssignments 时,可以使用查询参数定位这些对象。

示例

示例 1:管理员请求直接分配目录中已有的用户

请求

以下示例显示了一个直接分配请求,其中管理员请求为用户创建分配。 由于 accessPackageSubject 可能尚不存在,因此 targetID 的值是要分配的用户的对象 ID,accessPackageId 的值是该用户所需的访问包,而 assignmentPolicyId 的值是该访问包中的直接分配策略。

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

{
  "requestType": "adminAdd",
  "assignment":{
     "targetId":"46184453-e63b-4f20-86c2-c557ed5d5df9",
     "assignmentPolicyId":"2264bf65-76ba-417b-a27d-54d291f0cbc8",
     "accessPackageId":"a914b616-e04e-476b-aa37-91038f0b165b"
  }
}

响应

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

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

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

{
  "id": "46184453-e63b-4f20-86c2-c557ed5d5df9",
  "requestType": "adminAdd",
  "requestState": "Submitted",
  "requestStatus": "Accepted"
}

示例 2:删除作业

若要删除分配,请使用以下设置创建新的 accessPackageAssignmentRequest 对象:

  • requestType 属性的值设置为 adminRemove。
  • 在 分配 属性中,包含一个具有要删除的 accessPackageAssignment 对象标识符的对象。

请求

下面的示例演示如何删除作业。

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

{
    "requestType": "adminRemove",
    "assignment":{
     "id": "a6bb6942-3ae1-4259-9908-0133aaee9377"
    }
}

响应

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

注意:为了提高可读性,可能缩短了此处显示的响应对象。 所有属性均从实际调用返回。

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

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#accessPackageAssignmentRequests/$entity",
    "id": "78eaee8c-e6cf-48c9-8f99-aae44c35e379",
    "requestType": "adminRemove",
    "requestState": "Submitted",
    "requestStatus": "Accepted"
}

示例 3:通过提供问题答案来请求作业

下面的示例演示了用户如何通过在请求过程中回答策略要求的问题来请求自己的访问包分配。

请求

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

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

{
    "@odata.type": "#microsoft.graph.accessPackageAssignmentRequest",
    "requestType": "userAdd",
    "answers": [
        {
            "@odata.type": "#microsoft.graph.accessPackageAnswerString",
            "displayValue": "This is the answer to a multiple choice question",
            "value": "MultipleChoiceAnswerValue",
            "answeredQuestion": {
                "@odata.type": "#microsoft.graph.accessPackageMultipleChoiceQuestion",
                "id": "8fe745e7-80b2-490d-bd22-4e708c77288c"
            }
        },
        {
            "@odata.type": "#microsoft.graph.accessPackageAnswerString",
            "value": "This is my answer to a text input question.",
            "displayValue": "This is my answer.",
            "answeredQuestion": {
                "@odata.type": "#microsoft.graph.accessPackageTextInputQuestion",
                "id": "7aaa18c9-8e4f-440f-bd5a-3a7ce312cbe6"
            }
        }
    ],
    "assignment": {
        "accessPackageId": "977c7ff4-ef8f-4910-9d31-49048ddf3120"
    }
}

响应

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

注意:为了提高可读性,可能缩短了此处显示的响应对象。 所有属性均从实际调用返回。

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

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#accessPackageAssignmentRequests/$entity",
    "id": "7a6ab703-0780-4b37-8445-81f679b2d75c",
    "requestType": "userAdd",
    "state": "submitted",
    "status": "Accepted",
    "createdDateTime": null,
    "completedDateTime": null,
    "schedule": {
        "startDateTime": null,
        "recurrence": null,
        "expiration": {
            "endDateTime": null,
            "duration": null,
            "type": "notSpecified"
        }
    },
    "answers": [
        {
            "@odata.type": "#microsoft.graph.accessPackageAnswerString",
            "value": "MultipleChoiceAnswerValue",
            "answeredQuestion": {
                "@odata.type": "#microsoft.graph.accessPackageMultipleChoiceQuestion",
                "id": "8fe745e7-80b2-490d-bd22-4e708c77288c"   
            },
            "displayValue": "This is the answer to a multiple choice question"
        },
        {
            "@odata.type": "#microsoft.graph.accessPackageAnswerString",
            "value": "This is my answer to a text input question.",
            "answeredQuestion": {
                "@odata.type": "#microsoft.graph.accessPackageTextInputQuestion",
                "id": "7aaa18c9-8e4f-440f-bd5a-3a7ce312cbe6"
            },
            "displayValue": "This is my answer."
        }
    ]
}

示例 4: 请求包并提供理由

下面的示例显示了如何请求访问包并向审批者提供理由。

请求

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

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

{
    "requestType": "UserAdd",
    "accessPackageAssignment": {
        "accessPackageId": "a914b616-e04e-476b-aa37-91038f0b165b"
    },
    "justification":"Need access to New Hire access package"
}

响应

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

注意:为了提高可读性,可能缩短了此处显示的响应对象。 所有属性均从实际调用返回。

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

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#identityGovernance/entitlementManagement/assignmentRequests/$entity",
    "id": "9c1e258d-7723-43b1-ae21-e6eeeb324fe5",
    "requestType": "UserAdd",
    "requestState": "Submitted",
    "requestStatus": "Accepted",
    "createdDateTime": null,
    "completedDate": null,
    "justification": "Need access to New Hire access package",
    "isValidationOnly": false,
    "schedule": {
        "startDateTime": null,
        "recurrence": null,
        "expiration": {
            "endDateTime": null,
            "duration": null,
            "type": "notSpecified"
        }
    },
    "answers": [],
    "verifiedCredentialsData": [],
    "customExtensionHandlerInstances": [],
    "customExtensionCalloutInstances": []
}

示例 5:代表直接员工请求程序包

以下示例展示了经理如何代表其直接员工请求访问包分配。

注意

请求者 (经理) 从令牌中提取,目标对象由 id 接收访问权限的直接员工确定。

请求

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

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

{
   "assignment": {
       "accessPackageId": "5b98f958-0dea-4a5b-836e-109dccbd530c",
       "schedule": {
           "startDateTime": null,
           "stopDateTime": null
       },
       "assignmentPolicyId": "c5f7847f-83a8-4315-a754-d94a6f39b875",
       "target": {
           "displayName": "Idris Ibrahim",
           "email": "IdrisIbrahim@woodgrovebank.com",
           "objectId": "21aceaba-fe13-4e3b-aa8c-4c588d5e7387",
           "subjectType": "user"
       }
   },
   "justification": "Access for direct employee",
   "requestType": "UserAdd",
   "answers": []
}

响应

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

注意:为了提高可读性,可能缩短了此处显示的响应对象。 所有属性均从实际调用返回。

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

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#identityGovernance/entitlementManagement/assignmentRequests/$entity",
    "id": "445a3118-6bf2-4a19-94ad-5660295963fd",
    "requestType": "userAdd",
    "state": "submitted",
    "status": "Accepted",
    "createdDateTime": null,
    "completedDateTime": null,
    "schedule": {
        "startDateTime": null,
        "recurrence": null,
        "expiration": {
            "endDateTime": null,
            "duration": null,
            "type": "notSpecified"
        }
    },
    "answers": [],
    "customExtensionCalloutInstances": []
}

示例 6:管理员请求直接分配尚未在目录中的用户

请求

下面的示例显示了一个直接分配请求,其中管理员请求为目录中不存在的用户创建作业。 accessPackageId 的值是该用户所需的访问包,assignmentPolicyId 的值是该访问包中的直接分配策略。

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

{
  "requestType": "AdminAdd",
  "accessPackageAssignment":{
     "target": {
        "email": "user@contoso.com"
     },
     "assignmentPolicyId":"2264bf65-76ba-417b-a27d-54d291f0cbc8",
     "accessPackageId":"a914b616-e04e-476b-aa37-91038f0b165b"
  }
}

响应

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

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

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

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#identityGovernance/entitlementManagement/assignmentRequests/$entity",
    "id": "cb32aef9-2976-496d-9804-eb432fd894a7",
    "requestType": "AdminAdd",
    "requestState": "Submitted",
    "requestStatus": "Accepted",
    "createdDateTime": null,
    "completedDate": null,
    "justification": null,
    "isValidationOnly": false,
    "schedule": {
        "startDateTime": null,
        "recurrence": null,
        "expiration": {
            "endDateTime": null,
            "duration": null,
            "type": "notSpecified"
        }
    },
    "answers": [],
    "verifiedCredentialsData": [],
    "customExtensionHandlerInstances": [],
    "customExtensionCalloutInstances": []
}

示例 7:请求更新作业答案

下面的示例展示了管理员如何请求对作业进行更新,以编辑他们对在请求作业期间回答的问题的答复。

请求

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

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

{
    "@odata.type": "#microsoft.graph.accessPackageAssignmentRequest",
    "id": "7a6ab703-0780-4b37-8445-81f679b2d75c",
    "requestType": "adminUpdate",
    "answers": [
        {
            "@odata.type": "#microsoft.graph.accessPackageAnswerString",
            "value": "UpdatedAnswerValue",
            "answeredQuestion": {
                "@odata.type": "#microsoft.graph.accessPackageMultipleChoiceQuestion",
                "id": "8fe745e7-80b2-490d-bd22-4e708c77288c"
            }
        },
        {
            "@odata.type": "#microsoft.graph.accessPackageAnswerString",
            "value": "My updated answer.",
            "displayValue": "This is my updated answer to the question.",
            "answeredQuestion": {
                "@odata.type": "#microsoft.graph.accessPackageTextInputQuestion",
                "id": "7aaa18c9-8e4f-440f-bd5a-3a7ce312cbe6"
            }
        }
    ],
    "assignment": {
        "id": "44c741c1-2cf4-40db-83b6-e0112f8e5a83"
    }
}

响应

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

注意:为了提高可读性,可能缩短了此处显示的响应对象。 所有属性均从实际调用返回。

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

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#accessPackageAssignmentRequests/$entity",
    "id": "0c471116-e439-40a6-8441-fe739dd48dab",
    "requestType": "adminUpdate",
    "state": "submitted",
    "status": "Accepted",
    "createdDateTime": null,
    "completedDateTime": null,
    "schedule": {
        "startDateTime": null,
        "recurrence": null,
        "expiration": {
            "endDateTime": null,
            "duration": null,
            "type": "notSpecified"
        }
    },
    "answers": [
        {
            "@odata.type": "#microsoft.graph.accessPackageAnswerString",
            "value": "UpdatedAnswerValue",
            "displayValue": "This is the answer to a multiple choice question",
            "answeredQuestion": {
                "@odata.type": "#microsoft.graph.accessPackageMultipleChoiceQuestion",
                "id": "8fe745e7-80b2-490d-bd22-4e708c77288c"   
            }         
        },
        {
            "@odata.type": "#microsoft.graph.accessPackageAnswerString",
            "value": "My updated answer.",
            "displayValue": "This is my updated answer to the question.",
            "answeredQuestion": {
                "@odata.type": "#microsoft.graph.accessPackageTextInputQuestion",
                "id": "7aaa18c9-8e4f-440f-bd5a-3a7ce312cbe6"
            }
        }
    ]
}

示例 8:更新访问包分配的到期日期

以下示例演示如何更新访问包分配的到期日期。

请求

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

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

{
    "@odata.type": "#microsoft.graph.accessPackageAssignmentRequest",
    "requestType": "adminUpdate",
    "schedule": {
        "startDateTime": "2023-05-23T20:04:02.39Z",
        "recurrence": null,
        "expiration": {
            "endDateTime": "2024-07-01T00:00:00.00Z",
            "duration": null,
            "type": "afterDateTime"
        }
    },
    "assignment": {
        "id": "329f8dac-8062-4c1b-a9b8-39b7132f9bff"
    }
}

响应

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

注意:为了提高可读性,可能缩短了此处显示的响应对象。 所有属性均从实际调用返回。

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

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#identityGovernance/entitlementManagement/assignmentRequests/$entity",
    "id": "5b682fbb-d6e5-4118-a471-46dfc553e9cc",
    "requestType": "adminUpdate",
    "state": "submitted",
    "status": "Accepted",
    "createdDateTime": null,
    "completedDateTime": null,
    "schedule": {
        "startDateTime": "2024-06-07T15:53:35.333Z",
        "recurrence": null,
        "expiration": {
            "endDateTime": "2024-07-01T00:00:00Z",
            "duration": null,
            "type": "afterDateTime"
        }
    },
    "answers": [],
    "customExtensionCalloutInstances": []
}