1. 信任类型
| 信任类型 | 方向 | 用途 |
|---|---|---|
| 外部信任 | 单向/双向 | 独立的两个林之间的信任 |
| 林信任 | 双向 | 整个林之间的信任,子域自动继承 |
| 领域信任 | 单向/双向 | AD 与 NIS 域之间的信任 |
| 快捷信任 | 双向 | 同一林中两个域之间的快捷信任 |
2. 建立外部信任
PowerShell - 建立外部信任
# 在林 A(iehang.cn)上创建指向林 B 的外部信任
netdom trust iehang.cn /Domain:B /Add /TwoWay:Yes /PasswordT:*
# 使用 PowerShell 建立林信任
New-ADTrust -Name "partner.com" `
-SourceDomain "iehang.cn" `
-TargetDomain "partner.com" `
-TrustType "ForestExternal" `
-TrustDirection "Bidirectional"
# 验证信任状态
Get-ADTrust -Filter { $_.Target -match "partner" }
3. 林信任配置
PowerShell - 建立林信任
# 建立两个林之间的林信任
New-ADForestTrust -Domain "iehang.cn" `
-PartnerDomains "acme.com" `
-Direction "Bidirectional" `
-IncludeGlobalCatalogs $true
# 传递身份验证
Set-ADTrust -Identity "iehang.cn" `
-SelectiveAuthentication $false
# 验证林信任
Get-ADForest -Identity "iehang.cn" | Select-Object Name, Trusts
4. 权限映射
跨林访问需要明确授权外部域的用户或组。
PowerShell - 添加跨域权限
# 将外部用户添加到本地组
Add-ADGroupMember -Identity "Domain Admins" `
-Members "partner.com\Domain Admins"
# 使用 SID History 迁移账户
Set-ADUser -Identity "User01" `
-add @{"msExchMasterAccountHistory"="S-1-5-21-xxx"}
# 授予外部用户共享访问权限
Grant-SmbAccess -Name "Share01" `
-AccountName "partner.com\Group01" -AccessRight "Full"
5. 常见问题
Q1:跨林登录失败如何排查
① 检查信任状态 netdom trust ② 验证 DNS 解析 ③ 检查防火墙放行 88/389/445 端口 ④ 查看安全日志
Q2:外部信任可以选择性身份验证吗
可以。使用选择性身份验证,只允许特定用户或组通过信任访问资源,提高安全性。