手动配置 Microsoft Entra 混合加入

如果使用 Microsoft Entra Connect 是一个选项,请参阅配置Microsoft Entra 混合加入中的指导。 使用 Microsoft Entra Connect 中的自动化将显著简化 Microsoft Entra 混合加入的配置。

本文介绍如何手动配置 Microsoft Entra 混合加入要求,包括托管域和联合域的步骤。

先决条件

  • Microsoft Entra Connect 1.1.819.0 或更高版本。
    • 若要使设备注册同步联接成功,在进行设备注册配置时,请不要从 Microsoft Entra Connect Sync 配置中排除默认设备属性。 若要详细了解同步到 Microsoft Entra ID 的默认设备属性,请参阅 Microsoft Entra Connect 同步的属性
    • 如果要进行混合 Microsoft Entra 联接的设备的计算机对象属于特定的组织单位 (OU),请配置在 Microsoft Entra Connect 中同步所需的正确 OU。 要详细了解如何使用 Microsoft Entra Connect 同步计算机对象,请参阅基于组织单位的筛选
  • Microsoft Entra 租户全局管理员凭据。
  • 每个本地 Active Directory 域服务林的企业管理员凭据。
  • (对于联合域)安装了 Active Directory 联合身份验证服务的 Windows Server。
  • 用户可以使用 Microsoft Entra ID 注册设备。 可以在配置设备设置一文的“配置设备设置”标题下找到有关此设置的详细信息。

Microsoft Entra 混合联接要求设备能够从组织的网络中访问以下 Microsoft 资源:

  • https://enterpriseregistration.windows.net
  • https://enterpriseregistration.partner.microsoftonline.cn
  • https://login.partner.microsoftonline.cn
  • https://device.login.partner.microsoftonline.cn
  • 组织的安全令牌服务 (STS)(联合域)

警告

如果组织使用针对数据丢失防护或 Microsoft Entra 租户限制等方案拦截 SSL 流量的代理服务器,请确保在 TLS 中断和检查中排除发往这些 URL 的流量。 不排除这些 URL 可能会导致干扰客户端证书身份验证,从而导致设备注册和基于设备的条件访问出现问题。

如果你的组织需要通过出站代理访问 Internet,你可使用 Web 代理自动发现 (WPAD),使 Windows 10 或更新版本计算机能够在 Microsoft Entra ID 中进行设备注册。 若要解决在配置和管理 WPAD 时遇到问题,请参阅排查自动检测的问题

从 Windows 10 1709 开始,如果不使用 WPAD,则可以在计算机上配置 WinHTTP 代理设置。 有关详细信息,请参阅组策略对象 (GPO) 部署的 WinHTTP 代理设置

注意

如果使用 WinHTTP 设置在计算机上配置代理设置,则无法连接到所配置的代理的任何计算机将无法连接到 Internet。

如果组织需要通过经身份验证的出站代理访问 Internet,请确保 Windows 10 或更新版本计算机能够成功对出站代理进行身份验证。 由于 Windows 10 或更新版本计算机使用计算机上下文运行设备注册,因此请使用计算机上下文配置出站代理身份验证。 根据配置要求使用相应的出站代理提供程序。

使用测试设备注册连接脚本验证设备是否能够访问系统帐户下的必需 Microsoft 资源。

配置

可以为各种类型的 Windows 设备平台配置加入 Microsoft Entra 混合的设备。

完成这些配置后,请按照指南验证注册

配置服务连接点

在注册过程中,设备使用服务连接点 (SCP) 对象来发现 Microsoft Entra 租户信息。 在本地 Active Directory 实例中,计算机林的配置命名上下文分区中必须存在用于加入 Microsoft Entra 混合的设备的 SCP 对象。 每个林只有一个配置命名上下文。 在多林 Active Directory 配置中,服务连接点必须存在于所有包含已加入域的计算机的林中。

SCP 对象包含两个关键字值 - azureADid:<TenantID>azureADName:<verified domain>azureADName 关键字中的 <verified domain> 值指示设备在从本地 Active Directory 实例读取 SCP 值后将遵循的设备注册流的类型(联合或托管)。 有关托管流和联合流的详细信息,请参阅 Microsoft Entra 设备注册的工作原理一文。

可以使用 Get-ADRootDSE cmdlet 来检索林的配置命名上下文。

对于具有 Active Directory 域名 fabrikam.com 的林,配置命名上下文是:

CN=Configuration,DC=fabrikam,DC=com

在林中,用于自动注册已加入域的设备的 SCP 对象位于:

CN=62a0ff2e-97b9-4513-943f-0d221bd30080,CN=Device Registration Configuration,CN=Services,[Your Configuration Naming Context]

SCP 对象可能已配置,具体取决于 Microsoft Entra Connect 的部署方式。 可使用以下 PowerShell 脚本验证该对象是否存在并检索发现值:

$scp = New-Object System.DirectoryServices.DirectoryEntry;

$scp.Path = "LDAP://CN=62a0ff2e-97b9-4513-943f-0d221bd30080,CN=Device Registration Configuration,CN=Services,CN=Configuration,DC=fabrikam,DC=com";

$scp.Keywords;

$scp.Keywords 输出显示 Microsoft Entra 租户信息。 下面是一个示例:

azureADName:microsoft.com
azureADId:72f988bf-86f1-41af-91ab-2d7cd011db47

设置声明颁发

在联合 Microsoft Entra 配置中,设备依赖 AD FS 或 Microsoft 合作伙伴的本地联合身份验证服务向 Microsoft Entra ID 进行身份验证。 设备将执行身份验证,以获取一个访问令牌来针对 Microsoft Entra 设备注册服务 (Azure DRS) 注册。

Windows 当前设备使用 Windows 集成身份验证向本地联合身份验证服务托管的 WS-Trust 活动终结点(版本 1.3 或 2005)进行身份验证。

使用 AD FS 时,需要启用以下 WS-Trust 终结点:

  • /adfs/services/trust/2005/windowstransport
  • /adfs/services/trust/13/windowstransport
  • /adfs/services/trust/2005/usernamemixed
  • /adfs/services/trust/13/usernamemixed
  • /adfs/services/trust/2005/certificatemixed
  • /adfs/services/trust/13/certificatemixed

警告

adfs/services/trust/2005/windowstransportadfs/services/trust/13/windowstransport 应仅作为面向 Intranet 的终结点启用,不能通过 Web 应用程序代理作为面向 Extranet 的终结点公开。 若要详细了解如何禁用 WS-Trust Windows 终结点,请参阅在代理上禁用 WS-Trust Windows 终结点。 可以通过 AD FS 管理控制台中的“服务”“终结点”查看已启用哪些终结点。

注意

如果不使用 AD FS 作为本地联合身份验证服务,请按供应商的说明操作,确保供应商支持 WS-Trust 1.3 或 2005 终结点,并且已通过元数据交换文件 (MEX) 发布这些终结点。

若要完成设备注册,Azure DRS 收到的令牌中必须存在以下声明。 Azure DRS 会根据该信息的部分内容在 Microsoft Entra ID 中创建设备对象。 然后,Microsoft Entra Connect 使用该信息将新建的设备对象与本地计算机帐户相关联。

  • http://schemas.microsoft.com/ws/2012/01/accounttype
  • http://schemas.microsoft.com/identity/claims/onpremobjectguid
  • http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid

如果需要多个已验证的域名,需提供计算机的以下声明:

  • http://schemas.microsoft.com/ws/2008/06/identity/claims/issuerid

如果已颁发 ImmutableID 声明(例如,使用 mS-DS-ConsistencyGuid 或其他属性作为 ImmutableID 的源值),则需要提供计算机的一个对应声明:

  • http://schemas.microsoft.com/LiveID/Federation/2008/05/ImmutableID

以下部分介绍:

  • 每个声明应使用的值。
  • AD FS 中的定义形式。

定义可以帮助验证值是否存在,或者是否需要创建值。

注意

如果不对本地联合身份验证服务器使用 AD FS,请遵照供应商的说明创建相应的配置来颁发这些声明。

颁发帐户类型声明

http://schemas.microsoft.com/ws/2012/01/accounttype 声明必须包含值 DJ,用于将设备标识为已加入域的计算机。 在 AD FS 中,可以添加如下所示的颁发转换规则:

@RuleName = "Issue account type for domain-joined computers"
c:[
   Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid",
   Value =~ "-515$",
   Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"
]
=> issue(
   Type = "http://schemas.microsoft.com/ws/2012/01/accounttype",
   Value = "DJ"
);

颁发本地计算机帐户的 objectGUID

http://schemas.microsoft.com/identity/claims/onpremobjectguid 声明必须包含本地计算机帐户的 objectGUID 值。 在 AD FS 中,可以添加如下所示的颁发转换规则:

@RuleName = "Issue object GUID for domain-joined computers"
c1:[
   Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid",
   Value =~ "-515$", 
   Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"
]
&&
c2:[
   Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname",
   Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"
]
=> issue(
   store = "Active Directory",
   types = ("http://schemas.microsoft.com/identity/claims/onpremobjectguid"),
   query = ";objectguid;{0}",
   param = c2.Value
);

颁发本地计算机帐户的 objectSid

http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid 声明必须包含本地计算机帐户的 objectSid 值。 在 AD FS 中,可以添加如下所示的颁发转换规则:

@RuleName = "Issue objectSID for domain-joined computers"
c1:[
   Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid",
   Value =~ "-515$",
   Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"
]
&&
c2:[
   Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid",
   Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"
]
=> issue(claim = c2);

当 Microsoft Entra ID 中存在多个已验证域名时颁发计算机的 issuerID

http://schemas.microsoft.com/ws/2008/06/identity/claims/issuerid 声明必须包含与颁发令牌的本地联合身份验证服务(AD FS 或合作伙伴)相连接的任何已验证域名的统一资源标识符 (URI)。 在 AD FS 中,可以在上述规则的后面,按特定的顺序添加如下所示的颁发转换规则。 必须创建一条规则来显式为用户颁发规则。 在下面的规则中,添加的第一个规则用于标识用户而不是计算机身份验证。

@RuleName = "Issue account type with the value User when its not a computer"
NOT EXISTS(
[
   Type == "http://schemas.microsoft.com/ws/2012/01/accounttype",
   Value == "DJ"
]
)
=> add(
   Type = "http://schemas.microsoft.com/ws/2012/01/accounttype",
   Value = "User"
);

@RuleName = "Capture UPN when AccountType is User and issue the IssuerID"
c1:[
   Type == "http://schemas.xmlsoap.org/claims/UPN"
]
&&
c2:[
   Type == "http://schemas.microsoft.com/ws/2012/01/accounttype",
   Value == "User"
]
=> issue(
   Type = "http://schemas.microsoft.com/ws/2008/06/identity/claims/issuerid",
   Value = regexreplace(
   c1.Value,
   ".+@(?<domain>.+)",
   "http://${domain}/adfs/services/trust/"
   )
);

@RuleName = "Issue issuerID for domain-joined computers"
c:[
   Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid",
   Value =~ "-515$",
   Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"
]
=> issue(
   Type = "http://schemas.microsoft.com/ws/2008/06/identity/claims/issuerid",
   Value = "http://<verified-domain-name>/adfs/services/trust/"
);

在前面的声明中,<verified-domain-name> 为占位符。 将它替换为 Microsoft Entra ID 中的已验证域名之一。 例如,使用 Value = "http://contoso.com/adfs/services/trust/"

若要详细了解验证域名,请参阅将自定义域名添加到 Microsoft Entra ID

若要获取已验证的公司域的列表,可以使用 Get-MgDomain cmdlet。

公司域的列表

当用户存在一个 ImmutableID 时颁发计算机的 ImmutableID(例如,使用 mS-DS-ConsistencyGuid 作为 ImmutableID 的源)

http://schemas.microsoft.com/LiveID/Federation/2008/05/ImmutableID 声明必须包含计算机的有效值。 在 AD FS 中,可按如下所示创建颁发转换规则:

@RuleName = "Issue ImmutableID for computers"
c1:[
   Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid",
   Value =~ "-515$",
   Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"
]
&&
c2:[
   Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname",
   Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"
]
=> issue(
   store = "Active Directory",
   types = ("http://schemas.microsoft.com/LiveID/Federation/2008/05/ImmutableID"),
   query = ";objectguid;{0}",
   param = c2.Value
);

用于创建 AD FS 颁发转换规则的帮助器脚本

可以借助以下脚本创建前述颁发转换规则。

$multipleVerifiedDomainNames = $false
$immutableIDAlreadyIssuedforUsers = $false
$oneOfVerifiedDomainNames = 'example.com'   # Replace example.com with one of your verified domains

$rule1 = '@RuleName = "Issue account type for domain-joined computers"
c:[
   Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid",
   Value =~ "-515$",
   Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"
]
=> issue(
   Type = "http://schemas.microsoft.com/ws/2012/01/accounttype",
   Value = "DJ"
);'

$rule2 = '@RuleName = "Issue object GUID for domain-joined computers"
c1:[
   Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid",
   Value =~ "-515$",
   Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"
]
&&
c2:[
   Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname",
   Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"
]
=> issue(
   store = "Active Directory",
   types = ("http://schemas.microsoft.com/identity/claims/onpremobjectguid"),
   query = ";objectguid;{0}",
   param = c2.Value
);'

$rule3 = '@RuleName = "Issue objectSID for domain-joined computers"
c1:[
   Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid",
   Value =~ "-515$",
   Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"
]
&&
c2:[
   Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/primarysid",
   Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"
]
=> issue(claim = c2);'

$rule4 = ''
if ($multipleVerifiedDomainNames -eq $true) {
$rule4 = '@RuleName = "Issue account type with the value User when it is not a computer"
NOT EXISTS(
[
   Type == "http://schemas.microsoft.com/ws/2012/01/accounttype",
   Value == "DJ"
]
)
=> add(
   Type = "http://schemas.microsoft.com/ws/2012/01/accounttype",
   Value = "User"
);

@RuleName = "Capture UPN when AccountType is User and issue the IssuerID"
c1:[
   Type == "http://schemas.xmlsoap.org/claims/UPN"
]
&&
c2:[
   Type == "http://schemas.microsoft.com/ws/2012/01/accounttype",
   Value == "User"
]
=> issue(
   Type = "http://schemas.microsoft.com/ws/2008/06/identity/claims/issuerid",
   Value = regexreplace(
   c1.Value,
   ".+@(?<domain>.+)",
   "http://${domain}/adfs/services/trust/"
   )
);

@RuleName = "Issue issuerID for domain-joined computers"
c:[
   Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid",
   Value =~ "-515$",
   Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"
]
=> issue(
   Type = "http://schemas.microsoft.com/ws/2008/06/identity/claims/issuerid",
   Value = "http://' + $oneOfVerifiedDomainNames + '/adfs/services/trust/"
);'
}

$rule5 = ''
if ($immutableIDAlreadyIssuedforUsers -eq $true) {
$rule5 = '@RuleName = "Issue ImmutableID for computers"
c1:[
   Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/groupsid",
   Value =~ "-515$",
   Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"
]
&&
c2:[
   Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname",
   Issuer =~ "^(AD AUTHORITY|SELF AUTHORITY|LOCAL AUTHORITY)$"
]
=> issue(
   store = "Active Directory",
   types = ("http://schemas.microsoft.com/LiveID/Federation/2008/05/ImmutableID"),
   query = ";objectguid;{0}",
   param = c2.Value
);'
}

$existingRules = (Get-ADFSRelyingPartyTrust -Identifier urn:federation:partner.microsoftonline.cn).IssuanceTransformRules

$updatedRules = $existingRules + $rule1 + $rule2 + $rule3 + $rule4 + $rule5

$crSet = New-ADFSClaimRuleSet -ClaimRule $updatedRules

Set-AdfsRelyingPartyTrust -TargetIdentifier urn:federation:partner.microsoftonline.cn -IssuanceTransformRules $crSet.ClaimRulesString

备注

  • 此脚本将规则追加到现有规则。 请不要运行该脚本两次,否则会添加规则集两次。 再次运行该脚本之前,请确保这些声明没有相应的规则(在相应的条件下)。

  • 如果有多个已验证的域名,请在脚本中将 $multipleVerifiedDomainNames 的值设置为 $true。 此外,请确保删除由 Microsoft Entra Connect 创建的或通过其他方式创建的任何现有 issuerid 声明。 下面是此规则的一个示例:

    c:[Type == "http://schemas.xmlsoap.org/claims/UPN"]
    => issue(Type = "http://schemas.microsoft.com/ws/2008/06/identity/claims/issuerid", Value = regexreplace(c.Value, ".+@(?<domain>.+)",  "http://${domain}/adfs/services/trust/")); 
    

如果已颁发用户帐户的 ImmutableID 声明,请在脚本中将 $immutableIDAlreadyIssuedforUsers 的值设置为 $true

对实现进行故障排除

如果在完成已加入域的 Windows 设备的 Microsoft Entra 混合加入方面遇到问题,请参阅: