概述
将根域添加到 Microsoft Entra ID(它是 Microsoft Entra 的一部分)后,添加到 Microsoft Entra 组织中的该根域的所有后续子域会自动从根域继承身份验证设置。 但是,如果要独立于根域设置管理域身份验证设置,现在可以使用Microsoft 图形 API执行此操作。 例如,如果你有一个联合根域(如 contoso.com),则本文可以帮助你将子域(如 child.contoso.com)验证为托管子域而非联合子域。
在Azure门户中,当父域联合且管理员尝试验证 Custom 域名页上的托管子域时,页面将显示“无法添加域”错误,原因为“一个或多个属性包含无效值”。如果尝试从Microsoft 365 管理中心中添加此子域, 收到类似的错误。 有关错误的详细信息,请参阅 A 子域不会在 Office 365、Azure 或 Intune 中继承父域更改。
由于子域默认继承根域的身份验证类型,因此必须使用Microsoft Graph将子域提升为Microsoft Entra ID中的根域,以便可以将身份验证类型设置为所需的类型。
警告
此小脚本是演示目的的一个示例。 如果打算在你的环境中使用它,请先进行测试。 应调整代码以满足你的要求。
添加子域
注释
以下示例用作 <your-root-domain> 占位符。 将其替换为你自己的已验证根域名(例如 contoso.com)。
使用 PowerShell 添加新子域,该子域具有其根域的默认身份验证类型。 Microsoft Entra ID和Microsoft 365管理中心尚不支持此操作。
# Connect to Microsoft Graph with the required scopes Connect-MgGraph -Environment China -ClientId 'YOUR_CLIENT_ID' -TenantId 'YOUR_TENANT_ID' -Scopes "Domain.ReadWrite.All" # Define the parameters for the new domain $domainParams = @{ Id = "child6.<your-root-domain>" AuthenticationType = "Federated" } # Create a new domain with the specified parameters New-MgDomain @domainParams使用以下示例通过 GET 获取域名。 因为该域不是根域,所以它继承了根域身份验证类型。 使用你自己的租户 ID,命令和结果可能如下所示:
GET https://microsoftgraph.chinacloudapi.cn/v1.0/domains/foo.contoso.com/ Return: { "authenticationType": "Federated", "availabilityStatus": null, "isAdminManaged": true, "isDefault": false, "isDefaultForCloudRedirections": false, "isInitial": false, "isRoot": false, <---------------- Not a root domain, so it inherits parent domain's authentication type (federated) "isVerified": true, "name": "child.<your-root-domain>", "supportedServices": [], "forceDeleteState": null, "state": null, "passwordValidityPeriodInDays": null, "passwordNotificationWindowInDays": null },
将子域更改为根域
使用以下命令升级子域:
POST https://microsoftgraph.chinacloudapi.cn/v1.0/{tenant-id}/domains/foo.contoso.com/promote
提升命令错误条件
| 场景 | 方法 | Code | 消息 |
|---|---|---|---|
| 调用 API 时使用父域未验证的子域 | POST (发布) | 400 | 无法推广未验证的域。 在推广前请验证域名。 |
| 使用经过联合验证的子域并带有用户引用来调用 API | POST (发布) | 400 | 不允许宣传带有用户引用的子域。 请在提升子域之前将用户迁移到当前根域。 |
将子域身份验证类型更改为“托管”
重要
若要更改联合子域的身份验证类型,应在完成以下步骤之前记下现有的联合配置值。 如果你决定在将域升级以前重新实现联合功能,那么这些信息是必需的。
使用以下命令更改子域身份验证类型:
Connect-MGGraph -Environment China -ClientId 'YOUR_CLIENT_ID' -TenantId 'YOUR_TENANT_ID' -Scopes "Domain.ReadWrite.All", "Directory.AccessAsUser.All" Update-MgDomain -DomainId "test.contoso.com" -BodyParameter @{AuthenticationType="Managed"}在 Microsoft 图形 API 中通过 GET 验证子域身份验证类型现在是否已受到管理:
GET https://microsoftgraph.chinacloudapi.cn/v1.0/domains/foo.contoso.com/ Return: { "authenticationType": "Managed", <---------- Now this domain is successfully added as Managed and not inheriting Federated status "availabilityStatus": null, "isAdminManaged": true, "isDefault": false, "isDefaultForCloudRedirections": false, "isInitial": false, "isRoot": true, <------------------------------ Also a root domain, so not inheriting from parent domain any longer "isVerified": true, "name": "child.<your-root-domain>", "supportedServices": [ "Email", "OfficeCommunicationsOnline", "Intune" ], "forceDeleteState": null, "state": null, "passwordValidityPeriodInDays": null, "passwordNotificationWindowInDays": null }