16.5. 同步用户

用户不会在 Directory 服务器和 Active Directory 之间自动同步。必须配置同步这两个指令:
  • 如果在同步协议中通过选择 Sync New Windows Users 选项,则 Active Directory 域中的用户会被同步。同步时,所有 Windows 用户都会复制到目录服务器中,然后在创建时同步新用户。
  • 目录服务器用户帐户通过 Directory Server 条目中存在的特定属性与 Active Directory 同步。任何目录服务器条目都必须具有 ntUser 对象类和 ntUserCreateNewAccount 属性;ntUserCreateNewAccount 属性(即使在现有条目上)会向 Directory Server Windows 同步插件发送信号,将条目写入到 Active Directory 服务器。
    在下次常规更新时,会创建和修改的带有 ntUser 对象类的用户条目,并在下一次常规更新时与 Windows 机器同步,这是条目的标准轮询。
注意
用户在 Active Directory 域中未激活,直到它有密码。当将现有用户修改为具有所需的 Windows 属性时,该用户条目将同步到 Active Directory 域,但将无法登录,直到密码在 Directory Server 端或管理员在 Active Directory 上设置密码。这是因为目录服务器中存储的密码已加密,密码同步无法同步 已加密的密码。
要使用户在 Active Directory 域中激活,请重置用户的密码。
Directory 服务器中的所有 同步条目(无论是来自目录服务器还是 Active Directory)都有特殊的同步属性:
  • ntUserDomainId.这与 Active Directory 条目的 sAMAccountName 属性对应。
  • ntUniqueId.它包含对应 Windows 条目的 objectGUID 属性的值。此属性由同步进程设置,不应手动设置或修改。
  • ntUserDeleteAccount.当 Windows 条目同步时,会自动设置此属性,但必须为 Directory Server 条目手动设置。如果 ntUserDeleteAccount 的值为 true,则当 Directory Server 条目被删除时,会删除对应的 Windows 条目。否则,该条目保留在 Active Directory 中,但如果在 Directory Server 中删除,则条目会从 Directory Server 数据库中删除。
在 Directory Server 条目上设置 ntUserCreateNewAccountntUserDeleteAccount 允许目录管理器精确控制同步子树中的哪些用户在 Active Directory 上同步。

16.5.1. 在 Directory 服务器和 Active Directory 之间同步的用户属性

只有 Directory 服务器和 Active Directory 的部分属性会同步。这些属性是硬编码的,无论条目同步的方式是什么。条目中存在的任何其他属性(在 Directory Server 或 Active Directory 中)均不受同步的影响。
Directory 服务器和 Active Directory 中使用的一些属性是相同的。它们通常是在 LDAP 标准中定义的属性,在所有 LDAP 服务间都很常见。这些属性会完全同步到另一个属性。表 16.2 “用户架构,其在 Directory 服务器和 Windows 服务器中是相同的” 显示 Directory 服务器和 Windows 服务器之间是相同的属性。
有些属性会定义相同的信息,但属性的名称或其架构定义有所不同。这些属性在 Active Directory 和 Directory Server 之间映射,因此一个服务器上的属性 A 被视为另一个服务器中的属性 B。对于同步,许多与 Windows 特定信息相关的属性。表 16.1 “在 Directory 服务器和 Active Directory 之间映射的用户架构” 显示目录服务器和 Windows 服务器之间映射的属性。
有关 Directory 服务器和 Active Directory 处理某些架构元素的方式差异的更多信息,请参阅 第 16.5.2 节 “Red Hat Directory Server 和 Active Directory 之间的用户架构差异”

表 16.1. 在 Directory 服务器和 Active Directory 之间映射的用户架构

目录服务器 Active Directory
cn[a] name
ntUserDomainId sAMAccountName
ntUserHomeDir homeDirectory
ntUserScriptPath scriptPath
ntUserLastLogon lastLogon
ntUserLastLogoff lastLogoff
ntUserAcctExpires accountExpires
ntUserCodePage codePage
ntUserLogonHours logonHours
ntUserMaxStorage maxStorage
ntUserProfile profilePath
ntUserParms userParameters
ntUserWorkstations userWorkstations
[a] cn 和其它同步属性不同。当从 Directory Server 同步到 Active Directory 时,它会被直接映射 (cncn)。从 Active Directory 同步到 Directory 服务器时,cn 从 Windows 上的 name 属性映射到 Directory Server 中的 cn 属性。

表 16.2. 用户架构,其在 Directory 服务器和 Windows 服务器中是相同的

cn[a] physicalDeliveryOfficeName
description postOfficeBox
destinationIndicator postalAddress
facsimileTelephoneNumber postalCode
givenName registeredAddress
homePhone sn
homePostalAddress st
Initials 法国
l telephoneNumber
mail teletexTerminalIdentifier
手机 telexNumber
o title
ou usercertificate
pager x121Address
[a] cn 和其它同步属性不同。当从 Directory Server 同步到 Active Directory 时,它会被直接映射 (cncn)。从 Active Directory 同步到 Directory 服务器时,cn 从 Windows 上的 name 属性映射到 Directory Server 中的 cn 属性。

16.5.2. Red Hat Directory Server 和 Active Directory 之间的用户架构差异

虽然 Active Directory 支持与目录服务器相同的基本 X.500 对象类,但管理员应该了解哪些不兼容性。

16.5.2.1. cn 属性的值

在 Directory 服务器中,cn 属性可以是多值,而在 Active Directory 中,此属性必须只有一个值。当 Directory Server cn 属性同步时,只有一个值发送到 Active Directory peer。
这对于同步意味着,如果将 cn 值添加到 Active Directory 条目,且该值不是 Directory Server 中 cn 的值之一,则所有 Directory Server cn 值都会用单个 Active Directory 值覆盖。
另一个重要的区别是 Active Directory 使用 cn 属性作为其命名属性,其中 Directory 服务器使用 uid。这意味着,如果目录服务器中编辑 cn 属性,则可能完全重命名条目(并意外)。如果 cn 更改被写入 Active Directory 条目,则会重命名该条目,新的命名条目将写回目录服务器。

16.5.2.2. 密码策略

Active Directory 和 Directory 服务器都可以强制执行密码策略,如密码最小长度或最长期限。Windows 同步不会尝试确保策略一致、强制或同步。如果 Directory 服务器和 Active Directory 中密码策略不一致,那么当同步到其他系统时,在一个系统上进行的密码更改可能会失败。目录服务器上的默认密码语法设置模拟 Active Directory 强制的默认密码复杂性规则。

16.5.2.3. street 和 streetAddress 的值

Active Directory 将属性 streetAddress 用于用户或组的 postal 地址;这是目录服务器使用 street 属性的方式。Active Directory 和 Directory 服务器分别使用 streetAddressstreet 属性的方式有两个重要的区别:
  • 在目录服务器中,streetAddressstreet 的别名。Active Directory 也具有 street 属性,但它是一个单独的属性,可以存放独立的值,而不是 streetAddress 的别名。
  • Active Directory 将 streetAddressstreet 定义为单值属性,而目录服务器将 street 定义为多值属性,如 RFC 4519 中指定的。
由于 Directory 服务器和 Active Directory 处理 streetAddressstreet 属性的不同方法,在活动目录和目录服务器中设置地址属性时有两个规则:
  • Windows 同步将 Windows 条目中的 streetAddress 映射到目录服务器中的 street。为避免冲突,不应在 Active Directory 中使用 street 属性。
  • 只有一个目录服务器 street 属性值被同步到 Active Directory。如果在 Active Directory 中更改了 streetAddress 属性,且 Directory 服务器中不存在新值,则目录服务器中的所有 street 属性值都会被替换为新的单个 Active Directory 值。

16.5.2.4. 初始属性的限制

对于 initials 属性,Active Directory 会实施最大长度约束为六个字符,但目录服务器没有长度限制。如果在 Directory Server 中添加大于六个字符的 initials 属性,则该值会在与 Active Directory 条目同步时进行修剪。

16.5.3. 为目录服务器用户配置用户会话

要使目录服务器用户与 Active Directory 同步,用户条目必须设置适当的同步属性。
要通过命令行启用同步,请将所需的同步属性添加到条目中,或使用这些属性创建条目。
同步需要三个模式元素:
  • ntUser 对象类
  • ntUserDomainId 属性,用于提供 Windows ID
  • ntUserCreateNewAccount 属性向同步插件发出信号,以便将目录服务器条目同步到 Active Directory
例如,使用 ldapmodify 工具:
dn: uid=scarter,ou=People,dc=example,dc=com
changetype: modify
add: objectClass
objectClass:ntUser
-
add: ntUserDomainId
ntUserDomainId: Sam Carter
-
add: ntUserCreateNewAccount
ntUserCreateNewAccount: true
-
add: ntUserDeleteAccount
ntUserDeleteAccount: true
很多额外的 Windows 和用户属性可以添加到该条目中。同步的所有模式都在 第 16.5.1 节 “在 Directory 服务器和 Active Directory 之间同步的用户属性” 中列出。属于 ntUser 对象类的特定于 Windows 的属性在 Red Hat Directory Server 11 配置、命令和文件参考 中进行了更详细的描述。
注意
重置用户的密码。
用户在 Active Directory 域中未激活,直到它有密码。当将现有用户修改为具有所需的 Windows 属性时,该用户条目将同步到 Active Directory 域,但将无法登录,直到密码在 Directory Server 端或管理员在 Active Directory 上设置密码。密码同步 无法同步加密密码。
因此,若要使用户在 Active Directory 域中激活,请重置用户的密码。

16.5.4. 为活动目录用户配置用户会话

Windows 用户的同步(源自 Active Directory 域的用户)是在同步协议中配置。
启用用户同步:
# dsconf -D "cn=Directory Manager" ldap://server.example.com repl-winsync-agmt set --sync-users="on" --suffix="dc=example,dc=com" example-agreement
要禁用用户同步,可将 --sync-users 选项设置为 off