Crie um novo accessPackageResourceRoleScope para adicionar uma função de recurso a um pacote de acesso. O recurso do pacote de acesso, para um grupo, uma aplicação ou um site do SharePoint Online, já tem de existir no catálogo de pacotes de acesso e o originId para a função de recurso obtida a partir da lista de funções de recursos. Depois de adicionar o âmbito da função de recurso ao pacote de acesso, o utilizador receberá esta função de recurso através de quaisquer atribuições de pacotes de acesso atuais e futuras.
Escolha a permissão ou permissões marcadas como menos privilegiadas para esta API. Utilize uma permissão ou permissões com privilégios mais elevados apenas se a sua aplicação o exigir. Para obter detalhes sobre as permissões delegadas e de aplicação, veja Tipos de permissão. Para saber mais sobre estas permissões, veja a referência de permissões.
Tipo de permissão
Permissões com menos privilégios
Permissões com privilégios superiores
Delegado (conta corporativa ou de estudante)
EntitlementManagement.ReadWrite.All
Indisponível.
Delegado (conta pessoal da Microsoft)
Sem suporte.
Sem suporte.
Application
EntitlementManagement.ReadWrite.All
Indisponível.
Dica
Em cenários delegados com contas escolares ou profissionais, o utilizador com sessão iniciada também tem de ter uma função de administrador com permissões de função suportadas através de uma das seguintes opções:
Em cenários apenas de aplicações, a aplicação de chamadas pode ser atribuída a uma das funções suportadas anteriores em vez da permissão da aplicação EntitlementManagement.ReadWrite.All . A função gestor de pacotes do Access tem menos privilégios do que a permissão da aplicação.EntitlementManagement.ReadWrite.All
Se for bem-sucedido, este método devolve um código de resposta de série 200 e um novo objeto accessPackageResourceRoleScope no corpo da resposta.
Exemplos
Exemplo 1: adicionar uma função de site do SharePoint Online a um pacote de acesso
Solicitação
O exemplo seguinte mostra um pedido que adiciona uma função de site do SharePoint Online à lista de funções de recursos de um pacote de acesso. O recurso do pacote de acesso para o site já deve ter sido adicionado ao catálogo de pacotes de acesso que contém este pacote de acesso.
// 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)
Exemplo 2: adicionar uma função de aplicação a um pacote de acesso
Solicitação
O exemplo seguinte mostra um pedido que adiciona a função de uma aplicação à lista de funções de recursos de um pacote de acesso. O recurso do pacote de acesso para a aplicação já deve ter sido adicionado ao catálogo de pacotes de acesso que contém este pacote de acesso. O rolee resourcescope podem ser obtidos por uma lista dos recursos de um catálogo.
// 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)
Exemplo 3: Adicionar associação a um grupo a um pacote de acesso
Solicitação
O exemplo seguinte mostra um pedido que adiciona a associação de um grupo à lista de funções de recursos de um pacote de acesso. O recurso do pacote de acesso para o grupo já deve ter sido adicionado ao catálogo de pacotes de acesso que contém este pacote de acesso. O rolee resourcescope podem ser obtidos por uma lista dos recursos de um catálogo.
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)