Erstellen Sie eine Schutzrichtlinie für den OneDrive-Dienst in Microsoft 365. Wenn die Richtlinie erstellt wird, wird ihr Status auf inactivefestgelegt. Benutzer können auch eine Liste der Schutzeinheiten unter der Richtlinie angeben.
Wählen Sie für diese API die Als am wenigsten privilegierten Berechtigungen gekennzeichneten Berechtigungen aus. Verwenden Sie nur dann eine Berechtigung mit höheren Berechtigungen , wenn dies für Ihre App erforderlich ist. Ausführliche Informationen zu delegierten Berechtigungen und Anwendungsberechtigungen finden Sie unter Berechtigungstypen. Weitere Informationen zu diesen Berechtigungen finden Sie in der Berechtigungsreferenz.
Berechtigungstyp
Berechtigungen mit den geringsten Berechtigungen
Berechtigungen mit höheren Berechtigungen
Delegiert (Geschäfts-, Schul- oder Unikonto)
BackupRestore-Configuration.ReadWrite.All
Nicht verfügbar.
Delegiert (persönliches Microsoft-Konto)
Nicht unterstützt
Nicht unterstützt
Anwendung
BackupRestore-Configuration.ReadWrite.All
Nicht verfügbar.
HTTP-Anforderung
POST /solutions/backupRestore/oneDriveForBusinessProtectionPolicies
POST https://graph.microsoft.com/v1.0/solutions/backupRestore/oneDriveForBusinessProtectionPolicies
{
"displayName": "OneDrive For Business Protection Policy",
"driveProtectionUnits": [
{
"directoryObjectId": "cdd3a849-dcaf-4a85-af82-7e39fc14019"
},
{
"directoryObjectId": "9bc069da-b746-41a4-89ab-26125c6373c7"
},
{
"directoryObjectId": "b218eb4a-ea72-42bd-8f0b-d0bbf794bec7"
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new OneDriveForBusinessProtectionPolicy
{
DisplayName = "OneDrive For Business Protection Policy",
DriveProtectionUnits = new List<DriveProtectionUnit>
{
new DriveProtectionUnit
{
DirectoryObjectId = "cdd3a849-dcaf-4a85-af82-7e39fc14019",
},
new DriveProtectionUnit
{
DirectoryObjectId = "9bc069da-b746-41a4-89ab-26125c6373c7",
},
new DriveProtectionUnit
{
DirectoryObjectId = "b218eb4a-ea72-42bd-8f0b-d0bbf794bec7",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Solutions.BackupRestore.OneDriveForBusinessProtectionPolicies.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
OneDriveForBusinessProtectionPolicy oneDriveForBusinessProtectionPolicy = new OneDriveForBusinessProtectionPolicy();
oneDriveForBusinessProtectionPolicy.setDisplayName("OneDrive For Business Protection Policy");
LinkedList<DriveProtectionUnit> driveProtectionUnits = new LinkedList<DriveProtectionUnit>();
DriveProtectionUnit driveProtectionUnit = new DriveProtectionUnit();
driveProtectionUnit.setDirectoryObjectId("cdd3a849-dcaf-4a85-af82-7e39fc14019");
driveProtectionUnits.add(driveProtectionUnit);
DriveProtectionUnit driveProtectionUnit1 = new DriveProtectionUnit();
driveProtectionUnit1.setDirectoryObjectId("9bc069da-b746-41a4-89ab-26125c6373c7");
driveProtectionUnits.add(driveProtectionUnit1);
DriveProtectionUnit driveProtectionUnit2 = new DriveProtectionUnit();
driveProtectionUnit2.setDirectoryObjectId("b218eb4a-ea72-42bd-8f0b-d0bbf794bec7");
driveProtectionUnits.add(driveProtectionUnit2);
oneDriveForBusinessProtectionPolicy.setDriveProtectionUnits(driveProtectionUnits);
OneDriveForBusinessProtectionPolicy result = graphClient.solutions().backupRestore().oneDriveForBusinessProtectionPolicies().post(oneDriveForBusinessProtectionPolicy);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\OneDriveForBusinessProtectionPolicy;
use Microsoft\Graph\Generated\Models\DriveProtectionUnit;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new OneDriveForBusinessProtectionPolicy();
$requestBody->setDisplayName('OneDrive For Business Protection Policy');
$driveProtectionUnitsDriveProtectionUnit1 = new DriveProtectionUnit();
$driveProtectionUnitsDriveProtectionUnit1->setDirectoryObjectId('cdd3a849-dcaf-4a85-af82-7e39fc14019');
$driveProtectionUnitsArray []= $driveProtectionUnitsDriveProtectionUnit1;
$driveProtectionUnitsDriveProtectionUnit2 = new DriveProtectionUnit();
$driveProtectionUnitsDriveProtectionUnit2->setDirectoryObjectId('9bc069da-b746-41a4-89ab-26125c6373c7');
$driveProtectionUnitsArray []= $driveProtectionUnitsDriveProtectionUnit2;
$driveProtectionUnitsDriveProtectionUnit3 = new DriveProtectionUnit();
$driveProtectionUnitsDriveProtectionUnit3->setDirectoryObjectId('b218eb4a-ea72-42bd-8f0b-d0bbf794bec7');
$driveProtectionUnitsArray []= $driveProtectionUnitsDriveProtectionUnit3;
$requestBody->setDriveProtectionUnits($driveProtectionUnitsArray);
$result = $graphServiceClient->solutions()->backupRestore()->oneDriveForBusinessProtectionPolicies()->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.one_drive_for_business_protection_policy import OneDriveForBusinessProtectionPolicy
from msgraph.generated.models.drive_protection_unit import DriveProtectionUnit
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = OneDriveForBusinessProtectionPolicy(
display_name = "OneDrive For Business Protection Policy",
drive_protection_units = [
DriveProtectionUnit(
directory_object_id = "cdd3a849-dcaf-4a85-af82-7e39fc14019",
),
DriveProtectionUnit(
directory_object_id = "9bc069da-b746-41a4-89ab-26125c6373c7",
),
DriveProtectionUnit(
directory_object_id = "b218eb4a-ea72-42bd-8f0b-d0bbf794bec7",
),
],
)
result = await graph_client.solutions.backup_restore.one_drive_for_business_protection_policies.post(request_body)