Erstellen Sie ein neues accessPackageResourceRoleScope zum Hinzufügen einer Ressourcenrolle zu einem Zugriffspaket. Die Zugriffspaketressource für eine Gruppe, eine App oder eine SharePoint Online-Website muss bereits im Zugriffspaketkatalog vorhanden sein, und die originId für die Ressourcenrolle muss aus der Liste der Ressourcenrollen abgerufen werden. Nachdem Sie dem Zugriffspaket den Ressourcenrollenbereich hinzugefügt haben, erhält der Benutzer diese Ressourcenrolle über alle aktuellen und zukünftigen Zugriffspaketzuweisungen.
Wählen Sie die Berechtigungen aus, die für diese API als am wenigsten privilegiert markiert sind. Verwenden Sie eine höhere Berechtigung oder Berechtigungen nur, wenn Ihre App dies erfordert. 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)
EntitlementManagement.ReadWrite.All
Nicht verfügbar.
Delegiert (persönliches Microsoft-Konto)
Nicht unterstützt
Nicht unterstützt
Anwendung
EntitlementManagement.ReadWrite.All
Nicht verfügbar.
Tipp
In delegierten Szenarien mit Geschäfts-, Schul- oder Unikonten muss dem angemeldeten Benutzer über eine der folgenden Optionen auch eine Administratorrolle mit unterstützten Rollenberechtigungen zugewiesen werden:
In reinen App-Szenarien kann der aufrufenden App anstelle EntitlementManagement.ReadWrite.All der Anwendungsberechtigung eine der oben genannten unterstützten Rollen zugewiesen werden. Die Rolle Access-Paket-Manager ist weniger privilegiert als die EntitlementManagement.ReadWrite.All Anwendungsberechtigung.
Bei erfolgreicher Ausführung gibt die Methode einen Antwortcode der 200er-Serie und ein neues accessPackageResourceRoleScope-Objekt im Antworttext zurück.
Beispiele
Beispiel 1: Hinzufügen einer SharePoint Online-Websiterolle zu einem Zugriffspaket
Anforderung
Das folgende Beispiel zeigt eine Anforderung zum Hinzufügen einer SharePoint Online-Websiterolle zur Liste der Ressourcenrollen eines Zugriffspakets. Die Zugriffspaketressource für den Standort muss bereits dem Zugriffspaketkatalog hinzugefügt worden sein, der dieses Zugriffspaket enthält.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new AccessPackageResourceRoleScope
{
Role = new AccessPackageResourceRole
{
DisplayName = "Contributors",
OriginSystem = "SharePointOnline",
OriginId = "4",
Resource = new AccessPackageResource
{
Id = "53c71803-a0a8-4777-aecc-075de8ee3991",
},
},
Scope = new AccessPackageResourceScope
{
DisplayName = "Root",
Description = "Root Scope",
OriginId = "https://contoso.sharepoint.com/portals/Community",
OriginSystem = "SharePointOnline",
IsRootScope = true,
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.IdentityGovernance.EntitlementManagement.AccessPackages["{accessPackage-id}"].ResourceRoleScopes.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
AccessPackageResourceRoleScope accessPackageResourceRoleScope = new AccessPackageResourceRoleScope();
AccessPackageResourceRole role = new AccessPackageResourceRole();
role.setDisplayName("Contributors");
role.setOriginSystem("SharePointOnline");
role.setOriginId("4");
AccessPackageResource resource = new AccessPackageResource();
resource.setId("53c71803-a0a8-4777-aecc-075de8ee3991");
role.setResource(resource);
accessPackageResourceRoleScope.setRole(role);
AccessPackageResourceScope scope = new AccessPackageResourceScope();
scope.setDisplayName("Root");
scope.setDescription("Root Scope");
scope.setOriginId("https://contoso.sharepoint.com/portals/Community");
scope.setOriginSystem("SharePointOnline");
scope.setIsRootScope(true);
accessPackageResourceRoleScope.setScope(scope);
AccessPackageResourceRoleScope result = graphClient.identityGovernance().entitlementManagement().accessPackages().byAccessPackageId("{accessPackage-id}").resourceRoleScopes().post(accessPackageResourceRoleScope);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\AccessPackageResourceRoleScope;
use Microsoft\Graph\Generated\Models\AccessPackageResourceRole;
use Microsoft\Graph\Generated\Models\AccessPackageResource;
use Microsoft\Graph\Generated\Models\AccessPackageResourceScope;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AccessPackageResourceRoleScope();
$role = new AccessPackageResourceRole();
$role->setDisplayName('Contributors');
$role->setOriginSystem('SharePointOnline');
$role->setOriginId('4');
$roleResource = new AccessPackageResource();
$roleResource->setId('53c71803-a0a8-4777-aecc-075de8ee3991');
$role->setResource($roleResource);
$requestBody->setRole($role);
$scope = new AccessPackageResourceScope();
$scope->setDisplayName('Root');
$scope->setDescription('Root Scope');
$scope->setOriginId('https://contoso.sharepoint.com/portals/Community');
$scope->setOriginSystem('SharePointOnline');
$scope->setIsRootScope(true);
$requestBody->setScope($scope);
$result = $graphServiceClient->identityGovernance()->entitlementManagement()->accessPackages()->byAccessPackageId('accessPackage-id')->resourceRoleScopes()->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.access_package_resource_role_scope import AccessPackageResourceRoleScope
from msgraph.generated.models.access_package_resource_role import AccessPackageResourceRole
from msgraph.generated.models.access_package_resource import AccessPackageResource
from msgraph.generated.models.access_package_resource_scope import AccessPackageResourceScope
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AccessPackageResourceRoleScope(
role = AccessPackageResourceRole(
display_name = "Contributors",
origin_system = "SharePointOnline",
origin_id = "4",
resource = AccessPackageResource(
id = "53c71803-a0a8-4777-aecc-075de8ee3991",
),
),
scope = AccessPackageResourceScope(
display_name = "Root",
description = "Root Scope",
origin_id = "https://contoso.sharepoint.com/portals/Community",
origin_system = "SharePointOnline",
is_root_scope = True,
),
)
result = await graph_client.identity_governance.entitlement_management.access_packages.by_access_package_id('accessPackage-id').resource_role_scopes.post(request_body)
Beispiel 2: Hinzufügen einer Anwendungsrolle zu einem Zugriffspaket
Anforderung
Das folgende Beispiel zeigt eine Anforderung, die der Liste der Ressourcenrollen eines Zugriffspakets die Rolle einer Anwendung hinzufügt. Die Zugriffspaketressource für die Anwendung muss dem Zugriffspaketkatalog, der dieses Zugriffspaket enthält, bereits hinzugefügt worden sein. , roleresource und scope können über eine Liste der Ressourcen eines Katalogs abgerufen werden.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new AccessPackageResourceRoleScope
{
Role = new AccessPackageResourceRole
{
Id = "cde82ecb-e461-496b-98fb-4f807c7ca640",
DisplayName = "Standard User",
Description = "Standard User",
OriginSystem = "AadApplication",
OriginId = "a29a7690-b3c4-4ed5-96c6-f640cde06fb8",
Resource = new AccessPackageResource
{
Id = "5f80c0c7-a180-4521-b585-18200048a0d8",
OriginId = "e81d7f57-0840-45e1-894b-f505c1bdcc1f",
OriginSystem = "AadApplication",
},
},
Scope = new AccessPackageResourceScope
{
Id = "dbeb8772-9907-4e95-a28e-a8d70dbcda69",
OriginId = "e81d7f57-0840-45e1-894b-f505c1bdcc1f",
OriginSystem = "AadApplication",
IsRootScope = true,
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.IdentityGovernance.EntitlementManagement.AccessPackages["{accessPackage-id}"].ResourceRoleScopes.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
AccessPackageResourceRoleScope accessPackageResourceRoleScope = new AccessPackageResourceRoleScope();
AccessPackageResourceRole role = new AccessPackageResourceRole();
role.setId("cde82ecb-e461-496b-98fb-4f807c7ca640");
role.setDisplayName("Standard User");
role.setDescription("Standard User");
role.setOriginSystem("AadApplication");
role.setOriginId("a29a7690-b3c4-4ed5-96c6-f640cde06fb8");
AccessPackageResource resource = new AccessPackageResource();
resource.setId("5f80c0c7-a180-4521-b585-18200048a0d8");
resource.setOriginId("e81d7f57-0840-45e1-894b-f505c1bdcc1f");
resource.setOriginSystem("AadApplication");
role.setResource(resource);
accessPackageResourceRoleScope.setRole(role);
AccessPackageResourceScope scope = new AccessPackageResourceScope();
scope.setId("dbeb8772-9907-4e95-a28e-a8d70dbcda69");
scope.setOriginId("e81d7f57-0840-45e1-894b-f505c1bdcc1f");
scope.setOriginSystem("AadApplication");
scope.setIsRootScope(true);
accessPackageResourceRoleScope.setScope(scope);
AccessPackageResourceRoleScope result = graphClient.identityGovernance().entitlementManagement().accessPackages().byAccessPackageId("{accessPackage-id}").resourceRoleScopes().post(accessPackageResourceRoleScope);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.access_package_resource_role_scope import AccessPackageResourceRoleScope
from msgraph.generated.models.access_package_resource_role import AccessPackageResourceRole
from msgraph.generated.models.access_package_resource import AccessPackageResource
from msgraph.generated.models.access_package_resource_scope import AccessPackageResourceScope
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AccessPackageResourceRoleScope(
role = AccessPackageResourceRole(
id = "cde82ecb-e461-496b-98fb-4f807c7ca640",
display_name = "Standard User",
description = "Standard User",
origin_system = "AadApplication",
origin_id = "a29a7690-b3c4-4ed5-96c6-f640cde06fb8",
resource = AccessPackageResource(
id = "5f80c0c7-a180-4521-b585-18200048a0d8",
origin_id = "e81d7f57-0840-45e1-894b-f505c1bdcc1f",
origin_system = "AadApplication",
),
),
scope = AccessPackageResourceScope(
id = "dbeb8772-9907-4e95-a28e-a8d70dbcda69",
origin_id = "e81d7f57-0840-45e1-894b-f505c1bdcc1f",
origin_system = "AadApplication",
is_root_scope = True,
),
)
result = await graph_client.identity_governance.entitlement_management.access_packages.by_access_package_id('accessPackage-id').resource_role_scopes.post(request_body)
Beispiel 3: Hinzufügen einer Gruppenmitgliedschaft zu einem Zugriffspaket
Anforderung
Das folgende Beispiel zeigt eine Anforderung zum Hinzufügen der Mitgliedschaft einer Gruppe zur Liste der Ressourcenrollen eines Zugriffspakets. Die Zugriffspaketressource für die Gruppe muss bereits dem Zugriffspaketkatalog hinzugefügt worden sein, der dieses Zugriffspaket enthält. , roleresource und scope können über eine Liste der Ressourcen eines Katalogs abgerufen werden.
POST https://graph.microsoft.com/v1.0/identityGovernance/entitlementManagement/accessPackages/cdd5f06b-752a-4c9f-97a6-82f4eda6c76d/resourceRoleScopes
Content-type: application/json
{
"role": {
"id": "748f8431-c7c6-404d-8564-df67aa8cfc5e",
"displayName": "Member",
"originSystem": "AadGroup",
"originId": "Member_0282e19d-bf41-435d-92a4-99bab93af305",
"resource": {
"id": "b16e0e71-17b4-4ebd-a3cd-8a468542e418",
"displayName": "example group",
"description": "a group whose members are to be assigned via an access package",
"originId": "0282e19d-bf41-435d-92a4-99bab93af305",
"originSystem": "AadGroup"
}
},
"scope": {
"id": "83b3e3e9-c8b3-481b-ad80-53e29d1eda9c",
"displayName": "Root",
"description": "Root Scope",
"originId": "0282e19d-bf41-435d-92a4-99bab93af305",
"originSystem": "AadGroup",
"isRootScope": true
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new AccessPackageResourceRoleScope
{
Role = new AccessPackageResourceRole
{
Id = "748f8431-c7c6-404d-8564-df67aa8cfc5e",
DisplayName = "Member",
OriginSystem = "AadGroup",
OriginId = "Member_0282e19d-bf41-435d-92a4-99bab93af305",
Resource = new AccessPackageResource
{
Id = "b16e0e71-17b4-4ebd-a3cd-8a468542e418",
DisplayName = "example group",
Description = "a group whose members are to be assigned via an access package",
OriginId = "0282e19d-bf41-435d-92a4-99bab93af305",
OriginSystem = "AadGroup",
},
},
Scope = new AccessPackageResourceScope
{
Id = "83b3e3e9-c8b3-481b-ad80-53e29d1eda9c",
DisplayName = "Root",
Description = "Root Scope",
OriginId = "0282e19d-bf41-435d-92a4-99bab93af305",
OriginSystem = "AadGroup",
IsRootScope = true,
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.IdentityGovernance.EntitlementManagement.AccessPackages["{accessPackage-id}"].ResourceRoleScopes.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
AccessPackageResourceRoleScope accessPackageResourceRoleScope = new AccessPackageResourceRoleScope();
AccessPackageResourceRole role = new AccessPackageResourceRole();
role.setId("748f8431-c7c6-404d-8564-df67aa8cfc5e");
role.setDisplayName("Member");
role.setOriginSystem("AadGroup");
role.setOriginId("Member_0282e19d-bf41-435d-92a4-99bab93af305");
AccessPackageResource resource = new AccessPackageResource();
resource.setId("b16e0e71-17b4-4ebd-a3cd-8a468542e418");
resource.setDisplayName("example group");
resource.setDescription("a group whose members are to be assigned via an access package");
resource.setOriginId("0282e19d-bf41-435d-92a4-99bab93af305");
resource.setOriginSystem("AadGroup");
role.setResource(resource);
accessPackageResourceRoleScope.setRole(role);
AccessPackageResourceScope scope = new AccessPackageResourceScope();
scope.setId("83b3e3e9-c8b3-481b-ad80-53e29d1eda9c");
scope.setDisplayName("Root");
scope.setDescription("Root Scope");
scope.setOriginId("0282e19d-bf41-435d-92a4-99bab93af305");
scope.setOriginSystem("AadGroup");
scope.setIsRootScope(true);
accessPackageResourceRoleScope.setScope(scope);
AccessPackageResourceRoleScope result = graphClient.identityGovernance().entitlementManagement().accessPackages().byAccessPackageId("{accessPackage-id}").resourceRoleScopes().post(accessPackageResourceRoleScope);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\AccessPackageResourceRoleScope;
use Microsoft\Graph\Generated\Models\AccessPackageResourceRole;
use Microsoft\Graph\Generated\Models\AccessPackageResource;
use Microsoft\Graph\Generated\Models\AccessPackageResourceScope;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AccessPackageResourceRoleScope();
$role = new AccessPackageResourceRole();
$role->setId('748f8431-c7c6-404d-8564-df67aa8cfc5e');
$role->setDisplayName('Member');
$role->setOriginSystem('AadGroup');
$role->setOriginId('Member_0282e19d-bf41-435d-92a4-99bab93af305');
$roleResource = new AccessPackageResource();
$roleResource->setId('b16e0e71-17b4-4ebd-a3cd-8a468542e418');
$roleResource->setDisplayName('example group');
$roleResource->setDescription('a group whose members are to be assigned via an access package');
$roleResource->setOriginId('0282e19d-bf41-435d-92a4-99bab93af305');
$roleResource->setOriginSystem('AadGroup');
$role->setResource($roleResource);
$requestBody->setRole($role);
$scope = new AccessPackageResourceScope();
$scope->setId('83b3e3e9-c8b3-481b-ad80-53e29d1eda9c');
$scope->setDisplayName('Root');
$scope->setDescription('Root Scope');
$scope->setOriginId('0282e19d-bf41-435d-92a4-99bab93af305');
$scope->setOriginSystem('AadGroup');
$scope->setIsRootScope(true);
$requestBody->setScope($scope);
$result = $graphServiceClient->identityGovernance()->entitlementManagement()->accessPackages()->byAccessPackageId('accessPackage-id')->resourceRoleScopes()->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.access_package_resource_role_scope import AccessPackageResourceRoleScope
from msgraph.generated.models.access_package_resource_role import AccessPackageResourceRole
from msgraph.generated.models.access_package_resource import AccessPackageResource
from msgraph.generated.models.access_package_resource_scope import AccessPackageResourceScope
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AccessPackageResourceRoleScope(
role = AccessPackageResourceRole(
id = "748f8431-c7c6-404d-8564-df67aa8cfc5e",
display_name = "Member",
origin_system = "AadGroup",
origin_id = "Member_0282e19d-bf41-435d-92a4-99bab93af305",
resource = AccessPackageResource(
id = "b16e0e71-17b4-4ebd-a3cd-8a468542e418",
display_name = "example group",
description = "a group whose members are to be assigned via an access package",
origin_id = "0282e19d-bf41-435d-92a4-99bab93af305",
origin_system = "AadGroup",
),
),
scope = AccessPackageResourceScope(
id = "83b3e3e9-c8b3-481b-ad80-53e29d1eda9c",
display_name = "Root",
description = "Root Scope",
origin_id = "0282e19d-bf41-435d-92a4-99bab93af305",
origin_system = "AadGroup",
is_root_scope = True,
),
)
result = await graph_client.identity_governance.entitlement_management.access_packages.by_access_package_id('accessPackage-id').resource_role_scopes.post(request_body)