こんにちは.
LDAPのレプリケーションに対応したいということですよね?
タイムアウトの制御ができないようなので微妙ですが,
以下のようにするとどうでしょう.
・ホスト名をカンマ区切りで複数指定可能
・最初に接続成功したホストを選択(全部失敗なら最初のホスト)
Index: app/models/auth_source_ldap.rb
===================================================================
--- app/models/auth_source_ldap.rb (リビジョン 2838)
+++ app/models/auth_source_ldap.rb (作業コピー)
@@ -87,6 +87,21 @@
:encryption => (self.tls ? :simple_tls : nil)
}
options.merge!(:auth => { :method => :simple, :username =>
ldap_user, :password => ldap_password }) unless ldap_user.blank? &&
ldap_password.blank?
+
+ # LDAP host comma separable
+ hosts = self.host.split(",")
+ if hosts.size > 1
+ # select first live host or first host
+ options[:host] = hosts.find {|h|
+ begin
+ Net::LDAP.new(options.merge(:host => h)).open {}
+ true
+ rescue Net::LDAP::LdapError
+ false
+ end
+ } || hosts.first
+ end
+
Net::LDAP.new options
end