配置与目录扩展属性的同步
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
您可以自定义同步架构以包括Azure Active Directory (Azure AD) 扩展属性。 本文介绍如何使用目录扩展属性 (extension_9d98asdfl15980a_Nickname) Salesforce 中User.CommunityNickname 的值。 在此方案中,你已Azure AD 连接设置从本地到本地部署Windows Server Active Directory多个目录扩展Azure AD。
本文假定你已添加支持通过Azure门户与租户同步的应用程序,你知道应用程序 显示名称,并且你具有 Microsoft Graph 的授权令牌。 若要了解如何获取授权令牌,请参阅获取访问令牌以调用 Microsoft Graph。
按以下方法查找服务主体显示名称
以下示例演示如何查找具有"Salesforce 沙盒"显示名称服务主体对象。
GET https://graph.microsoft.com/beta/servicePrincipals?$select=id,appId,displayName&$filter=startswith(displayName, 'salesforce')
Authorization: Bearer {Token}
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#servicePrincipals(id,appId,displayName)",
"value": [
{
"id": "167e33e9-f80e-490e-b4d8-698d4a80fb3e",
"appId": "cd3ed3de-93ee-400b-8b19-b61ef44a0f29",
"displayName": "Salesforce"
},
{
"id": "8cbbb70b-7290-42da-83ee-89fa3517a977",
"appId": "b0f2e3b1-fe31-4658-b216-44dcaeabb63a",
"displayName": "salesforce 1"
},
{
"id": "60443998-8cf7-4e61-b05c-a53b658cb5e1",
"appId": "79079396-c301-405d-900f-e2e0c2439a90",
"displayName": "Salesforce Sandbox"
}
]
}
{servicePrincipalId}为 60443998-8cf7-4e61-b05c-a53b658cb5e1 。
在服务主体上下文中列出同步作业
以下示例演示如何获取 jobId 您需要的 。 通常,响应仅返回一个作业。
GET https://graph.microsoft.com/beta/servicePrincipals/60443998-8cf7-4e61-b05c-a53b658cb5e1/synchronization/jobs
Authorization: Bearer {Token}
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#servicePrincipals('60443998-8cf7-4e61-b05c-a53b658cb5e1')/synchronization/jobs",
"value": [
{
"id": "SfSandboxOutDelta.e4bbf44533ea4eabb17027f3a92e92aa",
"templateId": "SfSandboxOutDelta",
"schedule": {},
"status": {}
}
]
}
{jobId}为 SfSandboxOutDelta.e4bbf44533ea4eabb17027f3a92e92aa 。
查找所需的目录扩展属性的名称
你将需要扩展属性的完整名称。 如果不知道完整名称 (其外观应类似于 extension_9d98asdfl15980a_Nickname ) , 请参阅以下有关目录扩展属性以及如何检查它们的信息:
获取同步架构
以下示例演示如何获取同步架构。
GET https://graph.microsoft.com/beta/servicePrincipals/{servicePrincipalId}/synchronization/jobs/{jobId}/schema
Authorization: Bearer {Token}
注意: 为了提高可读性,可能缩短了此处显示的响应对象。 在实际调用中将返回所有属性。
HTTP/1.1 200 OK
Content-Type: application/json
{
"directories": [
{
"id": "66e4a8cc-1b7b-435e-95f8-f06cea133828",
"name": "Azure Active Directory",
"objects": [
{
"attributes": [
{
"anchor": true,
"caseExact": false,
"defaultValue": null,
"metadata": [],
"multivalued": false,
"mutability": "ReadWrite",
"name": "objectId",
"required": false,
"referencedObjects": [],
"type": "String"
},
{
"anchor": false,
"caseExact": false,
"defaultValue": null,
"metadata": [],
"multivalued": false,
"mutability": "ReadWrite",
"name": "streetAddress",
"required": false,
"referencedObjects": [],
"type": "String"
}
],
"name": "User"
}
]
},
{
"id": "8ffa6169-f354-4751-9b77-9c00765be92d",
"name": "salesforce.com",
"objects": []
}
],
"synchronizationRules": [
{
"editable": true,
"id": "4c5ecfa1-a072-4460-b1c3-4adde3479854",
"name": "USER_OUTBOUND_USER",
"objectMappings": [
{
"attributeMappings": [
{
"defaultValue": "True",
"exportMissingReferences": false,
"flowBehavior": "FlowWhenChanged",
"flowType": "Always",
"matchingPriority": 0,
"source": {
"expression": "Not([IsSoftDeleted])",
"name": "Not",
"parameters": [
{
"key": "source",
"value": {
"expression": "[IsSoftDeleted]",
"name": "IsSoftDeleted",
"parameters": [],
"type": "Attribute"
}
}
],
"type": "Function"
},
"targetAttributeName": "IsActive"
}
],
"enabled": true,
"flowTypes": "Add, Update, Delete",
"name": "Synchronize Azure Active Directory Users to salesforce.com",
"scope": null,
"sourceObjectName": "User",
"targetObjectName": "User"
}]
}]
}
为目录扩展属性添加定义,以及属性之间的映射
使用你选择的纯文本编辑器 (例如,记事本++或JSON Editor Online) :
为 属性添加属性
extension_9d98asdfl15980a_Nickname定义。- 在目录下,查找名为"Azure Active Directory"的目录,在对象的数组中查找名为 User 的目录。
- 将新属性添加到列表中,并指定名称和类型,如以下示例所示。
在 Extension_9d98asdfl15980a_Nickname 和 CommunityNickname 之间添加属性映射。
- 在synchronizationRules下,查找将Azure AD指定为源目录的规则,Salesforce.com 作为目标目录
"sourceDirectoryName": "Azure Active Directory", "targetDirectoryName": "salesforce.com"() 。 - 在 规则的 objectMappings 中,查找用户与
"sourceObjectName": "User", "targetObjectName": "User"() 。 - 在 objectMapping 的 attributeMappings数组中,添加新条目,如以下示例所示。
{ "directories": [ { "id": "66e4a8cc-1b7b-435e-95f8-f06cea133828", "name": "Azure Active Directory", "objects": [ { "attributes": [ ,{ "name": "extension_9d98asdfl15980a_Nickname", "type": "String" } ], "name":"User" }] } ], "synchronizationRules": [ { "editable": true, "id": "4c5ecfa1-a072-4460-b1c3-4adde3479854", "metadata": [..], "name": "USER_OUTBOUND_USER", "objectMappings": [ { "attributeMappings": [ ,{ "source": { "name": "extension_9d98asdfl15980a_Nickname", "type": "Attribute" }, "targetAttributeName": "CommunityNickname" } ], "name": "Synchronize Azure Active Directory Users to salesforce.com", "scope": null, "sourceObjectName": "User", "targetObjectName": "User" } ], "priority": 1, "sourceDirectoryName": "Azure Active Directory", "targetDirectoryName": "salesforce.com" }, ] }- 在synchronizationRules下,查找将Azure AD指定为源目录的规则,Salesforce.com 作为目标目录
保存修改后的同步架构
保存更新的同步架构时,请确保包括整个架构,包括未修改的部分。 此请求将用您提供的架构替换现有架构。
PUT https://graph.microsoft.com/beta/servicePrincipals/{servicePrincipalId}/synchronization/jobs/{jobId}/schema
Authorization: Bearer {Token}
{
"directories": [],
"synchronizationRules": []
}
HTTP/1.1 201 No Content
如果架构已成功保存,则下次迭代同步作业时,它将开始重新处理 Azure AD 中所有帐户,并且新映射将应用于所有预配的帐户。
反馈
提交和查看相关反馈