是否有 ldap C/C++ 提供故障转移的库?
我正在寻找 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
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 toldap_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 ifLDAP_SERVER_DOWN
occurs, and then does the operation again.使用多个 A 记录,每个记录具有不同的 IP。
OpenLDAP 客户端库将依次尝试每个主机。 故障转移(不幸的是)与 TCP 连接超时一样慢......
Use multiple A records, each with a different IP.
The OpenLDAP client libs will try each host in turn. Failover is (unfortunately) as slow as your TCP connection timeout...
我不能说我曾经听说过一个。 此外,我使用过的大多数支持 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.