本主題涵蓋如何在群組布建至 Microsoft Entra ID 的過程中,保留及使用內部部署群組的原始組織單位(OU)。
先決條件
使用 [連線同步 ] 或 [ 雲端同步 ] 同步處理自定義擴充屬性,或使用您目前未使用之預設架構的現有屬性,並設定您要將授權來源 (SOA) 轉換為雲端的群組 OU 路徑。 當您從雲端更新這些群組時,屬性可協助您將群組布建至相同的 OU。
步驟 1:在內部部署 Active Directory 網域服務(AD DS)中填入 extensionAttribute13
使用 PowerShell 從每個群組的辨別名稱 (DN) 擷取 OU,並將其儲存在 extensionAttribute13 屬性中。 您可以執行下列 Cmdlet,將每個群組的原始 OU 路徑儲存在可寫入的屬性中,然後再轉換授權單位群組來源 (SOA)。
Get-ADGroup -Filter * -SearchBase "DC=contoso,DC=com" | ForEach-Object {
$ou = ($_.DistinguishedName -split ",", 2)[1] # Extract OU path
Set-ADGroup -Identity $_.DistinguishedName -Replace @{extensionAttribute13 = $ou}
}
您也可以將 OU 資訊儲存在其他屬性中,例如 info 或任何其他自訂屬性。 如需如何同步處理自定義屬性的詳細資訊,請參閱 自定義屬性對應。
步驟 2:在 Microsoft Entra Cloud Sync 或 Connect Sync 中啟用 extensionAttribute13 的同步
以至少混合式身分識別系統管理員身分登入 Microsoft Entra 系統管理中心。
流覽至 身分識別>佈建>雲端同步。
選取您的雲端同步設定。
在 [屬性對應] 底下,針對 [群組] 物件:
- 按一下 編輯對應
- 新增對應:
設定 價值觀 來源屬性 extensionAttribute13 目標屬性 onPremisesExtensionAttributes.extensionAttribute13 比對物件 保持未核取狀態 套用此對應 永遠
步驟 3:確認 Microsoft Entra ID 中的屬性同步
使用 PowerShell 或 Microsoft Graph Explorer 來驗證屬性同步處理。
Microsoft Graph PowerShell
Get-MgGroup -GroupId <groupId> | Select -ExpandProperty OnPremisesExtensionAttributes圖形瀏覽器
GET https://graph.microsoft.com/v1.0/groups/{group-id}?$select=onPremisesExtensionAttributes您應該會看到:
{ "onPremisesExtensionAttributes": { "extensionAttribute13": "OU=Finance,DC=contoso,DC=com" } }
步驟 4:在配置期間使用 extensionAttribute13
當您設定 佈署時,請使用同步屬性來控制目標 OU。
在 布建設定 中,將 onPremisesExtensionAttributes.extensionAttribute13 對應至自定義變數,例如 preferredOU。
使用類似此範例的表達式來處理備援。 如果原始 OU 可供使用,則此表達式會使用原始 OU,或切換回您指定的預設 OU。 您可以稍後變更 extensionAttribute13 以重新設定該值。
IIF(IsNullOrEmpty([extensionAttribute13]), "OU=<Enter your default OU name>,DC=contoso,DC=com", [extensionAttribute13])