从Active Directory(AD)删除用户后收到此通知(使用Microsoft Graph订阅):
{
"value": [
{
"changeType": "updated",
"clientState": null,
"resource": "Users/{user-id}",
"resourceData": {
"@odata.type": "#Microsoft.Graph.User",
"@odata.id": "Users/{user-id}",
"id": "{user-id}",
"organizationId": "{organisation-id}",
"sequenceNumber": hidden
},
"subscriptionExpirationDateTime": "2019-01-17T12:48:43.7825578+00:00",
"subscriptionId": "hidden",
"tenantId": "hidden"
}
]
}
接下来尝试从Microsoft图中获取此用户
/GET https://graph.microsoft.com/v1.0/users/{user-id}
并得到了
{
"error": {
"code": "Request_ResourceNotFound",
"message": "Resource '{user-id}' does not exist or one of its queried reference-property objects are not present.",
"innerError": {
"request-id": "{user-id}",
"date": "2019-01-15T13:41:49"
}
}
}
如果用户不存在,为什么通知带有 changeType ="已更新"?
从目录中删除用户时,它们将被"软删除"(这意味着仍然可以访问该对象 - 见下文,并还原)。这种类型的更改被建模为"更新"。我们计划在未来的版本中对此进行改进。
资源最终将被硬删除(通常在 30 天后),发生这种情况时,您将看到"已删除"通知。
无法使用users/id
访问软删除的用户 - 因此您会看到错误。
但是,可以使用特殊的deletedItems
API 访问 Azure AD 中的软删除资源:
https://learn.microsoft.com/en-us/graph/api/directory-deleteditems-get?view=graph-rest-1.0