Configurer la synchronisation avec des attributs cibles personnalisés
Article
Espace de noms: microsoft.graph
Vous pouvez personnaliser votre schéma de synchronisation pour inclure des attributs personnalisés qui sont définis dans le répertoire cible. Cet article explique comment personnaliser un abonnement Salesforce en ajoutant un nouveau champ appelé officeCode. Vous configurez la synchronisation de Microsoft Entra ID vers Salesforce et, pour chaque utilisateur, vous remplirez le officeCode champ dans Salesforce avec la valeur du extensionAttribute10 champ dans Microsoft Entra ID.
Cet article part du principe que vous avez déjà ajouté une application qui prend en charge la synchronisation avec votre locataire via le centre d'administration Microsoft Entra, que vous connaissez le nom complet de l’application et que vous disposez d’un jeton d’autorisation pour Microsoft Graph. Pour plus d’informations sur la façon d’obtenir le jeton d’autorisation, consultez Obtenir des jetons d’accès pour appeler Microsoft Graph.
Rechercher l’objet principal de service par nom d’affichage
L’exemple suivant montre comment rechercher un objet principal de service avec le nom complet Salesforce.
GET https://graph.microsoft.com/v1.0/servicePrincipals?$select=id,appId,displayName&$filter=startswith(displayName, 'salesforce')
Authorization: Bearer {Token}
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.ServicePrincipals.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Select = new string []{ "id","appId","displayName" };
requestConfiguration.QueryParameters.Filter = "startswith(displayName, 'salesforce')";
requestConfiguration.Headers.Add("Authorization", "Bearer {Token}");
});
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
ServicePrincipalCollectionResponse result = graphClient.servicePrincipals().get(requestConfiguration -> {
requestConfiguration.queryParameters.select = new String []{"id", "appId", "displayName"};
requestConfiguration.queryParameters.filter = "startswith(displayName, 'salesforce')";
requestConfiguration.headers.add("Authorization", "Bearer {Token}");
});
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.service_principals.service_principals_request_builder import ServicePrincipalsRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = ServicePrincipalsRequestBuilder.ServicePrincipalsRequestBuilderGetQueryParameters(
select = ["id","appId","displayName"],
filter = "startswith(displayName, 'salesforce')",
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
request_configuration.headers.add("Authorization", "Bearer {Token}")
result = await graph_client.service_principals.get(request_configuration = request_configuration)
GET https://graph.microsoft.com/v1.0/servicePrincipals/60443998-8cf7-4e61-b05c-a53b658cb5e1/synchronization/jobs
Authorization: Bearer {Token}
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.ServicePrincipals["{servicePrincipal-id}"].Synchronization.Jobs.GetAsync((requestConfiguration) =>
{
requestConfiguration.Headers.Add("Authorization", "Bearer {Token}");
});
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
abstractions "github.com/microsoft/kiota-abstractions-go"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphserviceprincipals "github.com/microsoftgraph/msgraph-sdk-go/serviceprincipals"
//other-imports
)
headers := abstractions.NewRequestHeaders()
headers.Add("Authorization", "Bearer {Token}")
configuration := &graphserviceprincipals.ItemSynchronizationJobsRequestBuilderGetRequestConfiguration{
Headers: headers,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
jobs, err := graphClient.ServicePrincipals().ByServicePrincipalId("servicePrincipal-id").Synchronization().Jobs().Get(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
SynchronizationJobCollectionResponse result = graphClient.servicePrincipals().byServicePrincipalId("{servicePrincipal-id}").synchronization().jobs().get(requestConfiguration -> {
requestConfiguration.headers.add("Authorization", "Bearer {Token}");
});
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.service_principals.item.synchronization.jobs.jobs_request_builder import JobsRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_configuration = RequestConfiguration()
request_configuration.headers.add("Authorization", "Bearer {Token}")
result = await graph_client.service_principals.by_service_principal_id('servicePrincipal-id').synchronization.jobs.get(request_configuration = request_configuration)
GET https://graph.microsoft.com/v1.0/servicePrincipals/{servicePrincipalId}/synchronization/jobs/{jobId}/schema
Authorization: Bearer {Token}
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.ServicePrincipals["{servicePrincipal-id}"].Synchronization.Jobs["{synchronizationJob-id}"].Schema.GetAsync((requestConfiguration) =>
{
requestConfiguration.Headers.Add("Authorization", "Bearer {Token}");
});
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
abstractions "github.com/microsoft/kiota-abstractions-go"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphserviceprincipals "github.com/microsoftgraph/msgraph-sdk-go/serviceprincipals"
//other-imports
)
headers := abstractions.NewRequestHeaders()
headers.Add("Authorization", "Bearer {Token}")
configuration := &graphserviceprincipals.ItemSynchronizationJobsItemSchemaRequestBuilderGetRequestConfiguration{
Headers: headers,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
schema, err := graphClient.ServicePrincipals().ByServicePrincipalId("servicePrincipal-id").Synchronization().Jobs().BySynchronizationJobId("synchronizationJob-id").Schema().Get(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
SynchronizationSchema result = graphClient.servicePrincipals().byServicePrincipalId("{servicePrincipal-id}").synchronization().jobs().bySynchronizationJobId("{synchronizationJob-id}").schema().get(requestConfiguration -> {
requestConfiguration.headers.add("Authorization", "Bearer {Token}");
});
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.service_principals.item.synchronization.jobs.item.schema.schema_request_builder import SchemaRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_configuration = RequestConfiguration()
request_configuration.headers.add("Authorization", "Bearer {Token}")
result = await graph_client.service_principals.by_service_principal_id('servicePrincipal-id').synchronization.jobs.by_synchronization_job_id('synchronizationJob-id').schema.get(request_configuration = request_configuration)
Remarque : l’objet de réponse affiché ci-après peut être raccourci pour plus de lisibilité. Toutes les propriétés seront retournées dans un appel réel.
Sous synchronizationRules, recherchez la règle qui spécifie Microsoft Entra ID comme répertoire source et Salesforce.com comme répertoire cible ("sourceDirectoryName": "Azure Active Directory", "targetDirectoryName": "salesforce.com").
Dans objectMappings de la règle, recherchez le mappage entre les utilisateurs ("sourceObjectName": "User", "targetObjectName": "User").
Dans le tableau attributeMappings de l’objetMapping, ajoutez une nouvelle entrée, comme illustré dans l’exemple suivant.
Lorsque vous enregistrez le schéma de synchronisation mis à jour, veillez à inclure l’intégralité du schéma, y compris les parties non modifiées. Cette demande remplace le schéma existant par celui que vous fournissez.
Si le schéma a été enregistré avec succès, la requête retourne un 204 No Content code de réponse. Lors de la prochaine itération du travail de synchronisation, il commencera à rétraiter tous les comptes de votre Microsoft Entra ID, et les nouveaux mappages seront appliqués à tous les comptes provisionnés.