创建 accessPackageAssignmentRequest

命名空间:microsoft.graph

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

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

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

权限

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

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

HTTP 请求

POST /identityGovernance/entitlementManagement/assignmentRequests

请求标头

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

请求正文

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

对于要请求为用户创建分配的管理员,requestType 属性adminAdd的值为 ,分配属性包含targetId要分配的用户的 、用于标识 accessPackageAssignmentPolicyassignmentPolicyId 属性和标识 accessPackage 的 accessPackageId 属性。

对于管理员请求更新分配 (例如,扩展分配或更新) 问题的答案,requestType 属性的值为 adminUpdate,而 assignment 属性包含标识要更新的 accessPackageAssignment 的id 属性。

对于请求删除分配的管理员,requestType 属性adminRemove的值为 ,并且 assignment 属性包含标识要删除的 accessPackageAssignmentid 属性。

对于非管理员用户请求为第一个分配或续订分配创建自己的分配, requestType 属性的值为 userAdd赋值属性包含一个对象,该对象与targetId用户的 一起idassignmentPolicyId 属性标识 accessPackageAssignmentPolicyaccessPackageId 属性标识 accessPackage。 发出请求的用户必须已存在于 目录中。

对于非管理员用户请求更新其自己的分配, requestType 属性 userUpdate的值为 。 分配属性包含标识要更新的 accessPackageAssignment 的ID 属性。 计划属性包含更新的计划。

响应

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

如果这是 adminAdduserAdd 请求,则在任何审批后检查 accessPackageAssignment ,并根据需要创建 accessPackageSubject列出 accessPackageAssignments 时,可以使用查询参数查找这些参数。

示例

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

请求

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

POST https://graph.microsoft.com/v1.0/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/v1.0/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/v1.0/$metadata#accessPackageAssignmentRequests/$entity",
    "id": "78eaee8c-e6cf-48c9-8f99-aae44c35e379",
    "requestType": "adminRemove",
    "requestState": "Submitted",
    "requestStatus": "Accepted"
}

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

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

请求

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

POST https://graph.microsoft.com/v1.0/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/v1.0/$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/v1.0/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/v1.0/$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": []
}

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

请求

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

POST https://graph.microsoft.com/v1.0/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/v1.0/$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": []
}

示例 6:请求更新作业的答案

以下示例演示了管理员如何请求对分配的更新,以编辑他们对在请求分配期间回答的问题的响应。

请求

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

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

{
    "@odata.type": "#microsoft.graph.accessPackageAssignmentRequest",
    "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/v1.0/$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"
            }
        }
    ]
}

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

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

请求

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

POST https://graph.microsoft.com/v1.0/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/v1.0/$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": []
}

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

以下示例演示用户如何更新其答案以及访问包分配的到期日期。

请求

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

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

{
    "requestType": "userUpdate",
    "answers": [
        {
            "@odata.type": "#microsoft.graph.accessPackageAnswerString",
            "value": "My updated answer.",
            "answeredQuestion": {
                "@odata.type": "#microsoft.graph.accessPackageTextInputQuestion",
                "id": "0d31cc60-968e-4f92-955b-443fed03d6f6"
            }
        }

    ],
    "schedule": {
        "startDateTime": "2024-09-18T20:49:16.17Z",
        "recurrence": null,
        "expiration": {
            "endDateTime": "2024-10-18T20:49:15.17Z",
            "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/v1.0/$metadata#identityGovernance/entitlementManagement/assignmentRequests/$entity",
    "id": "e0f8458c-7681-42ad-a0b5-0c9587c4dad8",
    "requestType": "userUpdate",
    "state": "submitted",
    "status": "Accepted"
}