命名空间:microsoft.graph
检索最近删除的目录对象的列表。 目前,仅 应用程序、 servicePrincipal、 组、 管理单元和 用户 资源支持已删除项功能。
注意: 已删除的安全组将永久删除,无法通过此 API 检索。
此 API 可用于以下国家级云部署。
全局服务 |
美国政府 L4 |
美国政府 L5 (DOD) |
由世纪互联运营的中国 |
✅ |
✅ |
✅ |
✅ |
权限
下表显示了对每种受支持的资源类型调用此 API 所需的最低特权权限。 请遵循 最佳做法 来请求最低特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。
支持的资源 |
委派(工作或学校帐户) |
委派(个人 Microsoft 帐户) |
应用程序 |
administrativeUnit |
AdministrativeUnit.Read.All |
不支持。 |
AdministrativeUnit.Read.All |
application |
Application.Read.All |
不支持。 |
Application.Read.All |
组 |
Group.Read.All |
不支持。 |
Group.Read.All |
servicePrincipal |
Application.Read.All |
不支持。 |
Application.Read.All |
用户 |
User.Read.All |
不支持。 |
User.Read.All |
重要
当应用程序查询返回 directoryObject 类型集合的关系时,如果它没有读取特定资源类型的权限,则会返回该类型的成员,但信息有限。 例如,仅返回对象类型和 ID 的 @odata.type 属性,而其他属性则指示为 null
。 通过此行为,应用程序可以请求所需的最低特权权限,而不是依赖于 目录集。*权限。 有关详细信息,请参阅为不可访问的成员对象返回有限的信息。
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
OData 强制转换类型是 URI 的必需部分,不支持在没有类型的情况下调用GET /directory/deleteditems
。
可选的查询参数
此方法支持由 OData 强制转换指定的资源支持的查询参数。 即 、$count
、$expand
、$filter
、$orderby
$search
、 $select
和 $top
查询参数。 此 API 默认返回 100 个对象,并支持使用 $top
每页最多返回 999 个对象。
只有将 ConsistencyLevel 标头设置为 eventual
和 $count
时,才支持某些查询。 例如:
GET 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/v1.0/directory/deletedItems/microsoft.graph.group
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Directory.DeletedItems.GraphGroup.GetAsync();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphGroup, err := graphClient.Directory().DeletedItems().GraphGroup().Get(context.Background(), nil)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
GroupCollectionResponse result = graphClient.directory().deletedItems().graphGroup().get();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
let group = await client.api('/directory/deletedItems/microsoft.graph.group')
.get();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
<?php
use Microsoft\Graph\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->directory()->deletedItems()->graphGroup()->get()->wait();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
Import-Module Microsoft.Graph.Identity.DirectoryManagement
Get-MgDirectoryDeletedItemAsGroup
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.directory.deleted_items.graph_group.get()
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
响应
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context":"https://graph.microsoft.com/v1.0/$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/v1.0/directory/deletedItems/microsoft.graph.group?$count=true&$orderby=deletedDateTime asc&$select=id,DisplayName,deletedDateTime
ConsistencyLevel: eventual
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Directory.DeletedItems.GraphGroup.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Count = true;
requestConfiguration.QueryParameters.Orderby = new string []{ "deletedDateTime asc" };
requestConfiguration.QueryParameters.Select = new string []{ "id","DisplayName","deletedDateTime" };
requestConfiguration.Headers.Add("ConsistencyLevel", "eventual");
});
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
mgc directory deleted-items graph-group get --count "true" --orderby "deletedDateTime asc" --select "id,DisplayName,deletedDateTime"
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
abstractions "github.com/microsoft/kiota-abstractions-go"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphdirectory "github.com/microsoftgraph/msgraph-sdk-go/directory"
//other-imports
)
headers := abstractions.NewRequestHeaders()
headers.Add("ConsistencyLevel", "eventual")
requestCount := true
requestParameters := &graphdirectory.DeletedItemsGraph.groupRequestBuilderGetQueryParameters{
Count: &requestCount,
Orderby: [] string {"deletedDateTime asc"},
Select: [] string {"id","DisplayName","deletedDateTime"},
}
configuration := &graphdirectory.DeletedItemsGraph.groupRequestBuilderGetRequestConfiguration{
Headers: headers,
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphGroup, err := graphClient.Directory().DeletedItems().GraphGroup().Get(context.Background(), configuration)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
GroupCollectionResponse result = graphClient.directory().deletedItems().graphGroup().get(requestConfiguration -> {
requestConfiguration.queryParameters.count = true;
requestConfiguration.queryParameters.orderby = new String []{"deletedDateTime asc"};
requestConfiguration.queryParameters.select = new String []{"id", "DisplayName", "deletedDateTime"};
requestConfiguration.headers.add("ConsistencyLevel", "eventual");
});
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
let group = await client.api('/directory/deletedItems/microsoft.graph.group')
.header('ConsistencyLevel','eventual')
.select('id,displayName,deletedDateTime')
.orderby('deletedDateTime asc')
.get();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Directory\DeletedItems\Graph\Group\GroupRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new GraphGroupRequestBuilderGetRequestConfiguration();
$headers = [
'ConsistencyLevel' => 'eventual',
];
$requestConfiguration->headers = $headers;
$queryParameters = GraphGroupRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->count = true;
$queryParameters->orderby = ["deletedDateTime asc"];
$queryParameters->select = ["id","DisplayName","deletedDateTime"];
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->directory()->deletedItems()->graphGroup()->get($requestConfiguration)->wait();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
Import-Module Microsoft.Graph.Identity.DirectoryManagement
Get-MgDirectoryDeletedItemAsGroup -CountVariable CountVar -Sort "deletedDateTime asc" -Property "id,DisplayName,deletedDateTime"
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.directory.deleted_items.graph.group.group_request_builder import GroupRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = GroupRequestBuilder.GroupRequestBuilderGetQueryParameters(
count = True,
orderby = ["deletedDateTime asc"],
select = ["id","DisplayName","deletedDateTime"],
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
request_configuration.headers.add("ConsistencyLevel", "eventual")
result = await graph_client.directory.deleted_items.graph_group.get(request_configuration = request_configuration)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
响应
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$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"
}
]
}