命名空间:microsoft.graph
重要
Microsoft Graph /beta 版本下的 API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
从已删除的项中检索最近 删除的目录对象的列表。 支持以下类型:
- administrativeUnit
- application
- agentIdentityBlueprint
- agentIdentity
- agentIdentityBlueprintPrincipal
- agentUser
- certificateBasedAuthPki
- certificateAuthorityDetail
- externalUserProfile
- 组
- pendingExternalUserProfile
- servicePrincipal
- 用户
此 API 可用于以下国家级云部署。
| 全局服务 | 美国政府 L4 | 美国政府 L5 (DOD) | 由世纪互联运营的中国 |
|---|---|---|---|
| ✅ | ✅ | ✅ | ✅ |
权限
下表显示了对每种受支持的资源类型调用此 API 所需的最低特权权限。 请遵循 最佳做法 来请求最低特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。
| 支持的资源 | 委派(工作或学校帐户) | 委派(个人 Microsoft 帐户) | 应用程序 |
|---|---|---|---|
| administrativeUnit | AdministrativeUnit.Read.All | 不支持。 | AdministrativeUnit.Read.All |
| application | Application.Read.All | 不支持。 | Application.Read.All |
| agentIdentity | AgentIdentity.Read.All | 不支持。 | AgentIdentity.Read.All |
| agentIdentityBlueprint | AgentIdentityBlueprint.Read.All | 不支持。 | AgentIdentityBlueprint.Read.All |
| agentIdentityBlueprintPrincipal | AgentIdentityBlueprintPrincipal.Read.All | 不支持。 | AgentIdentityBlueprintPrincipal.Read.All |
| agentUser | User.ReadBasic.All | 不支持。 | User.ReadBasic.All |
| externalUserProfile | ExternalUserProfile.Read.All | 不支持 | ExternalUserProfile.Read.All |
| 组 | Group.Read.All | 不支持。 | Group.Read.All |
| pendingExternalUserProfile | PendingExternalUserProfile.Read.All | 不支持 | PendingExternalUserProfile.Read.All |
| servicePrincipal | Application.Read.All | 不支持。 | Application.Read.All |
| user | User.Read.All | 不支持。 | User.Read.All |
| certificateBasedAuthPki | PublicKeyInfrastructure.Read.All | 不支持。 | PublicKeyInfrastructure.Read.All |
| certificateAuthorityDetail | PublicKeyInfrastructure.Read.All | 不支持。 | PublicKeyInfrastructure.Read.All |
重要
当应用程序查询返回 directoryObject 类型集合的关系时,如果它没有读取特定资源类型的权限,则会返回该类型的成员,但信息有限。 例如,仅返回对象类型和 ID 的 @odata.type 属性,而其他属性则指示为 null。 通过此行为,应用程序可以请求所需的最低特权权限,而不是依赖于 目录集。*权限。 有关详细信息,请参阅为不可访问的成员对象返回有限的信息。
重要
在具有工作或学校帐户的委托方案中,必须为登录用户分配受支持的Microsoft Entra角色或具有支持的角色权限的自定义角色。 此作支持以下最低特权角色。
- 代理标识:代理 ID 管理员
- 管理单元:目录读取器 (只读) 、全局读取者 (只读) 、特权角色管理员
- 应用程序:混合标识管理员、云应用程序管理员、应用程序管理员
- 外部用户配置文件:全局读取者 (只读) 、Skype for Business管理员、Teams 管理员
- 组:组管理员 () 可分配角色的组除外,用户管理员 (角色可分配组) 除外,特权角色管理员 (可分配组的最低特权角色)
- 挂起的外部用户配置文件:全局读取者 (只读) 、Skype for Business管理员、Teams 管理员
- 服务主体:混合标识管理员、云应用程序管理员、应用程序管理员
- 用户:身份验证管理员、特权身份验证管理员、用户管理员。 但是,若要还原具有特权管理员角色的用户,请执行以下作:
HTTP 请求
GET /directory/deleteditems/microsoft.graph.application
GET /directory/deleteditems/microsoft.graph.servicePrincipal
GET /directory/deleteditems/microsoft.graph.group
GET /directory/deletedItems/microsoft.graph.user
GET /directory/deletedItems/microsoft.graph.administrativeUnit
GET /directory/deletedItems/microsoft.graph.externalUserProfile
GET /directory/deletedItems/microsoft.graph.pendingExternalUserProfile
GET /directory/deletedItems/microsoft.graph.certificateBasedAuthPki
GET /directory/deletedItems/microsoft.graph.certificateAuthorityDetail
OData 强制转换类型是 URI 的必需部分,不支持在没有类型的情况下调用GET /directory/deleteditems。
可选的查询参数
此方法支持由 OData 强制转换指定的资源支持的查询参数。 即 、$count、$expand、$filter、$orderby$search、 $select和 $top 查询参数。 此 API 默认返回 100 个对象,并支持使用 $top每页最多返回 999 个对象。
只有将 ConsistencyLevel 标头设置为 eventual 和 $count 时,才支持某些查询。 例如:
https://graph.microsoft.com/beta/directory/deletedItems/microsoft.graph.group?&$count=true&$orderby=deletedDateTime desc&$select=id,displayName,deletedDateTime
ConsistencyLevel: eventual
此示例需要 ConsistencyLevel 标头, $orderby 因为 和 $count 查询参数在查询中使用。
$orderby OData 查询参数示例
已删除 $orderby 对象类型的 deletedDateTime、 displayName 和 userPrincipalName 属性支持 OData 查询参数。 在 deletedDateTime 属性上,查询需要添加 高级查询参数 (ConsistencyLevel 标头设置为 eventual 并将 $count=true 查询字符串) 。
| OData 强制转换 | 支持$orderby的属性 | 示例 |
|---|---|---|
| microsoft.graph.user | deletedDateTime, displayName, userPrincipalName | /directory/deletedItems/microsoft.graph.user?$orderby=userPrincipalName |
| microsoft.graph.group | deletedDateTime, displayName | /directory/deletedItems/microsoft.graph.group?$orderby=deletedDateTime asc&$count=true |
| microsoft.graph.application | deletedDateTime, displayName | /directory/deletedItems/microsoft.graph.application?$orderby=displayName |
| microsoft.graph.device | deletedDateTime, displayName | /directory/deletedItems/microsoft.graph.device?$orderby=deletedDateTime&$count=true |
请求标头
| 名称 | 说明 |
|---|---|
| Authorization | 持有者 {token}。 必填。 详细了解 身份验证和授权。 |
| 接受 | application/json |
请求正文
请勿提供此方法的请求正文。
响应
如果成功,此方法在响应正文中返回 200 OK 响应代码和 directoryObject 对象集合。
示例
示例 1:检索已删除的组
请求
GET https://graph.microsoft.com/beta/directory/deleteditems/microsoft.graph.group
响应
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/beta/$metadata#groups",
"value": [
{
"id":"46cc6179-19d0-473e-97ad-6ff84347bbbb",
"displayName":"SampleGroup",
"groupTypes":["Unified"],
"mail":"example@contoso.com",
"mailEnabled":true,
"mailNickname":"Example",
"securityEnabled":false,
"visibility":"Public"
}
]
}
示例 2:检索已删除的用户对象的计数,并按 deletedDateTime 属性对结果进行排序
请求
GET https://graph.microsoft.com/beta/directory/deletedItems/microsoft.graph.group?$count=true&$orderby=deletedDateTime asc&$select=id,displayName,deletedDateTime
ConsistencyLevel: eventual
响应
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#groups(id,displayName,deletedDateTime)",
"@odata.count": 2,
"value": [
{
"id": "c31799b8-0683-4d70-9e91-e032c89d3035",
"displayName": "Role assignable group",
"deletedDateTime": "2021-10-26T16:56:36Z"
},
{
"id": "74e45ce0-a52a-4766-976c-7201b0f99370",
"displayName": "Role assignable group",
"deletedDateTime": "2021-10-26T16:58:37Z"
}
]
}