Erstellen Sie ein neues accessPackageResourceRequest-Objekt , um das Hinzufügen einer Ressource zu einem Zugriffspaketkatalog, das Aktualisieren einer Ressource oder das Entfernen einer Ressource aus einem Katalog anzufordern. Eine Ressource muss in einen Zugriffspaketkatalog aufgenommen werden, bevor eine Rolle dieser Ressource einem Zugriffspaket hinzugefügt werden kann.
Um einem Katalog eine Microsoft Entra Gruppe als Ressource hinzuzufügen, legen Sie den requestType auf adminAddfest, und legen Sie einen resource fest, der die Ressource darstellt. Der Wert der originSystem-Eigenschaft innerhalb der resource sollte sein AadGroup , und der Wert der originId ist der Bezeichner der Gruppe.
Um einem Katalog eine Microsoft Entra Anwendung als Ressource hinzuzufügen, legen Sie den requestType auf adminAddfest, und legen Sie eine resource fest, die die Ressource darstellt. Der Wert der originSystem-Eigenschaft innerhalb der resource sollte sein AadApplication , und der Wert der originId ist der Bezeichner von servicePrincipal.
Um eine SharePoint Online-Website als Ressource zu einem Katalog hinzuzufügen, legen Sie den requestType auf adminAddfest, und legen Sie eine resource fest, die die Ressource darstellt. Der Wert der originSystem-Eigenschaft innerhalb der resource sollte sein SharePointOnline , und der Wert der originId ist der URI der Website.
Um eine Ressource aus einem Katalog zu entfernen, legen Sie den requestType auf adminRemovefest, und legen Sie fest resource , dass der des id zu entfernenden Ressourcenobjekts enthalten ist. Das Ressourcenobjekt kann mithilfe von Listenressourcen abgerufen werden.
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:
Eine Rolle im Berechtigungsverwaltungssystem , bei der die Rolle mit den geringsten Berechtigungen Katalogbesitzer ist.
Dies ist die Option mit den geringsten Rechten.
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 Katalogbesitzer ist weniger privilegiert als die EntitlementManagement.ReadWrite.All Anwendungsberechtigung.
Darüber hinaus müssen Sie über die folgenden Berechtigungen für die ressource verfügen, die hinzugefügt wird:
So fügen Sie einem Katalog eine Microsoft Entra Gruppe als Ressource hinzu:
Wenn Delegierte Berechtigungen verwendet werden, sollte der Benutzer, der das Hinzufügen einer Gruppe anfordert, Besitzer der Gruppe oder in einer Verzeichnisrolle sein, die es dem Benutzer ermöglicht, Gruppen zu ändern.
Wenn Sie Anwendungsberechtigungen verwenden, sollte der Anwendung, die das Hinzufügen der Gruppe anfordert, auch die Group.ReadWrite.All Berechtigung zugewiesen werden.
So fügen Sie einem Katalog eine Microsoft Entra Anwendung als Ressource hinzu:
Bei Verwendung delegierter Berechtigungen sollte der Benutzer, der das Hinzufügen einer Anwendung anfordert, Besitzer der Anwendung oder in einer Verzeichnisrolle sein, die es ihnen ermöglicht, Anwendungsrollenzuweisungen zu ändern.
Wenn Sie Anwendungsberechtigungen verwenden, sollte der Anwendung, die das Hinzufügen von servicePrincipal anfordert, auch die Berechtigung Application.ReadWrite.All zugewiesen werden.
So fügen Sie eine SharePoint Online-Website als Ressource zu einem Katalog hinzu:
Wenn delegierte Berechtigungen verwendet werden, sollte der Benutzer, der die Website hinzufügen möchte, eine Rolle besitzen, die es ihnen ermöglicht, die SharePoint-Websiterollen zu ändern, z. B. die SharePoint-Administratorrolle .
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new AccessPackageResourceRequest
{
RequestType = AccessPackageRequestType.AdminAdd,
Resource = new AccessPackageResource
{
DisplayName = "Test group",
OriginId = "8ab659d0-3839-427d-8c54-5ae92f0b3e2e",
OriginSystem = "AadGroup",
},
Catalog = new AccessPackageCatalog
{
Id = "beedadfe-01d5-4025-910b-84abb9369997",
},
};
// 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.ResourceRequests.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
AccessPackageResourceRequest accessPackageResourceRequest = new AccessPackageResourceRequest();
accessPackageResourceRequest.setRequestType(AccessPackageRequestType.AdminAdd);
AccessPackageResource resource = new AccessPackageResource();
resource.setDisplayName("Test group");
resource.setOriginId("8ab659d0-3839-427d-8c54-5ae92f0b3e2e");
resource.setOriginSystem("AadGroup");
accessPackageResourceRequest.setResource(resource);
AccessPackageCatalog catalog = new AccessPackageCatalog();
catalog.setId("beedadfe-01d5-4025-910b-84abb9369997");
accessPackageResourceRequest.setCatalog(catalog);
AccessPackageResourceRequest result = graphClient.identityGovernance().entitlementManagement().resourceRequests().post(accessPackageResourceRequest);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\AccessPackageResourceRequest;
use Microsoft\Graph\Generated\Models\AccessPackageRequestType;
use Microsoft\Graph\Generated\Models\AccessPackageResource;
use Microsoft\Graph\Generated\Models\AccessPackageCatalog;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AccessPackageResourceRequest();
$requestBody->setRequestType(new AccessPackageRequestType('adminAdd'));
$resource = new AccessPackageResource();
$resource->setDisplayName('Test group');
$resource->setOriginId('8ab659d0-3839-427d-8c54-5ae92f0b3e2e');
$resource->setOriginSystem('AadGroup');
$requestBody->setResource($resource);
$catalog = new AccessPackageCatalog();
$catalog->setId('beedadfe-01d5-4025-910b-84abb9369997');
$requestBody->setCatalog($catalog);
$result = $graphServiceClient->identityGovernance()->entitlementManagement()->resourceRequests()->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_request import AccessPackageResourceRequest
from msgraph.generated.models.access_package_request_type import AccessPackageRequestType
from msgraph.generated.models.access_package_resource import AccessPackageResource
from msgraph.generated.models.access_package_catalog import AccessPackageCatalog
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AccessPackageResourceRequest(
request_type = AccessPackageRequestType.AdminAdd,
resource = AccessPackageResource(
display_name = "Test group",
origin_id = "8ab659d0-3839-427d-8c54-5ae92f0b3e2e",
origin_system = "AadGroup",
),
catalog = AccessPackageCatalog(
id = "beedadfe-01d5-4025-910b-84abb9369997",
),
)
result = await graph_client.identity_governance.entitlement_management.resource_requests.post(request_body)
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new AccessPackageResourceRequest
{
RequestType = AccessPackageRequestType.AdminAdd,
Resource = new AccessPackageResource
{
OriginId = "e81d7f57-0840-45e1-894b-f505c1bdcc1f",
OriginSystem = "AadApplication",
},
Catalog = new AccessPackageCatalog
{
Id = "beedadfe-01d5-4025-910b-84abb9369997",
},
};
// 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.ResourceRequests.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewAccessPackageResourceRequest()
requestType := graphmodels.ADMINADD_ACCESSPACKAGEREQUESTTYPE
requestBody.SetRequestType(&requestType)
resource := graphmodels.NewAccessPackageResource()
originId := "e81d7f57-0840-45e1-894b-f505c1bdcc1f"
resource.SetOriginId(&originId)
originSystem := "AadApplication"
resource.SetOriginSystem(&originSystem)
requestBody.SetResource(resource)
catalog := graphmodels.NewAccessPackageCatalog()
id := "beedadfe-01d5-4025-910b-84abb9369997"
catalog.SetId(&id)
requestBody.SetCatalog(catalog)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
resourceRequests, err := graphClient.IdentityGovernance().EntitlementManagement().ResourceRequests().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
AccessPackageResourceRequest accessPackageResourceRequest = new AccessPackageResourceRequest();
accessPackageResourceRequest.setRequestType(AccessPackageRequestType.AdminAdd);
AccessPackageResource resource = new AccessPackageResource();
resource.setOriginId("e81d7f57-0840-45e1-894b-f505c1bdcc1f");
resource.setOriginSystem("AadApplication");
accessPackageResourceRequest.setResource(resource);
AccessPackageCatalog catalog = new AccessPackageCatalog();
catalog.setId("beedadfe-01d5-4025-910b-84abb9369997");
accessPackageResourceRequest.setCatalog(catalog);
AccessPackageResourceRequest result = graphClient.identityGovernance().entitlementManagement().resourceRequests().post(accessPackageResourceRequest);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\AccessPackageResourceRequest;
use Microsoft\Graph\Generated\Models\AccessPackageRequestType;
use Microsoft\Graph\Generated\Models\AccessPackageResource;
use Microsoft\Graph\Generated\Models\AccessPackageCatalog;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AccessPackageResourceRequest();
$requestBody->setRequestType(new AccessPackageRequestType('adminAdd'));
$resource = new AccessPackageResource();
$resource->setOriginId('e81d7f57-0840-45e1-894b-f505c1bdcc1f');
$resource->setOriginSystem('AadApplication');
$requestBody->setResource($resource);
$catalog = new AccessPackageCatalog();
$catalog->setId('beedadfe-01d5-4025-910b-84abb9369997');
$requestBody->setCatalog($catalog);
$result = $graphServiceClient->identityGovernance()->entitlementManagement()->resourceRequests()->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_request import AccessPackageResourceRequest
from msgraph.generated.models.access_package_request_type import AccessPackageRequestType
from msgraph.generated.models.access_package_resource import AccessPackageResource
from msgraph.generated.models.access_package_catalog import AccessPackageCatalog
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AccessPackageResourceRequest(
request_type = AccessPackageRequestType.AdminAdd,
resource = AccessPackageResource(
origin_id = "e81d7f57-0840-45e1-894b-f505c1bdcc1f",
origin_system = "AadApplication",
),
catalog = AccessPackageCatalog(
id = "beedadfe-01d5-4025-910b-84abb9369997",
),
)
result = await graph_client.identity_governance.entitlement_management.resource_requests.post(request_body)
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new AccessPackageResourceRequest
{
RequestType = AccessPackageRequestType.AdminAdd,
Resource = new AccessPackageResource
{
OriginId = "https://microsoft.sharepoint.com/sites/Example",
OriginSystem = "SharePointOnline",
},
Catalog = new AccessPackageCatalog
{
Id = "beedadfe-01d5-4025-910b-84abb9369997",
},
};
// 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.ResourceRequests.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewAccessPackageResourceRequest()
requestType := graphmodels.ADMINADD_ACCESSPACKAGEREQUESTTYPE
requestBody.SetRequestType(&requestType)
resource := graphmodels.NewAccessPackageResource()
originId := "https://microsoft.sharepoint.com/sites/Example"
resource.SetOriginId(&originId)
originSystem := "SharePointOnline"
resource.SetOriginSystem(&originSystem)
requestBody.SetResource(resource)
catalog := graphmodels.NewAccessPackageCatalog()
id := "beedadfe-01d5-4025-910b-84abb9369997"
catalog.SetId(&id)
requestBody.SetCatalog(catalog)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
resourceRequests, err := graphClient.IdentityGovernance().EntitlementManagement().ResourceRequests().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
AccessPackageResourceRequest accessPackageResourceRequest = new AccessPackageResourceRequest();
accessPackageResourceRequest.setRequestType(AccessPackageRequestType.AdminAdd);
AccessPackageResource resource = new AccessPackageResource();
resource.setOriginId("https://microsoft.sharepoint.com/sites/Example");
resource.setOriginSystem("SharePointOnline");
accessPackageResourceRequest.setResource(resource);
AccessPackageCatalog catalog = new AccessPackageCatalog();
catalog.setId("beedadfe-01d5-4025-910b-84abb9369997");
accessPackageResourceRequest.setCatalog(catalog);
AccessPackageResourceRequest result = graphClient.identityGovernance().entitlementManagement().resourceRequests().post(accessPackageResourceRequest);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\AccessPackageResourceRequest;
use Microsoft\Graph\Generated\Models\AccessPackageRequestType;
use Microsoft\Graph\Generated\Models\AccessPackageResource;
use Microsoft\Graph\Generated\Models\AccessPackageCatalog;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AccessPackageResourceRequest();
$requestBody->setRequestType(new AccessPackageRequestType('adminAdd'));
$resource = new AccessPackageResource();
$resource->setOriginId('https://microsoft.sharepoint.com/sites/Example');
$resource->setOriginSystem('SharePointOnline');
$requestBody->setResource($resource);
$catalog = new AccessPackageCatalog();
$catalog->setId('beedadfe-01d5-4025-910b-84abb9369997');
$requestBody->setCatalog($catalog);
$result = $graphServiceClient->identityGovernance()->entitlementManagement()->resourceRequests()->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_request import AccessPackageResourceRequest
from msgraph.generated.models.access_package_request_type import AccessPackageRequestType
from msgraph.generated.models.access_package_resource import AccessPackageResource
from msgraph.generated.models.access_package_catalog import AccessPackageCatalog
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AccessPackageResourceRequest(
request_type = AccessPackageRequestType.AdminAdd,
resource = AccessPackageResource(
origin_id = "https://microsoft.sharepoint.com/sites/Example",
origin_system = "SharePointOnline",
),
catalog = AccessPackageCatalog(
id = "beedadfe-01d5-4025-910b-84abb9369997",
),
)
result = await graph_client.identity_governance.entitlement_management.resource_requests.post(request_body)
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new AccessPackageResourceRequest
{
RequestType = AccessPackageRequestType.AdminRemove,
Resource = new AccessPackageResource
{
Id = "1d0bb962-5bb0-4b16-a488-fda7a788b9ec",
},
Catalog = new AccessPackageCatalog
{
Id = "beedadfe-01d5-4025-910b-84abb9369997",
},
};
// 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.ResourceRequests.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewAccessPackageResourceRequest()
requestType := graphmodels.ADMINREMOVE_ACCESSPACKAGEREQUESTTYPE
requestBody.SetRequestType(&requestType)
resource := graphmodels.NewAccessPackageResource()
id := "1d0bb962-5bb0-4b16-a488-fda7a788b9ec"
resource.SetId(&id)
requestBody.SetResource(resource)
catalog := graphmodels.NewAccessPackageCatalog()
id := "beedadfe-01d5-4025-910b-84abb9369997"
catalog.SetId(&id)
requestBody.SetCatalog(catalog)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
resourceRequests, err := graphClient.IdentityGovernance().EntitlementManagement().ResourceRequests().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
AccessPackageResourceRequest accessPackageResourceRequest = new AccessPackageResourceRequest();
accessPackageResourceRequest.setRequestType(AccessPackageRequestType.AdminRemove);
AccessPackageResource resource = new AccessPackageResource();
resource.setId("1d0bb962-5bb0-4b16-a488-fda7a788b9ec");
accessPackageResourceRequest.setResource(resource);
AccessPackageCatalog catalog = new AccessPackageCatalog();
catalog.setId("beedadfe-01d5-4025-910b-84abb9369997");
accessPackageResourceRequest.setCatalog(catalog);
AccessPackageResourceRequest result = graphClient.identityGovernance().entitlementManagement().resourceRequests().post(accessPackageResourceRequest);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\AccessPackageResourceRequest;
use Microsoft\Graph\Generated\Models\AccessPackageRequestType;
use Microsoft\Graph\Generated\Models\AccessPackageResource;
use Microsoft\Graph\Generated\Models\AccessPackageCatalog;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AccessPackageResourceRequest();
$requestBody->setRequestType(new AccessPackageRequestType('adminRemove'));
$resource = new AccessPackageResource();
$resource->setId('1d0bb962-5bb0-4b16-a488-fda7a788b9ec');
$requestBody->setResource($resource);
$catalog = new AccessPackageCatalog();
$catalog->setId('beedadfe-01d5-4025-910b-84abb9369997');
$requestBody->setCatalog($catalog);
$result = $graphServiceClient->identityGovernance()->entitlementManagement()->resourceRequests()->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_request import AccessPackageResourceRequest
from msgraph.generated.models.access_package_request_type import AccessPackageRequestType
from msgraph.generated.models.access_package_resource import AccessPackageResource
from msgraph.generated.models.access_package_catalog import AccessPackageCatalog
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = AccessPackageResourceRequest(
request_type = AccessPackageRequestType.AdminRemove,
resource = AccessPackageResource(
id = "1d0bb962-5bb0-4b16-a488-fda7a788b9ec",
),
catalog = AccessPackageCatalog(
id = "beedadfe-01d5-4025-910b-84abb9369997",
),
)
result = await graph_client.identity_governance.entitlement_management.resource_requests.post(request_body)
Beispiel 5: Erstellen einer accessPackageResourceRequest zum Aktualisieren einer Anwendung als Ressource mit Attributen
Das folgende Beispiel zeigt eine Anforderung zum Aktualisieren einer Ressource in einem Katalog für eine Anwendung, die bereits als Ressource hinzugefügt wurde, mit zwei Attributen.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new AccessPackageResourceRequest
{
RequestType = AccessPackageRequestType.AdminUpdate,
Resource = new AccessPackageResource
{
OriginId = "e81d7f57-0840-45e1-894b-f505c1bdcc1f",
OriginSystem = "AadApplication",
Attributes = new List<AccessPackageResourceAttribute>
{
new AccessPackageResourceAttribute
{
Destination = new AccessPackageUserDirectoryAttributeStore
{
OdataType = "microsoft.graph.accessPackageUserDirectoryAttributeStore",
},
Name = "officeLocation",
Source = new AccessPackageResourceAttributeQuestion
{
OdataType = "#microsoft.graph.accessPackageResourceAttributeQuestion",
Question = new AccessPackageTextInputQuestion
{
OdataType = "#microsoft.graph.accessPackageTextInputQuestion",
Sequence = 1,
IsRequired = true,
IsAnswerEditable = true,
Text = "What office do you work at?",
IsSingleLineQuestion = true,
RegexPattern = "[a-zA-Z]+[a-zA-Z\s]*",
},
},
},
new AccessPackageResourceAttribute
{
Destination = new AccessPackageUserDirectoryAttributeStore
{
OdataType = "microsoft.graph.accessPackageUserDirectoryAttributeStore",
},
Name = "extension_e409fedc08ab4807a9eb53ebc0d6cc9f_Expense_CostCenter",
Source = new AccessPackageResourceAttributeQuestion
{
OdataType = "#microsoft.graph.accessPackageResourceAttributeQuestion",
Question = new AccessPackageTextInputQuestion
{
OdataType = "#microsoft.graph.accessPackageTextInputQuestion",
IsRequired = false,
Text = "What is your cost center number?",
Sequence = 0,
IsSingleLineQuestion = true,
RegexPattern = "[0-9]*",
},
},
},
},
},
Catalog = new AccessPackageCatalog
{
Id = "beedadfe-01d5-4025-910b-84abb9369997",
},
};
// 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.ResourceRequests.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
AccessPackageResourceRequest accessPackageResourceRequest = new AccessPackageResourceRequest();
accessPackageResourceRequest.setRequestType(AccessPackageRequestType.AdminUpdate);
AccessPackageResource resource = new AccessPackageResource();
resource.setOriginId("e81d7f57-0840-45e1-894b-f505c1bdcc1f");
resource.setOriginSystem("AadApplication");
LinkedList<AccessPackageResourceAttribute> attributes = new LinkedList<AccessPackageResourceAttribute>();
AccessPackageResourceAttribute accessPackageResourceAttribute = new AccessPackageResourceAttribute();
AccessPackageUserDirectoryAttributeStore destination = new AccessPackageUserDirectoryAttributeStore();
destination.setOdataType("microsoft.graph.accessPackageUserDirectoryAttributeStore");
accessPackageResourceAttribute.setDestination(destination);
accessPackageResourceAttribute.setName("officeLocation");
AccessPackageResourceAttributeQuestion source = new AccessPackageResourceAttributeQuestion();
source.setOdataType("#microsoft.graph.accessPackageResourceAttributeQuestion");
AccessPackageTextInputQuestion question = new AccessPackageTextInputQuestion();
question.setOdataType("#microsoft.graph.accessPackageTextInputQuestion");
question.setSequence(1);
question.setIsRequired(true);
question.setIsAnswerEditable(true);
question.setText("What office do you work at?");
question.setIsSingleLineQuestion(true);
question.setRegexPattern("[a-zA-Z]+[a-zA-Z\s]*");
source.setQuestion(question);
accessPackageResourceAttribute.setSource(source);
attributes.add(accessPackageResourceAttribute);
AccessPackageResourceAttribute accessPackageResourceAttribute1 = new AccessPackageResourceAttribute();
AccessPackageUserDirectoryAttributeStore destination1 = new AccessPackageUserDirectoryAttributeStore();
destination1.setOdataType("microsoft.graph.accessPackageUserDirectoryAttributeStore");
accessPackageResourceAttribute1.setDestination(destination1);
accessPackageResourceAttribute1.setName("extension_e409fedc08ab4807a9eb53ebc0d6cc9f_Expense_CostCenter");
AccessPackageResourceAttributeQuestion source1 = new AccessPackageResourceAttributeQuestion();
source1.setOdataType("#microsoft.graph.accessPackageResourceAttributeQuestion");
AccessPackageTextInputQuestion question1 = new AccessPackageTextInputQuestion();
question1.setOdataType("#microsoft.graph.accessPackageTextInputQuestion");
question1.setIsRequired(false);
question1.setText("What is your cost center number?");
question1.setSequence(0);
question1.setIsSingleLineQuestion(true);
question1.setRegexPattern("[0-9]*");
source1.setQuestion(question1);
accessPackageResourceAttribute1.setSource(source1);
attributes.add(accessPackageResourceAttribute1);
resource.setAttributes(attributes);
accessPackageResourceRequest.setResource(resource);
AccessPackageCatalog catalog = new AccessPackageCatalog();
catalog.setId("beedadfe-01d5-4025-910b-84abb9369997");
accessPackageResourceRequest.setCatalog(catalog);
AccessPackageResourceRequest result = graphClient.identityGovernance().entitlementManagement().resourceRequests().post(accessPackageResourceRequest);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\AccessPackageResourceRequest;
use Microsoft\Graph\Generated\Models\AccessPackageRequestType;
use Microsoft\Graph\Generated\Models\AccessPackageResource;
use Microsoft\Graph\Generated\Models\AccessPackageResourceAttribute;
use Microsoft\Graph\Generated\Models\AccessPackageUserDirectoryAttributeStore;
use Microsoft\Graph\Generated\Models\AccessPackageResourceAttributeQuestion;
use Microsoft\Graph\Generated\Models\AccessPackageTextInputQuestion;
use Microsoft\Graph\Generated\Models\AccessPackageCatalog;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AccessPackageResourceRequest();
$requestBody->setRequestType(new AccessPackageRequestType('adminUpdate'));
$resource = new AccessPackageResource();
$resource->setOriginId('e81d7f57-0840-45e1-894b-f505c1bdcc1f');
$resource->setOriginSystem('AadApplication');
$attributesAccessPackageResourceAttribute1 = new AccessPackageResourceAttribute();
$attributesAccessPackageResourceAttribute1Destination = new AccessPackageUserDirectoryAttributeStore();
$attributesAccessPackageResourceAttribute1Destination->setOdataType('microsoft.graph.accessPackageUserDirectoryAttributeStore');
$attributesAccessPackageResourceAttribute1->setDestination($attributesAccessPackageResourceAttribute1Destination);
$attributesAccessPackageResourceAttribute1->setName('officeLocation');
$attributesAccessPackageResourceAttribute1Source = new AccessPackageResourceAttributeQuestion();
$attributesAccessPackageResourceAttribute1Source->setOdataType('#microsoft.graph.accessPackageResourceAttributeQuestion');
$attributesAccessPackageResourceAttribute1SourceQuestion = new AccessPackageTextInputQuestion();
$attributesAccessPackageResourceAttribute1SourceQuestion->setOdataType('#microsoft.graph.accessPackageTextInputQuestion');
$attributesAccessPackageResourceAttribute1SourceQuestion->setSequence(1);
$attributesAccessPackageResourceAttribute1SourceQuestion->setIsRequired(true);
$attributesAccessPackageResourceAttribute1SourceQuestion->setIsAnswerEditable(true);
$attributesAccessPackageResourceAttribute1SourceQuestion->setText('What office do you work at?');
$attributesAccessPackageResourceAttribute1SourceQuestion->setIsSingleLineQuestion(true);
$attributesAccessPackageResourceAttribute1SourceQuestion->setRegexPattern('[a-zA-Z]+[a-zA-Z\s]*');
$attributesAccessPackageResourceAttribute1Source->setQuestion($attributesAccessPackageResourceAttribute1SourceQuestion);
$attributesAccessPackageResourceAttribute1->setSource($attributesAccessPackageResourceAttribute1Source);
$attributesArray []= $attributesAccessPackageResourceAttribute1;
$attributesAccessPackageResourceAttribute2 = new AccessPackageResourceAttribute();
$attributesAccessPackageResourceAttribute2Destination = new AccessPackageUserDirectoryAttributeStore();
$attributesAccessPackageResourceAttribute2Destination->setOdataType('microsoft.graph.accessPackageUserDirectoryAttributeStore');
$attributesAccessPackageResourceAttribute2->setDestination($attributesAccessPackageResourceAttribute2Destination);
$attributesAccessPackageResourceAttribute2->setName('extension_e409fedc08ab4807a9eb53ebc0d6cc9f_Expense_CostCenter');
$attributesAccessPackageResourceAttribute2Source = new AccessPackageResourceAttributeQuestion();
$attributesAccessPackageResourceAttribute2Source->setOdataType('#microsoft.graph.accessPackageResourceAttributeQuestion');
$attributesAccessPackageResourceAttribute2SourceQuestion = new AccessPackageTextInputQuestion();
$attributesAccessPackageResourceAttribute2SourceQuestion->setOdataType('#microsoft.graph.accessPackageTextInputQuestion');
$attributesAccessPackageResourceAttribute2SourceQuestion->setIsRequired(false);
$attributesAccessPackageResourceAttribute2SourceQuestion->setText('What is your cost center number?');
$attributesAccessPackageResourceAttribute2SourceQuestion->setSequence(0);
$attributesAccessPackageResourceAttribute2SourceQuestion->setIsSingleLineQuestion(true);
$attributesAccessPackageResourceAttribute2SourceQuestion->setRegexPattern('[0-9]*');
$attributesAccessPackageResourceAttribute2Source->setQuestion($attributesAccessPackageResourceAttribute2SourceQuestion);
$attributesAccessPackageResourceAttribute2->setSource($attributesAccessPackageResourceAttribute2Source);
$attributesArray []= $attributesAccessPackageResourceAttribute2;
$resource->setAttributes($attributesArray);
$requestBody->setResource($resource);
$catalog = new AccessPackageCatalog();
$catalog->setId('beedadfe-01d5-4025-910b-84abb9369997');
$requestBody->setCatalog($catalog);
$result = $graphServiceClient->identityGovernance()->entitlementManagement()->resourceRequests()->post($requestBody)->wait();