OpenLDAP Proxy -- Tricks and tips

English 简体中文 繁体中文 ภาษาไทย Tiếng Việt
Summary

Setting up an OpenLDAP proxy involves several key considerations to ensure robust and secure operation. It is crucial to use the latest OpenLDAP version to benefit from bug fixes and new features, particularly for connection stability and SSL handling. For secure client and remote server communication, configure SSL certificates, specify ldaps:/// in slapd options, and potentially add TLS_REQCERT allow for trusting remote certificates. When remote LDAP servers require authentication, configure idassert-bind with appropriate credentials and idassert-authzFrom for authorization. To overcome the global nature of attribute mapping with the rwm overlay, define separate overlay rwm blocks for distinct mapping rules, allowing multiple source attributes to map to a single client-facing attribute.

就像其他软件配置一样,在OpenLDAP代理设置过程中可能会遇到问题。在这篇文章中,我们将尝试总结一些OpenLDAP代理设置的技巧和提示。

OpenLDAP版本

我们始终建议您安装最新版本的OpenLDAP,因为它们包含最新的功能、错误修复和安全补丁。您应该始终参考最新的发行说明以了解新的更改。如果您使用的是早期版本的OpenLDAP并遇到了一些异常行为,请尝试先更新到最新版本的OpenLDAP。

以下是我们遇到的一些问题,这些问题通过最新版本得到了解决。

  • 当远程LDAP服务器关闭时,结果将始终为空列表,不会搜索其他远程LDAP服务器
  • 尝试连接到使用SSL的远程LDAP服务器时,LDAP查询挂起且永远不会返回

SSL配置

如果您想为客户端提供安全服务,您可以通过以下更改启用SSL功能。

  • 在配置中,设置证书文件及其私钥位置以及CA证书位置。详细设置可以在OpenLDAP Proxy -- slapd.conf中找到。
  • 运行slapd服务时,需要在其-h选项中指定ldaps:///。见下文
    /usr/sbin/slapd -h 'ldap:/// ldapi:/// ldaps:///' -g ldap -u ldap
  • 从客户端连接使用端口389,这是默认的SSL端口。

如果您希望代理使用SSL连接到远程LDAP,如果您始终希望信任服务器的证书,则需要更新代理服务器中的/etc/ldap/ldap.conf。基本上,您需要在配置文件中添加以下行。

TLS_REQCERT allow

简单身份验证

在某些情况下,当客户端查询远程LDAP服务器时,需要进行身份验证。因此,当LDAP代理连接到远程服务器时,它需要为绑定提供服务器binddncredentials。这可以在/etc/ldap/slapd.conf中配置,并在uri条目之后添加idassert-bind条目。

除此之外,您还需要为代理创建一个虚拟dn和密码,以便LDAP客户端可以使用它进行连接。这些设置是rootdnrootpw。之后,您需要在idassert-bind条目之后添加一个idassert-authzFrom条目来告诉谁被授权启动与远程服务器的绑定。否则,绑定可能无法工作。

详细设置可以在OpenLDAP Proxy -- slapd.conf中找到。

属性映射

OpenLDAP提供属性映射功能,以便可以将远程LDAP服务器中的一些属性映射到客户端可以参考的一些用户友好的属性名称。此功能通常通过overlay rwm条目完成。这会向代理添加一个插件,因此可以完成属性映射。但是,属性映射是全局的,这意味着您不能为每个远程LDAP服务器设置单独的映射。

此限制带来了一些属性映射需求无法满足的问题。例如,如果您有一个基于OpenLDAP的远程LDAP服务器和一个基于Windows AD的远程LDAP服务器,则要求将OpenLDAP服务器的uid映射到accountId,并将Windows AD的sAMAccountName也映射到accountId,由于上述限制,这不容易实现。如果您的配置中有以下映射

overlay rwm
rwm-map       attribute   accountId  uid
rwm-map       attribute   accountId  sAMAccountName

只有最后一个映射会起作用。第一个被覆盖了。但是,如果您想让两个映射都起作用呢?您可以执行以下操作

overlay rwm
rwm-map       attribute   accountId  uid
overlay rwm
rwm-map       attribute   accountId  sAMAccountName

在第二个映射之前添加另一个overlay rwm条目。要了解有关overlay如何工作的更多信息,您可以参考官方文档。以下是它的功能摘要。

本质上,覆盖层代表一种方法:

  • 自定义现有后端的行为,无需更改后端代码,也无需编写具有完整功能的新自定义后端
  • 编写可应用于不同后端类型的通用功能

希望这些技巧能帮助您设置OpenLDAP代理。如果您有其他技巧,请随时发表评论。

SSL AUTHENTICATION OPENLDAP OPENLDAP PROXY ATTRIBUTE MAPPING OVERLAY

  RELATED

  COMMENTS

0

No comment for this article.