使用现有计算机帐户加入域时失败

本文解决了当现有具有相同名称的计算机帐户已存在时无法将计算机加入域的问题。

症状

尝试使用现有计算机帐户名称将计算机加入域时,操作将失败,并收到以下错误消息:

访问工作或学校 页面中:

无法加入此域。 有关详细信息,请联系 IT 管理员。

系统属性中:

尝试加入域“<domain_name>”时出现以下错误:

Active Directory 中存在同名的帐户。
安全策略阻止了重新使用该帐户。

Netsetup.log

查看完全更新系统上 Netsetup.log 文件的以下示例。

NetpProvisionComputerAccount:
    lpDomain: contoso.com
    lpHostName: host1
    lpMachineAccountOU: (NULL)
    lpDcName: ContosoDC1.contoso.com
    lpMachinePassword: (null)
    lpAccount: contoso\nonadminuser2
    lpPassword: (non-null)
    dwJoinOptions: 0x403
    dwOptions: 0x40000003
NetpLdapBind: Verified minimum encryption strength on ContosoDC1.contoso.com: 0x0
NetpLdapGetLsaPrimaryDomain: reading domain data
NetpGetNCData: Reading NC data
NetpGetDomainData: Lookup domain data for: DC=contoso,DC=com
NetpGetDomainData: Lookup crossref data for: CN=Partitions,CN=Configuration,DC=contoso,DC=com
NetpLdapGetLsaPrimaryDomain: result of retrieving domain data: 0x0
NetpCheckForDomainSIDCollision: returning 0x0(0).
NetpGetComputerObjectDn: Cracking DNS domain name contoso.com/ into Netbios on \\ContosoDC1.contoso.com
NetpGetComputerObjectDn: Crack results:     name = CONTOSO\
NetpGetComputerObjectDn: Cracking account name CONTOSO\HOST1$ on \\ContosoDC1.contoso.com
NetpGetComputerObjectDn: Crack results:     (Account already exists) DN = CN=HOST1,CN=Computers,DC=contoso,DC=com 
NetpGetADObjectOwnerAttributes: Looking up attributes for machine account: CN=HOST1,CN=Computers,DC=contoso,DC=com
NetpGetNCData: Reading NC data
NetpReadAccountReuseModeFromAD: Searching '<WKGUID=AB1D30F3768811D1ADED00C04FD8D5CD,DC=contoso,DC=com>' for '(&(ObjectClass=ServiceConnectionPoint)(KeyWords=NetJoin*))'.
NetpReadAccountReuseModeFromAD: Got 0 Entries.
Returning NetStatus: 0, ADReuseMode: 0
IsLegacyAccountReuseSetInRegistry: RegQueryValueEx for 'NetJoinLegacyAccountReuse' returned Status: 0x2. 
IsLegacyAccountReuseSetInRegistry returning: 'FALSE''.
NetpDsValidateComputerAccountReuseAttempt: returning NtStatus: 0, NetStatus: 0
NetpDsValidateComputerAccountReuseAttempt: returning Result: FALSE
NetpCheckIfAccountShouldBeReused: Active Directory Policy check with SAM_DOMAIN_JOIN_POLICY_LEVEL_V2 returned NetStatus:0x0.
NetpCheckIfAccountShouldBeReused: Account re-use attempt was Denied by Active Directory Policy. 
NetpCheckIfAccountShouldBeReused:fReuseAllowed: FALSE, NetStatus:0x0
NetpModifyComputerObjectInDs: Account exists and re-use is blocked by policy. Error: 0xaac 
NetpProvisionComputerAccount: LDAP creation failed: 0xaac 
NetpProvisionComputerAccount: Retrying downlevel per options
NetpManageMachineAccountWithSid: NetUserAdd on 'ContosoDC1.contoso.com' for 'HOST1$' failed: 0x8b0 
IsLegacyAccountReuseSetInRegistry: RegQueryValueEx for 'NetJoinLegacyAccountReuse' returned Status: 0x2. 
IsLegacyAccountReuseSetInRegistry returning: 'FALSE''.
NetpManageMachineAccountWithSid: The computer account already exists in Active Directory.Re-using the account was blocked by security policy.
NetpProvisionComputerAccount: retry status of creating account: 0xaac
ldap_unbind status: 0x0
NetpJoinCreatePackagePart: status:0xaac.
NetpJoinDomainOnDs: Function exits with status of: 0xaac 
NetpJoinDomainOnDs: status of disconnecting from '\\ContosoDC1.contoso.com': 0x0
NetpResetIDNEncoding: DnsDisableIdnEncoding(RESETALL) on 'contoso.com' returned 0x0
NetpJoinDomainOnDs: NetpResetIDNEncoding on 'contoso.com': 0x0
NetpDoDomainJoin: status: 0xaac

错误详细信息

十六进制错误 十进制错误 符号性错误字符串 错误说明 标题
0x8b0 2224 NERR_UserExists 帐户已存在。 lmerr.h
0xaac 2732 账号重用被策略阻止 Active Directory 中存在同名的帐户。 安全策略阻止了重新使用该帐户。 lmerr.h

原因

Windows 引入了其他保护,更新在 2022 年 10 月 11 日之后发布。 这些保护措施故意防止在目标域中重用现有计算机帐户的域加入操作,除非满足以下任一条件:

  • 尝试操作的用户是现有帐户的创建者。
  • 计算机由域管理员、企业管理员或内置管理员组的成员创建。
  • 正在重复使用的计算机帐户对象的所有者是 域控制器的成员:允许在域加入组策略设置期间重复使用计算机帐户 。 此设置要求在所有成员计算机和域控制器上安装在 2023 年 3 月 14 日或之后发布的 Windows 更新。

决议

要解决该问题,请执行以下步骤:

  1. 使用用于在目标域中创建计算机帐户的相同帐户执行联接操作。
  2. 如果现有帐户已过时(未使用),请先将其删除,然后再尝试再次加入域。
  3. 重命名计算机并使用不存在的其他帐户加入域。
  4. 如果受信任的安全主体拥有现有帐户,并且管理员希望重复使用该帐户,请使用 域控制器:允许在加入域组策略期间重复使用计算机帐户

参考文献

有关域加入强化更改的详细信息,请参阅 KB5020276 - Netjoin:域加入强化更改