Red Hat Training

A Red Hat training course is available for Red Hat Virtualization

15.3. 删除一个外部 LDAP 供应商

15.3.1. 删除一个外部 LDAP 供应商(交互式设置)

ovirt-engine-extension-aaa-ldap 扩展允许用户方便地定制外部目录地设置。ovirt-engine-extension-aaa-ldap 扩展支持多个不同地 LDAP 服务器类型,它包括一个交互式的设置脚本来帮助设置多数 LDAP 类型。
如果 LDAP 服务器类型没有在交换式设置脚本中出现,或您希望进行更多的定制,您可以手工编辑配置文件。详情请参阅 第 15.3.3 节 “删除一个外部 LDAP 供应商(手工模式)”
第 15.3.2 节 “附加一个 Active Directory” 包括了一个 Active Directory 实例。
先决条件:

  • 您需要知道 DNS 或 LDAP 服务器的域名。循环(round-robin)和故障转移(failover)策略也被支持。
  • 要设置 LDAP 服务器和 Manager 之间的安全连接,请确保已准备好 PEM 编码的 CA 证书。
  • 最少有一组账户名和密码来进行 LDAP 服务器的搜索和登录操作。

过程 15.1. 删除一个外部 LDAP 供应商

  1. 在 Red Hat Virtualization Manager 中安装 LDAP 扩展软件包:
    # yum install ovirt-engine-extension-aaa-ldap-setup
  2. 运行 ovirt-engine-extension-aaa-ldap-setup 启动设置过程:
    # ovirt-engine-extension-aaa-ldap-setup
  3. 输入相应的代码来选择一个 LDAP 类型。如果您不确定 LDAP 服务器所使用的 schema,选您的 LDAP 服务器类型的标准 schema。对于 Active Directory,请参阅 第 15.3.2 节 “附加一个 Active Directory” 中介绍的步骤。
    Available LDAP implementations:
    1 - 389ds
    2 - 389ds RFC-2307 Schema
    3 - Active Directory
    4 - IPA
    5 - Novell eDirectory RFC-2307 Schema
    6 - OpenLDAP RFC-2307 Schema
    7 - OpenLDAP Standard Schema
    8 - Oracle Unified Directory RFC-2307 Schema
    9 - RFC-2307 Schema (Generic)
    10 - RHDS
    11 - RHDS RFC-2307 Schema
    12 - iPlanet
    Please select: 10
  4. Enter 接受默认设置,为 LDAP 服务器名配置相应的域名解析:
    It is highly recommended to use DNS resolution for LDAP server.
    If for some reason you intend to use hosts or plain address disable DNS usage.
    Use DNS (Yes, No) [Yes]:
  5. 输入相应的代码来选择 DNS 策略方法:
    1 - Single server
    2 - DNS domain LDAP SRV record
    3 - Round-robin between multiple hosts
    4 - Failover between multiple hosts
    Please select:
    • 对于选项 1,使用 /etc/resolv.conf 中列出的 DNS 服务器解析 IP 地址。请确认已更新了 /etc/resolv.conf 文件来包括正确的 DNS 服务器。
      输入 LDAP 服务器的 FQDN 或 IP 地址。您可以使用带有 SRV 记录的 dig 命令找出域名。SRV 记录的格式是:_service._protocol.domain name。例如,dig _ldap._tcp.redhat.com SRV
    • 对于选项 2,输入 DNS 服务器的域名。DNS 查询通过查看 SRV 记录找出 LDAP 服务器的域名。
    • 对于选项 3,输入一个由空格分隔的 LDAP 服务器列表。使用服务器的 FQDN 或 IP 地址。这个策略可以实现 LDAP 服务器的负载均衡。查询会根据 round-robin 算法在所有 LDAP 服务器间进行分配。
    • 对于选项 4,输入一个由空格分隔的 LDAP 服务器列表。使用服务器的 FQDN 或 IP 地址。这个策略把第一个服务器作为默认的 LDAP 服务器来处理查询。如果第一个服务器无效,列表中的下一个服务器会处理查询。
  6. 选择 LDAP 服务器支持的安全连接方法,指定获得 PEM 编码的 CA 证书。使用 file 选项可以指定到证书的完全路径;使用 URL 选项可以指定到证书的 URL;使用 inline 选项可以在终端中粘贴证书的内容;system 选项可以指定所有 CA 文件的默认位置。如果选择 insecure 选项,连接仍然会使用 TLS 进行加密,但证书验证的过程会被忽略。
    NOTE:
    It is highly recommended to use secure protocol to access the LDAP server.
    Protocol startTLS is the standard recommended method to do so.
    Only in cases in which the startTLS is not supported, fallback to non standard ldaps protocol.
    Use plain for test environments only.
    Please select protocol to use (startTLS, ldaps, plain) [startTLS]: startTLS
    Please select method to obtain PEM encoded CA certificate (File, URL, Inline, System, Insecure): File
    Please enter the password:

    注意

    LDAPS 是 Lightweight Directory Access Protocol Over Secure Socket Links 的缩写。对于 SSL 连接,选择 ldaps 选项。
  7. 输入搜索用户的可分辨名称(DN)。用户需要有可以浏览目录服务器中的所有用户和组的权限。这个搜索用户需要在 LDAP 批注(LDAP annotation)中指定。如果支持匿名搜索,直接按 Enter
    Enter search user DN (empty for anonymous): uid=user1,ou=Users,dc=test,dc=redhat,dc=com
    Enter search user password:
  8. 输入基础 DN:
    Please enter base DN (dc=redhat,dc=com) [dc=redhat,dc=com]:
  9. 如果要为虚拟机配置单点登录,请输入 Yes。注意此功能无法与管理门户和用户门户功能的单点登录同时使用。脚本会提醒您配置集名称必须和域名匹配。您将需要遵循虚拟机管理指南为虚拟机配置单点登录中的说明。
    Are you going to use Single Sign-On for Virtual Machines (Yes, No) [No]:
  10. 指定一个域名(profile name)。这个域名会出现在用户的登录界面中。在这个示例中使用 redhat.com

    注意

    要在域配置后重新命名配置集,需要编辑 /etc/ovirt-engine/extensions.d/redhat.com-authn.properties 文件中的 ovirt.engine.aaa.authn.profile.name 属性。重启引擎服务以使所做的修改生效。
    Please specify profile name that will be visible to users:redhat.com
    管理门户登录页

    图 15.1. 管理门户登录页

    注意

    用户需要在第一次登录时从下拉列表中选项正确的域。这个信息会被保存在浏览器的 cookie 中,并在下一次用户登录时被预先选择。
  11. 测试搜索和登录功能来保证 LDAP 服务器已被正确地连接到您地 Red Hat Virtualization 环境中。对于登录查询,输入账户名和密码;对于搜索查询,为用户账户选 Principal,为组用户选择 Group。如果需要返回用户的组账户信息,为 Resolve Groups 输入 Yes。选择 Done 完成设置过程。三个配置文件会被创建并在屏幕输出中显示。
    NOTE:
    It is highly recommended to test drive the configuration before applying it into engine.
    Perform at least one Login sequence and one Search sequence.
    Select test sequence to execute (Done, Abort, Login, Search) [Abort]: Login
    Enter search user name: testuser1
    Enter search user password:
    [ INFO  ] Executing login sequence...
    ...
    Select test sequence to execute (Done, Abort, Login, Search) [Abort]: Search
    Select entity to search (Principal, Group) [Principal]:
    Term to search, trailing '*' is allowed: testuser1
    Resolve Groups (Yes, No) [No]: 
    [ INFO  ] Executing login sequence...
    ...
    Select test sequence to execute (Done, Abort, Login, Search) [Abort]: Done
    [ INFO  ] Stage: Transaction setup
    [ INFO  ] Stage: Misc configuration
    [ INFO  ] Stage: Package installation
    [ INFO  ] Stage: Misc configuration
    [ INFO  ] Stage: Transaction commit
    [ INFO  ] Stage: Closing up
              CONFIGURATION SUMMARY
              Profile name is: redhat.com
              The following files were created:
                  /etc/ovirt-engine/aaa/redhat.com.properties
                  /etc/ovirt-engine/extensions.d/redhat.com-authz.properties
                  /etc/ovirt-engine/extensions.d/redhat.com-authn.properties
    [ INFO  ] Stage: Clean up
              Log file is available at /tmp/ovirt-engine-extension-aaa-ldap-setup-20160114064955-1yar9i.log:
    [ INFO  ] Stage: Pre-termination
    [ INFO  ] Stage: Termination
  12. 重启引擎服务。创建的域会出现在管理门户和用户门户的登录界面中。如需了解与为 LDAP 用户分配角色和权限(如登录到用户门户)的信息,请参阅 第 15.6 节 “通过管理门户管理用户任务”
    # systemctl restart ovirt-engine.service

注意

如需了解更多信息,请参阅 LDAP 验证和授权扩展的 README 文件(/usr/share/doc/ovirt-engine-extension-aaa-ldap-version)。

15.3.2. 附加一个 Active Directory

先决条件:

  • 需要知道 Active Directory 的 forest name。forest name 也被成为 root domain name。
  • 在 Manager 的 /etc/resolv.conf 文件中添加一个可用解析到 Active Directory forest name 的 DNS 服务器,或记录下 Active Directory DNS 服务器的信息,在设置脚本提示输入时输入这些信息。
  • 在 LDAP 服务器和 Manager 间创建安全的连接,并准备一个 PEM 编码的 CA 证书。详情请参阅 第 D.2 节 “在 Manager 和一个 LDAP 服务器间设置 SSL 或 TLS 连接”
  • 除非支持匿名搜索,在 Active Directory 上需要有一个可以作为搜索用户的、具有浏览所有用户和组权限的用户。记录下搜索用户的可分辨名称(DN)。不要使用 Active Directory 的管理员用户。
  • 最少有一组账户名和密码来进行 Active Directory 的搜索和查询操作。

过程 15.2. 删除一个外部 LDAP 供应商

  1. 在 Red Hat Virtualization Manager 中安装 LDAP 扩展软件包:
    # yum install ovirt-engine-extension-aaa-ldap-setup
  2. 运行 ovirt-engine-extension-aaa-ldap-setup 启动设置过程:
    # ovirt-engine-extension-aaa-ldap-setup
  3. 选择一个 LDAP 类型。根据所选 LDAP 类型的不同,以后与 LDAP 相关的问题会有所不同。
    Available LDAP implementations:
    1 - 389ds
    2 - 389ds RFC-2307 Schema
    3 - Active Directory
    4 - IPA
    5 - Novell eDirectory RFC-2307 Schema
    6 - OpenLDAP RFC-2307 Schema
    7 - OpenLDAP Standard Schema
    8 - Oracle Unified Directory RFC-2307 Schema
    9 - RFC-2307 Schema (Generic)
    10 - RHDS
    11 - RHDS RFC-2307 Schema
    12 - iPlanet
    Please select: 3
  4. 输入 Active Directory 的林名称(forest name)。如果 Manager 的 DNS 无法解析这个林名称,脚本会要求您输入一个以空格分隔的 Active Directory DNS 服务器名列表。
    Please enter Active Directory Forest name: ad-example.redhat.com
    [ INFO  ] Resolving Global Catalog SRV record for ad-example.redhat.com
    [ INFO  ] Resolving LDAP SRV record for ad-example.redhat.com
  5. 选择 LDAP 服务器支持的安全连接方法,指定获得 PEM 编码的 CA 证书。使用 file 选项可以指定到证书的完全路径;使用 URL 选项可以指定到证书的 UR;使用 inline 选项可以在终端中粘贴证书的内容;system 选项可以指定所有 CA 文件的位置;insecure 选项允许用户以非安全模式使用 startTLS。
    NOTE:
    It is highly recommended to use secure protocol to access the LDAP server.
    Protocol startTLS is the standard recommended method to do so.
    Only in cases in which the startTLS is not supported, fallback to non standard ldaps protocol.
    Use plain for test environments only.
    Please select protocol to use (startTLS, ldaps, plain) [startTLS]: startTLS
    Please select method to obtain PEM encoded CA certificate (File, URL, Inline, System, Insecure): File
    Please enter the password:

    注意

    LDAPS 是 Lightweight Directory Access Protocol Over Secure Socket Links 的缩写。对于 SSL 连接,选择 ldaps 选项。
    如需了解更多与创建 PEM 编码的 CA 证书的信息,请参阅 第 D.2 节 “在 Manager 和一个 LDAP 服务器间设置 SSL 或 TLS 连接”
  6. 输入搜索用户的可分辨名称(DN)。用户需要有可以浏览目录服务器中的所有用户和组的权限。这个搜索用户需要在 LDAP 批注(LDAP annotation)中指定。如果支持匿名搜索,直接按 Enter
    Enter search user DN (empty for anonymous): uid=user1,ou=Users,dc=test,dc=redhat,dc=com
    Enter search user password:
  7. 指定一个域名(profile name)。这个域名会出现在用户的登录界面中。在这个示例中使用 redhat.com
    Please specify profile name that will be visible to users:redhat.com
    管理门户登录页

    图 15.2. 管理门户登录页

    注意

    用户需要在第一次登录时从下拉列表中选项正确的域。这个信息会被保存在浏览器的 cookie 中,并在下一次用户登录时被预先选择。
  8. 测试搜索和登录功能来保证 LDAP 服务器已被正确地连接到您地 Red Hat Virtualization 环境中。对于登录查询,输入账户名和密码;对于搜索查询,为用户账户选 Principal,为组用户选择 Group。如果需要返回用户的组账户信息,为 Resolve Groups 输入 Yes。选择 Done 完成设置过程。三个配置文件会被创建并在屏幕输出中显示。
    NOTE:
    It is highly recommended to test drive the configuration before applying it into engine.
    Perform at least one Login sequence and one Search sequence.
    Select test sequence to execute (Done, Abort, Login, Search) [Abort]: Login
    Enter search user name: testuser1
    Enter search user password:
    [ INFO  ] Executing login sequence...
    ...
    Select test sequence to execute (Done, Abort, Login, Search) [Abort]: Search
    Select entity to search (Principal, Group) [Principal]:
    Term to search, trailing '*' is allowed: testuser1
    Resolve Groups (Yes, No) [No]: 
    [ INFO  ] Executing login sequence...
    ...
    Select test sequence to execute (Done, Abort, Login, Search) [Abort]: Done
    [ INFO  ] Stage: Transaction setup
    [ INFO  ] Stage: Misc configuration
    [ INFO  ] Stage: Package installation
    [ INFO  ] Stage: Misc configuration
    [ INFO  ] Stage: Transaction commit
    [ INFO  ] Stage: Closing up
              CONFIGURATION SUMMARY
              Profile name is: redhat.com
              The following files were created:
                  /etc/ovirt-engine/aaa/redhat.com.properties
                  /etc/ovirt-engine/extensions.d/redhat.com-authz.properties
                  /etc/ovirt-engine/extensions.d/redhat.com-authn.properties
    [ INFO  ] Stage: Clean up
              Log file is available at /tmp/ovirt-engine-extension-aaa-ldap-setup-20160114064955-1yar9i.log:
    [ INFO  ] Stage: Pre-termination
    [ INFO  ] Stage: Termination
  9. 创建的域会出现在管理门户和用户门户的登录界面中。如需了解与为 LDAP 用户分配角色和权限(如登录到用户门户)的信息,请参阅 第 15.6 节 “通过管理门户管理用户任务”

注意

如需了解更多信息,请参阅 LDAP 验证和授权扩展的 README 文件(/usr/share/doc/ovirt-engine-extension-aaa-ldap-version)。

15.3.3. 删除一个外部 LDAP 供应商(手工模式)

ovirt-engine-extension-aaa-ldap 扩展使用 LDAP 协议访问目录服务器并可以进行定制。除非需要在用户门户或管理门户上实现单点登录,kerberos 验证并不需要。
如果前面介绍的交换式设置无法满足您的要求,您可以手工修改配置文件来附加 LDAP 服务器。以下介绍的步骤中使用了常规的信息,您需要根据您的具体情况进行相应的修改。

过程 15.3. 手工配置一个外部 LDAP 供应商

  1. 在 Red Hat Virtualization Manager 上安装 LDAP 扩展软件包:
    # yum install ovirt-engine-extension-aaa-ldap
  2. 把 LDAP 配置模板文件复制到 /etc/ovirt-engine 目录中。其中包括了 Active Directory(ad)和其它目录服务类型(simple)的模板文件。这个示例使用简单配置模板。
    # cp -r /usr/share/ovirt-engine-extension-aaa-ldap/examples/simple/. /etc/ovirt-engine
  3. 重新命名配置文件,从而使它与用户可以在管理门户和用户门户的登录界面中可见的 profile 名相匹配:
    # mv /etc/ovirt-engine/aaa/profile1.properties /etc/ovirt-engine/aaa/example.properties
    # mv /etc/ovirt-engine/extensions.d/profile1-authn.properties /etc/ovirt-engine/extensions.d/example-authn.properties
    # mv /etc/ovirt-engine/extensions.d/profile1-authz.properties /etc/ovirt-engine/extensions.d/example-authz.properties
  4. 编辑 LDAP 属性配置文件,取消注释一个 LDAP 服务器类型并更新域和密码项的内容:
    #  vi /etc/ovirt-engine/aaa/example.properties

    例 15.1. 配置档案实例:LDAP 服务器部分

    # Select one
    #
    include = <openldap.properties>
    #include = <389ds.properties>
    #include = <rhds.properties>
    #include = <ipa.properties>
    #include = <iplanet.properties>
    #include = <rfc2307-389ds.properties>
    #include = <rfc2307-rhds.properties>
    #include = <rfc2307-openldap.properties>
    #include = <rfc2307-edir.properties>
    #include = <rfc2307-generic.properties>
    
    # Server
    #
    vars.server = ldap1.company.com
    
    # Search user and its password.
    #
    vars.user = uid=search,cn=users,cn=accounts,dc=company,dc=com
    vars.password = 123456
    
    pool.default.serverset.single.server = ${global:vars.server}
    pool.default.auth.simple.bindDN = ${global:vars.user}
    pool.default.auth.simple.password = ${global:vars.password}
    为了使用 TLS 或 SSL 协议来与 LDAP 服务器进行交流,获得 LDAP 服务器的根(root)CA 证书,使用它来创建一个公共的 keystore 文件。取消注释以下行,指定到公共 keystore 文件的完全路径以及访问这个文件的密码。

    注意

    如需了解更多与创建公共 keystore 文件相关的信息,请参阅 第 D.2 节 “在 Manager 和一个 LDAP 服务器间设置 SSL 或 TLS 连接”

    例 15.2. 配置档案实例:keystore 部分

    # Create keystore, import certificate chain and uncomment
    # if using tls.
    pool.default.ssl.startTLS = true
    pool.default.ssl.truststore.file = /full/path/to/myrootca.jks
    pool.default.ssl.truststore.password = password
  5. 检查验证配置文件。用户在管理门户和用户门户的登录界面中可以选择的 profile 由 ovirt.engine.aaa.authn.profile.name 定义。配置 profile 的位置必须和 LDAP 配置文件的位置相匹配。所有项都可以使用默认值。
    # vi /etc/ovirt-engine/extensions.d/example-authn.properties

    例 15.3. 验证配置文件的示例

    ovirt.engine.extension.name = example-authn
    ovirt.engine.extension.bindings.method = jbossmodule
    ovirt.engine.extension.binding.jbossmodule.module = org.ovirt.engine-extensions.aaa.ldap
    ovirt.engine.extension.binding.jbossmodule.class = org.ovirt.engineextensions.aaa.ldap.AuthnExtension
    ovirt.engine.extension.provides = org.ovirt.engine.api.extensions.aaa.Authn
    ovirt.engine.aaa.authn.profile.name = example
    ovirt.engine.aaa.authn.authz.plugin = example-authz
    config.profile.file.1 = ../aaa/example.properties
  6. 检查授权配置文件。这个配置集的配置必须和 LDAP 配置文件的位置相匹配。所有项都可以使用默认值。
    # vi /etc/ovirt-engine/extensions.d/example-authz.properties

    例 15.4. 授权配置文件的示例

    ovirt.engine.extension.name = example-authz
    ovirt.engine.extension.bindings.method = jbossmodule
    ovirt.engine.extension.binding.jbossmodule.module = org.ovirt.engine-extensions.aaa.ldap
    ovirt.engine.extension.binding.jbossmodule.class = org.ovirt.engineextensions.aaa.ldap.AuthzExtension
    ovirt.engine.extension.provides = org.ovirt.engine.api.extensions.aaa.Authz
    config.profile.file.1 = ../aaa/example.properties
  7. 为配置文件设置正确的所有者权限和访问权限:
    # chown ovirt:ovirt /etc/ovirt-engine/aaa/example.properties
    # chmod 600 /etc/ovirt-engine/aaa/example.properties
  8. 重新启动引擎服务:
    # systemctl restart ovirt-engine.service
  9. 您所创建的 example 配置集会出现在管理门户和用户门户的登录界面中。如需了解与为 LDAP 用户分配权限(如登录到用户门户)的信息,请参阅 第 15.6 节 “通过管理门户管理用户任务”

注意

如需了解更多信息,请参阅 LDAP 验证和授权扩展的 README 文件(/usr/share/doc/ovirt-engine-extension-aaa-ldap-version)。