3.11. 使用引用完整性来维护条目之间的关系


参考完整性是一种数据库机制,可确保目录服务器在相关条目之间保持关系。您可以使用此功能来确保对目录中一个条目的更新被正确反映到引用更新条目的其他条目中。

例如,如果您从目录中删除用户,并且启用了 referential Integrity 插件,服务器也会从用户所属的任何组中删除该用户。如果没有启用插件,则用户会保留组的成员,直到管理员手动删除它。

如果您将目录服务器与其他依赖 Directory Server 进行用户和组管理的产品集成,则参考完整性是一个重要功能。

3.11.1. referential Integrity 插件的工作原理

当您启用 referential Integrity 插件时,它会在操作后立即对 成员uniqueMember所有者和 seeAlso 属性执行完整性检查。

例如,如果管理员在目录中删除、更新、重命名或移动组或用户,目录服务器会将操作记录在 referential Integrity 日志文件中。然后,目录服务器使用来自此日志文件的可分辨名称(DN),并搜索与插件配置中指定的属性匹配的条目,然后更新匹配的条目。例如,在删除 cn=demo,dc=example,dc=com 条目后,插件会搜索将 member 属性设置为 cn=demo,dc=example,dc=com 的条目,并删除这些成员属性。之后,插件对 uniqueMemberownerseeAlso 属性执行相同的操作。

默认情况下,Directory 服务器在与原始操作相同的事务中进行搜索和更新。因为搜索和更新操作可能需要大量时间,所以可以在完成原始操作后延迟它们。您可以使用 dsconf 插件的 -update-delay 选项引用ential-integrity set 命令,将原始操作与完整性更新分开。

为避免修改和删除操作的性能不佳,请对您在 referential Integrity 插件配置中指定的属性进行索引。

3.11.2. 使用命令行配置 referential Integrity 插件

您可以使用命令行配置 referential Integrity 插件。

对复制拓扑中的每个供应商执行这个步骤。

流程

  1. 启用 referential Integrity 插件:

    # dsconf <instance_name> plugin referential-integrity enable
    Copy to Clipboard Toggle word wrap
  2. 设置插件搜索删除或重命名用户条目的子树:

    # dsconf <instance_name> plugin referential-integrity set --entry-scope "ou=People,dc=example,dc=com"
    Copy to Clipboard Toggle word wrap
  3. 可选:排除条目范围下的子树:

    # dsconf <instance_name> plugin referential-integrity set --exclude-entry-scope "ou=Special Users,ou=People,dc=example,dc=com"
    Copy to Clipboard Toggle word wrap

    此命令将插件配置为忽略在 ou=Special Users,ou=People,dc=example,dc=com 子树中执行的 delete 或 rename 操作。

  4. 配置插件更新组条目的子树:

    # dsconf <instance_name> plugin referential-integrity set --container-scope "ou=Groups,dc=example,dc=com"
    Copy to Clipboard Toggle word wrap
  5. 默认情况下,插件对 成员uniqueMember所有者和 seeAlso 属性执行完整性检查。要指定其他属性,请输入:

    # dsconf <instance_name> plugin referential-integrity set --membership-attr attribute_1 attribute_2
    Copy to Clipboard Toggle word wrap

    请注意,这个命令会覆盖插件配置中的属性列表。如果要添加属性,请将当前属性列表和附加属性传递给 --membership-attr 选项。

  6. 可选: 默认情况下,Directory 服务器会立即执行引用完整性检查。如果要设置延迟,请输入:

    # dsconf <instance_name> plugin referential-integrity set --update-delay=5
    Copy to Clipboard Toggle word wrap

    此命令会延迟引用完整性检查 5 秒。请注意,如果您在多个供应商上启用引用完整性,设置延迟可能会导致复制循环和目录不一致。要避免这样的问题,请只在拓扑中的一个供应商上启用插件。

  7. 重启实例:

    # dsctl <instance_name> restart
    Copy to Clipboard Toggle word wrap

验证

  1. 显示 referential Integrity 插件配置:

    # dsconf <instance_name> plugin referential-integrity show
    ...
    nsslapd-plugincontainerscope: ou=Groups,dc=example,dc=com
    nsslapd-pluginentryscope: ou=People,dc=example,dc=com
    ...
    referint-membership-attr: member
    referint-membership-attr: uniquemember
    referint-membership-attr: owner
    referint-membership-attr: seeAlso
    referint-update-delay: 0
    ...
    Copy to Clipboard Toggle word wrap
  2. 通过显示组成员属性来列出 组成员

    # ldapsearch -D "cn=Directory Manager" -W -H ldap://server.example.com -b "cn=demoGroup,ou=Groups,dc=example,dc=com" member
    ...
    member: uid=demoUser,ou=People,dc=example,dc=com
    Copy to Clipboard Toggle word wrap
  3. 删除 uid=demoUser,ou=People,dc=example,dc=com 用户:

    # dsidm <instance_name> -b "dc=example,dc=com" user delete "uid=demoUser,ou=People,dc=example,dc=com"
    Copy to Clipboard Toggle word wrap
  4. 再次显示组成员:

    # ldapsearch -D "cn=Directory Manager" -W -H ldap://server.example.com -b "cn=demoGroup,ou=People,dc=example,dc=com" member
    Copy to Clipboard Toggle word wrap

    如果 uid=demoUser,ou=People,dc=example,dc=com 不再列为组的成员,则 Referential Integrity 插件可以正常工作。

您可以使用 Directory Server Web 控制台配置 Referential Integrity 插件。

对复制拓扑中的每个供应商执行这个步骤。

前提条件

  • 在 web 控制台中登录到实例。

流程

  1. 导航到 Plugins Referential Integrity
  2. 启用插件。
  3. 单击 Actions Restart Instance
  4. 再次导航到 Plugins referential Integrity
  5. 默认情况下,插件对 成员uniqueMember所有者和 seeAlso 属性执行完整性检查。要指定其他属性,请更新 Membership Attribute 字段中的列表。
  6. Entry Scope 字段设置为子树的 DN,其中插件应搜索用户条目的 delete 或 rename 操作。
  7. 可选: 要在条目范围下排除子树,请在 Exclude Entry Scope 字段中输入子树的 DN。
  8. Container Scope 字段设置为子树的 DN,其中插件应该更新组条目。
  9. 可选:更新引用完整性日志文件的路径。目录服务器使用此文件跟踪目录中的更改。请注意,dirsrv 用户必须具有这个位置的写入权限。
  10. 可选: 默认情况下,Directory 服务器会立即执行引用完整性检查。如果要设置延迟,请在 Update Delay 字段中设置它。

    请注意,如果您在多个供应商上启用引用完整性,设置延迟可能会导致复制循环和目录不一致。要避免这样的问题,请只在拓扑中的一个供应商上启用插件。

  11. 单击 Save Config

验证

  1. 通过显示组成员属性来列出 组成员

    # ldapsearch -D "cn=Directory Manager" -W -H ldap://server.example.com -b "cn=demoGroup,ou=Groups,dc=example,dc=com" member
    ...
    member: uid=demoUser,ou=People,dc=example,dc=com
    Copy to Clipboard Toggle word wrap
  2. 删除 uid=demoUser,ou=People,dc=example,dc=com 用户:

    # dsidm <instance_name> -b "dc=example,dc=com" user delete "uid=demoUser,ou=People,dc=example,dc=com"
    Copy to Clipboard Toggle word wrap
  3. 再次显示组成员:

    # ldapsearch -D "cn=Directory Manager" -W -H ldap://server.example.com -b "cn=demoGroup,ou=People,dc=example,dc=com" member
    Copy to Clipboard Toggle word wrap

    如果 uid=demoUser,ou=People,dc=example,dc=com 不再列为组的成员,则 Referential Integrity 插件可以正常工作。

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat