是否有 ldap C/C++ 提供故障转移的库?

发布于 2024-07-06 02:02:57 字数 129 浏览 5 评论 0原文

我正在寻找 C 或 C++ 语言的 LDAP 库,它允许我指定 LDAP 主机名列表而不是单个主机名。 然后,图书馆应使用它可以连接的第一个服务器,以防一台或多台服务器出现故障。 我确信包装现有的库来创建它很容易,但为什么要重新发明轮子呢?

I'm looking for an LDAP libracy in C or C++ that allows me to specify a list of LDAP hostnames instead of a single hostname. The library should then use the first one it can connect to in case one or more of the servers is/are down. I'm sure it'd be easy to wrap an existing library to create this, but why reinvent the wheel?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

请你别敷衍 2024-07-13 02:02:57

novell cldap 库(和 java 库)支持空格分隔的主机列表连接时。 它将依次尝试每一项,如 ldap_init() 页面。

openldap libldap 库还支持传递给 ldap_open() 的空格分隔主机列表或传递给 ldap_initialize() 的逗号分隔列表。

唯一的问题是确保处理连接断开后返回的 LDAP_SERVER_DOWN 错误。 我通常编写一个包装函数来尝试一个操作(即:搜索),并在发生 LDAP_SERVER_DOWN 时尝试重新连接,然后再次执行该操作。

The novell cldap libraries (and java libraries) support a list of space separated hosts when connecting. It'll try each one in turn, as noted in the ldap_init() page.

The openldap libldap library also supports a space separated list of hosts passed to ldap_open() or a comma separated list passed to ldap_initialize().

The only catch is to make sure to handle the LDAP_SERVER_DOWN error that gets returned after a connection goes away. I usually write a wrapper function that tries an operation (ie: a search), and tries to reconnect if LDAP_SERVER_DOWN occurs, and then does the operation again.

独自唱情﹋歌 2024-07-13 02:02:57

使用多个 A 记录,每个记录具有不同的 IP。

ldapserver.example.com.    IN A    1.2.3.4
ldapserver.example.com.    IN A    2.3.4.5

OpenLDAP 客户端库将依次尝试每个主机。 故障转移(不幸的是)与 TCP 连接超时一样慢......

Use multiple A records, each with a different IP.

ldapserver.example.com.    IN A    1.2.3.4
ldapserver.example.com.    IN A    2.3.4.5

The OpenLDAP client libs will try each host in turn. Failover is (unfortunately) as slow as your TCP connection timeout...

忆离笙 2024-07-13 02:02:57

我不能说我曾经听说过一个。 此外,我使用过的大多数支持 LDAP 的软件对故障转移的支持很差或者根本不支持。 您最好尝试在服务器上实现故障转移,将其放在负载平衡器或类似的后面。

I can't say I've ever heard of one. Furthermore, most LDAP-capable software I've used supported failover poorly or not at all. You might be better off trying to implement the failover at the server, by putting it behind a load balancer or similar.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文