强制删除域
本文内容
命名空间:microsoft.graph
使用异步长时间运行的操作删除域。
在调用 forceDelete 之前,必须更新或删除对 Exchange设置服务 的任何引用。
以下操作作为此操作的一部分执行:
userPrincipalName使用对mail已删除域proxyAddresses``users的引用更新 的 、 和 属性,以使用初始 onmicrosoft.com 域。
mail使用对已删除groups域的引用更新 的 属性,以使用初始 onmicrosoft.com 域。
identifierUris使用对已删除applications域的引用更新 的 属性,以使用初始 onmicrosoft.com 域。
如果要重命名的对象数大于 1000,则返回错误。
如果要重命名 applications 的 之一是多租户应用,则返回错误。
域删除完成后,已删除域的 API 操作将返回 HTTP 404 状态代码。 若要验证是否删除域,可以执行 get 域 操作。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
Domain.ReadWrite.All
委派(个人 Microsoft 帐户)
不支持。
应用程序
Domain.ReadWrite.All
HTTP 请求
POST /domains/{id}/forceDelete
对于 {id},请使用其完全限定的域名指定该域。
名称
说明
Authorization
Bearer {token}。必需。
Content-Type
application/json
请求正文
在请求正文中,提供具有以下参数的 JSON 对象。
参数
类型
说明
disableUserAccounts
Boolean
用于禁用重命名的用户帐户的选项。 如果禁用用户帐户,将不允许用户登录。 如果设置为 true ,将 users 禁用作为此操作的一部分进行更新。 默认值为 True 。
响应正文
如果成功,此方法将返回 HTTP/1.1 204 OK 状态代码。
示例
请求
POST https://graph.microsoft.com/v1.0/domains/{id}/forceDelete
Content-type: application/json
{
"disableUserAccounts": true
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var disableUserAccounts = true;
await graphClient.Domains["{domain-id}"]
.ForceDelete(disableUserAccounts)
.Request()
.PostAsync();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
const options = {
authProvider,
};
const client = Client.init(options);
const forceDelete = {
disableUserAccounts: true
};
await client.api('/domains/{id}/forceDelete')
.post(forceDelete);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/domains/{id}/forceDelete"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
BOOL disableUserAccounts = YES;
payloadDictionary[@"disableUserAccounts"] = disableUserAccounts;
NSData *data = [NSJSONSerialization dataWithJSONObject:payloadDictionary options:kNilOptions error:&error];
[urlRequest setHTTPBody:data];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
Boolean disableUserAccounts = true;
graphClient.domains("{id}")
.forceDelete(DomainForceDeleteParameterSet
.newBuilder()
.withDisableUserAccounts(disableUserAccounts)
.build())
.buildRequest()
.post();
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewDisableUserAccountsRequestBody()
disableUserAccounts := true
requestBody.SetDisableUserAccounts(&disableUserAccounts)
domainId := "domain-id"
graphClient.DomainsById(&domainId).ForceDelete(domain-id).Post(requestBody)
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
Import-Module Microsoft.Graph.Identity.DirectoryManagement
$params = @{
DisableUserAccounts = $true
}
Invoke-MgForceDomainDelete -DomainId $domainId -BodyParameter $params
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档 。
响应
HTTP/1.1 204 OK