在 Windows Server 2008 中运行Adprep /rodcprep命令时出错:Adprep 无法联系分区 DC=DomainDnsZones,DC=Contoso,DC=com 的副本 (replica)

本文解决了命令未成功完成的问题, Adprep /rodcprep 因为无法访问一个或多个 Active Directory NDNC 的基础结构主机。

适用于: Windows Server 2012 R2
原始 KB 编号: 949257

症状

Adprep /rodcprep Windows Server 2008 上运行命令时,会收到以下错误消息:

Adprep 无法联系分区 DC=DomainDnsZones,DC=Contoso,DC=com 的副本 (replica)

Adprep 未能对分区 DC=DomainDnsZones、DC=Contoso、DC=com 跳过到下一个分区执行操作。

Adprep 无法联系分区 DC=ForestDnsZones,DC=Contoso,DC=com 的副本 (replica)

Adprep 遇到 LDAP 错误。 错误代码:0x0。 服务器扩展错误代码:0x0,服务器错误消息: (null) 。

Adprep 未能对分区 DC=ForestDnsZones、DC=Contoso、DC=com 跳过到下一个分区执行操作。

Adprep 已完成,但出现错误。 并非所有分区都会更新。

原因

当命令尝试联系林中每个应用程序分区的基础结构主机时 Adprep /rodcprep ,会出现此问题。 命令执行该操作是为了设置 Read-Only 域控制器 (RODC) 复制所需的权限。 如果满足以下条件之一,该 Adprep /rodcprep 命令将失败:

  • 错误消息中引用的分区或分区不再存在。
  • 引用的分区或分区的基础结构主机已强制降级或处于脱机状态。

解决方案

若要在分区不再存在时解决此问题,请使用 Dsmgmt 工具的“remove nc”参数对孤立分区执行元数据清理。 有关更多信息,请访问以下 Microsoft 网站:

分区管理

如果指定的分区存在,请指定分区联机的基础结构角色所有者。 可以通过手动修改对象的 fSMORoleOwner 属性来执行此操作,如“更多信息”部分中所述。

更多信息

以下脚本示例修改指定非域命名上下文的基础结构对象的 fSMORoleOwner 属性, (NDNC) 活动服务器或可联系服务器。 此示例中的 NDNC 是 DomainDnsZones,DC=contoso,DC=com NDNC 命名上下文。 脚本使用以下命令:

cscript fixfsmo.vbs DC=DomainDnsZones,DC=contoso,DC=com
'-------fixfsmo.vbs------------------
const ADS_NAME_INITTYPE_GC = 3
const ADS_NAME_TYPE_1779 = 1
const ADS_NAME_TYPE_CANONICAL = 2

set inArgs = WScript.Arguments

if (inArgs.Count = 1) then
    ' Assume the command line argument is the NDNC (in DN form) to use.
    NdncDN = inArgs(0)
Else
    Wscript.StdOut.Write "usage: cscript fixfsmo.vbs NdncDN"
End if

if (NdncDN <> "") then

    ' Convert the DN form of the NDNC into DNS dotted form.
    Set objTranslator = CreateObject("NameTranslate")
    objTranslator.Init ADS_NAME_INITTYPE_GC, ""
    objTranslator.Set ADS_NAME_TYPE_1779, NdncDN
    strDomainDNS = objTranslator.Get(ADS_NAME_TYPE_CANONICAL)
    strDomainDNS = Left(strDomainDNS, len(strDomainDNS)-1)

    Wscript.Echo "DNS name: " & strDomainDNS

    ' Find a domain controller that hosts this NDNC and that is online.
    set objRootDSE = GetObject("LDAP://" & strDomainDNS & "/RootDSE")
    strDnsHostName = objRootDSE.Get("dnsHostName")
    strDsServiceName = objRootDSE.Get("dsServiceName")
    Wscript.Echo "Using DC " & strDnsHostName

    ' Get the current infrastructure fsmo.
    strInfraDN = "CN=Infrastructure," & NdncDN
    set objInfra = GetObject("LDAP://" & strInfraDN)
    Wscript.Echo "infra fsmo is " & objInfra.fsmoroleowner

    ' If the current fsmo holder is deleted, set the fsmo holder to this domain controller.

    if (InStr(objInfra.fsmoroleowner, "\0ADEL:") > 0) then

        ' Set the fsmo holder to this domain controller.
        objInfra.Put "fSMORoleOwner",  strDsServiceName
        objInfra.SetInfo

        ' Read the fsmo holder back.
        set objInfra = GetObject("LDAP://" & strInfraDN)
        Wscript.Echo "infra fsmo changed to:" & objInfra.fsmoroleowner

    End if

End if

若要确定分区的基础结构主机,请查询有关命名上下文根下的基础结构对象的 fSMORoleOwner 属性。 例如,查询 CN=Infrastructure,DC=DomainDnsZones,DC=contoso,DC=com 命名上下文根上的 fSMORoleOwner 属性,以确定 DC=DomainDnsZones,DC=contoso,DC=com 分区的基础结构主机。 同样,在 CN=Infrastructure,DC=ForestDnsZones,DC=contoso,DC=com 命名上下文根上查询 fSMORoleOwner 属性,以确定 DC=ForestDnsZones,DC=contoso,DC=com 分区的基础结构主机。

可以使用 LDP 工具、Active Directory 服务接口 (ADSI) 编辑工具和 ldifde 工具等工具来执行这些查询。 例如,以下查询使用 Idifde 工具:

ldifde -f Infra_DomainDNSZones.ldf -d “CN=Infrastructure,DC=DomainDnsZones,DC=contoso,DC=com” -l fSMORoleOwner

此查询将 DC=DomainDnsZones,DC=contoso,DC=com 分区的基础结构主角色所有者返回到 Infra_DomainDNSZones.ldf 文件。

注意

可以在不损害林的情况下多次运行 Adprep /rodcprep 命令。 在 rodcprep 命令的早期执行中完成的操作不会重复。

如果尝试在独立环境中运行 rodcprep 命令,则每个域和每个应用程序目录分区的基础结构主机必须在环境中可用,才能使操作成功。