cloudPC:changeUserAccountType
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
更改特定云电脑上用户的帐户类型。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
CloudPC.ReadWrite.All
委派(个人 Microsoft 帐户)
不支持。
应用程序
CloudPC.ReadWrite.All
HTTP 请求
POST /deviceManagement/virtualEndpoint/cloudPCs/{cloudPCId}/changeUserAccountType
名称
说明
Authorization
Bearer {token}。必需。
Content-Type
application/json. Required.
请求正文
在请求正文中,提供参数的 JSON 表示形式。
下表显示了可用于此操作的参数。
参数
类型
说明
userAccountType
cloudPcUserAccountType
已预配云 PC 上的用户的帐户类型。 可能的值是:、standardUser``administrator和 unknownFutureValue。
响应
如果成功,此操作返回 204 No Content 响应代码。
示例
请求
POST https://graph.microsoft.com/beta/deviceManagement/virtualEndpoint/cloudPCs/4b5ad5e0-6a0b-4ffc-818d-36bb23cf4dbd/changeUserAccountType
Content-Type: application/json
Content-length: 35
{
"userAccountType": "administrator"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var userAccountType = CloudPcUserAccountType.Administrator;
await graphClient.DeviceManagement.VirtualEndpoint.CloudPCs["{cloudPC-id}"]
.ChangeUserAccountType(userAccountType)
.Request()
.PostAsync();
const options = {
authProvider,
};
const client = Client.init(options);
const changeUserAccountType = {
userAccountType: 'administrator'
};
await client.api('/deviceManagement/virtualEndpoint/cloudPCs/4b5ad5e0-6a0b-4ffc-818d-36bb23cf4dbd/changeUserAccountType')
.version('beta')
.post(changeUserAccountType);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/deviceManagement/virtualEndpoint/cloudPCs/4b5ad5e0-6a0b-4ffc-818d-36bb23cf4dbd/changeUserAccountType"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
NSMutableDictionary *payloadDictionary = [[NSMutableDictionary alloc] init];
MSGraphCloudPcUserAccountType *userAccountType = [MSGraphCloudPcUserAccountType administrator];
payloadDictionary[@"userAccountType"] = userAccountType;
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];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
CloudPcUserAccountType userAccountType = CloudPcUserAccountType.ADMINISTRATOR;
graphClient.deviceManagement().virtualEndpoint().cloudPCs("4b5ad5e0-6a0b-4ffc-818d-36bb23cf4dbd")
.changeUserAccountType(CloudPCChangeUserAccountTypeParameterSet
.newBuilder()
.withUserAccountType(userAccountType)
.build())
.buildRequest()
.post();
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewUserAccountTypeRequestBody()
userAccountType := "administrator"
requestBody.SetUserAccountType(&userAccountType)
cloudPCId := "cloudPC-id"
graphClient.DeviceManagement().VirtualEndpoint().CloudPCsById(&cloudPCId).ChangeUserAccountType(cloudPC-id).Post(requestBody)
Import-Module Microsoft.Graph.DeviceManagement.Actions
$params = @{
UserAccountType = "administrator"
}
Rename-MgDeviceManagementVirtualEndpointCloudPcUserAccountType -CloudPCId $cloudPCId -BodyParameter $params
响应
HTTP/1.1 204 No Content