开发者

Adding a secondary/backup LDAP server in ruby-ldap

开发者 https://www.devze.com 2023-01-31 07:07 出处:网络
There are lots of examples out there about how to open and use a Ruby/LDAP connection. I do 开发者_StackOverflow社区not see any documentation or examples about opening a connection to one LDAP server

There are lots of examples out there about how to open and use a Ruby/LDAP connection. I do 开发者_StackOverflow社区not see any documentation or examples about opening a connection to one LDAP server and automatically falling back to a secondary/backup LDAP server. For instance, I have this:

ldap_port = LDAP::LDAP_PORT
ldap_scope = LDAP::LDAP_SCOPE_SUBTREE
ldap = LDAP::Conn.new(host1, ldap_port)

Does Ruby/LDAP have anything like

ldap.secondary(host2, ldap_port)

or am I going to have to do this manually with a begin/rescue/end?


i think the best way would be with a rescue

ldap_port = LDAP::LDAP_PORT
ldap_scope = LDAP::LDAP_SCOPE_SUBTREE
begin  
ldap = LDAP::Conn.new(host1, ldap_port)
rescue LDAP::Error
ldap = LDAP::Conn.new(host2, ldap_port)
end

somehting like that

0

精彩评论

暂无评论...
验证码 换一张
取 消