Microsoft Entra Connect で、あるフォレストから別のフォレストにグループを移行する

この記事では、あるフォレストから別のフォレストにグループを移行し、移行したグループ オブジェクトがクラウド内の既存のオブジェクトと一致するようにする方法を説明します。

前提条件

  • Microsoft Entra Connect バージョン 1.5.18.0 以降
  • ソース アンカー属性が mS-DS-ConsistencyGuid に設定されている

グループを移行する

バージョン 1.5.18.0 以降では、Microsoft Entra Connect は、グループの mS-DS-ConsistencyGuid 属性の使用をサポートしています。 ソース アンカー属性として mS-DS-ConsistencyGuid が選択されていて、その値が Active Directory に設定されている場合、Microsoft Entra Connect は mS-DS-ConsistencyGuid の値を immutableId として使用します。 それ以外の場合は、objectGUID の使用に戻ります。 ただし、Microsoft Entra Connect は値を Active Directory の mS-DS-ConsistencyGuid 属性に書き戻さないことに注意してください。

グループ オブジェクトが、あるフォレスト (たとえば F1) から別のフォレスト (たとえば F2) に移動するフォレスト間の移動では、mS-DS-ConsistencyGuid 値 (存在する場合) または objectGUID 値を、フォレスト F1 のオブジェクトから F2 のオブジェクトの mS-DS-ConsistencyGuid 属性にコピーする必要があります。

あるフォレストから別のフォレストに 1 つのグループを移行する方法について学習するには、次のスクリプトをガイドとして使用してください。 これらのスクリプトは、複数のグループを移行するためのガイドとしても使用できます。 スクリプトでは、ソース フォレストにはフォレスト名 F1、送信先フォレストには F2 が使用されます。

まず、フォレスト F1 のグループ オブジェクトの objectGUIDmS-DS-ConsistencyGuid を取得します。 これらの属性は、CSV ファイルにエクスポートされます。

<#
DESCRIPTION
============
This script will take DN of a group as input.
It then copies the objectGUID and mS-DS-ConsistencyGuid values along with other attributes of the given group to a CSV file.

This CSV file can then be used as input to the Export-Group script.
#>
Param(
       [ValidateNotNullOrEmpty()]
       [string]
       $dn,

       [ValidateNotNullOrEmpty()]
       [string]
       $outputCsv
)

$defaultProperties = @('samAccountName', 'distinguishedName', 'objectGUID', 'mS-DS-ConsistencyGuid')
$group  = Get-ADGroup -Filter "DistinguishedName -eq '$dn'" -Properties $defaultProperties -ErrorAction Stop
$results = @()
if ($group -eq $null)
{
       Write-Error "Group not found"
}
else
{
       $objectGUIDValue = [GUID]$group.'objectGUID'
       $mSDSConsistencyGuidValue = "N/A"
       if ($group.'mS-DS-ConsistencyGuid' -ne $null)
       {
              $mSDSConsistencyGuidValue = [GUID]$group.'mS-DS-ConsistencyGuid'
       }
       $adgroup = New-Object -TypeName PSObject
       $adgroup | Add-Member -MemberType NoteProperty -Name samAccountName -Value $($group.'samAccountName')
       $adgroup | Add-Member -MemberType NoteProperty -Name distinguishedName -Value $($group.'distinguishedName')
       $adgroup | Add-Member -MemberType NoteProperty -Name objectGUID -Value $($objectGUIDValue)
       $adgroup | Add-Member -MemberType NoteProperty -Name mS-DS-ConsistencyGuid -Value $($mSDSConsistencyGuidValue)
       $results += $adgroup
}

Write-Host "Exporting group to output file"
$results | Export-Csv "$outputCsv" -NoTypeInformation

次に、生成された出力 CSV ファイルを使用して、フォレスト F2 のターゲットオブジェクトに mS-DS-ConsistencyGuid 属性をスタンプします。

<#
DESCRIPTION
============
This script will take DN of a group as input and the CSV file that was generated by the Import-Group script.
It copies either the objectGUID or the mS-DS-ConsistencyGuid value from the CSV file to the given object.

#>
Param(
       [ValidateNotNullOrEmpty()]
       [string]
       $dn,

       [ValidateNotNullOrEmpty()]
       [string]
       $inputCsv
)

$group  = Get-ADGroup -Filter "DistinguishedName -eq '$dn'" -ErrorAction Stop
if ($group -eq $null)
{
       Write-Error "Group not found"
}

$csvFile = Import-Csv -Path $inputCsv -ErrorAction Stop
$msDSConsistencyGuid = $csvFile.'mS-DS-ConsistencyGuid'
$objectGuid = [GUID] $csvFile.'objectGUID'
$targetGuid = $msDSConsistencyGuid

if ($msDSConsistencyGuid -eq "N/A")
{
       $targetGuid = $objectGuid
}

Set-ADGroup -Identity $dn -Replace @{'mS-DS-ConsistencyGuid'=$targetGuid} -ErrorAction Stop

次のステップ

詳細については、オンプレミス ID と Microsoft Entra ID の統合に関する記事を参照してください。