L’une des autorisations suivantes est nécessaire pour appeler cette API. Pour plus d’informations, notamment sur la façon de choisir les autorisations, voir Autorisations.
Type d’autorisation
Autorisations (de celle qui offre le plus de privilèges à celle qui en offre le moins)
Déléguée (compte professionnel ou scolaire)
DeviceManagementConfiguration.ReadWrite.All
Déléguée (compte Microsoft personnel)
Non prise en charge.
Application
DeviceManagementConfiguration.ReadWrite.All
Requête HTTP
POST /deviceManagement/deviceCompliancePolicies/{deviceCompliancePolicyId}/userStatuses
Statut de conformité du rapport de stratégie. Les valeurs possibles sont les suivantes : unknown, notApplicable, compliant, remediated, nonCompliant, error, conflict et notAssigned.
lastReportedDateTime
DateTimeOffset
Dernière modification du rapport de stratégie.
userPrincipalName
String
UserPrincipalName.
Réponse
En cas de réussite, cette méthode renvoie un code de réponse 201 Created et un objet deviceComplianceUserStatus dans le corps de la réponse.
POST https://graph.microsoft.com/v1.0/deviceManagement/deviceCompliancePolicies/{deviceCompliancePolicyId}/userStatuses
Content-type: application/json
Content-length: 287
{
"@odata.type": "#microsoft.graph.deviceComplianceUserStatus",
"userDisplayName": "User Display Name value",
"devicesCount": 12,
"status": "notApplicable",
"lastReportedDateTime": "2017-01-01T00:00:17.7769392-08:00",
"userPrincipalName": "User Principal Name value"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new DeviceComplianceUserStatus
{
OdataType = "#microsoft.graph.deviceComplianceUserStatus",
UserDisplayName = "User Display Name value",
DevicesCount = 12,
Status = ComplianceStatus.NotApplicable,
LastReportedDateTime = DateTimeOffset.Parse("2017-01-01T00:00:17.7769392-08:00"),
UserPrincipalName = "User Principal Name value",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.DeviceManagement.DeviceCompliancePolicies["{deviceCompliancePolicy-id}"].UserStatuses.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
"time"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewDeviceComplianceUserStatus()
userDisplayName := "User Display Name value"
requestBody.SetUserDisplayName(&userDisplayName)
devicesCount := int32(12)
requestBody.SetDevicesCount(&devicesCount)
status := graphmodels.NOTAPPLICABLE_COMPLIANCESTATUS
requestBody.SetStatus(&status)
lastReportedDateTime , err := time.Parse(time.RFC3339, "2017-01-01T00:00:17.7769392-08:00")
requestBody.SetLastReportedDateTime(&lastReportedDateTime)
userPrincipalName := "User Principal Name value"
requestBody.SetUserPrincipalName(&userPrincipalName)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
userStatuses, err := graphClient.DeviceManagement().DeviceCompliancePolicies().ByDeviceCompliancePolicyId("deviceCompliancePolicy-id").UserStatuses().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
DeviceComplianceUserStatus deviceComplianceUserStatus = new DeviceComplianceUserStatus();
deviceComplianceUserStatus.setOdataType("#microsoft.graph.deviceComplianceUserStatus");
deviceComplianceUserStatus.setUserDisplayName("User Display Name value");
deviceComplianceUserStatus.setDevicesCount(12);
deviceComplianceUserStatus.setStatus(ComplianceStatus.NotApplicable);
OffsetDateTime lastReportedDateTime = OffsetDateTime.parse("2017-01-01T00:00:17.7769392-08:00");
deviceComplianceUserStatus.setLastReportedDateTime(lastReportedDateTime);
deviceComplianceUserStatus.setUserPrincipalName("User Principal Name value");
DeviceComplianceUserStatus result = graphClient.deviceManagement().deviceCompliancePolicies().byDeviceCompliancePolicyId("{deviceCompliancePolicy-id}").userStatuses().post(deviceComplianceUserStatus);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\DeviceComplianceUserStatus;
use Microsoft\Graph\Generated\Models\ComplianceStatus;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new DeviceComplianceUserStatus();
$requestBody->setOdataType('#microsoft.graph.deviceComplianceUserStatus');
$requestBody->setUserDisplayName('User Display Name value');
$requestBody->setDevicesCount(12);
$requestBody->setStatus(new ComplianceStatus('notApplicable'));
$requestBody->setLastReportedDateTime(new \DateTime('2017-01-01T00:00:17.7769392-08:00'));
$requestBody->setUserPrincipalName('User Principal Name value');
$result = $graphServiceClient->deviceManagement()->deviceCompliancePolicies()->byDeviceCompliancePolicyId('deviceCompliancePolicy-id')->userStatuses()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.device_compliance_user_status import DeviceComplianceUserStatus
from msgraph.generated.models.compliance_status import ComplianceStatus
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = DeviceComplianceUserStatus(
odata_type = "#microsoft.graph.deviceComplianceUserStatus",
user_display_name = "User Display Name value",
devices_count = 12,
status = ComplianceStatus.NotApplicable,
last_reported_date_time = "2017-01-01T00:00:17.7769392-08:00",
user_principal_name = "User Principal Name value",
)
result = await graph_client.device_management.device_compliance_policies.by_device_compliance_policy_id('deviceCompliancePolicy-id').user_statuses.post(request_body)
Voici un exemple de réponse. Remarque : l’objet de réponse illustré ici peut être tronqué à des fins de concision. Toutes les propriétés sont renvoyées à partir d’un appel réel.
HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 336
{
"@odata.type": "#microsoft.graph.deviceComplianceUserStatus",
"id": "a0b566cd-66cd-a0b5-cd66-b5a0cd66b5a0",
"userDisplayName": "User Display Name value",
"devicesCount": 12,
"status": "notApplicable",
"lastReportedDateTime": "2017-01-01T00:00:17.7769392-08:00",
"userPrincipalName": "User Principal Name value"
}