class PsuDir::Ldap
Public Class Methods
get_users(filter, fields = [])
click to toggle source
# File lib/psu_dir/ldap.rb, line 6 def get_users(filter, fields = []) retry_if { Hydra::LDAP.get_user(filter, fields) } || [] end
ldap_error_message(e)
click to toggle source
# File lib/psu_dir/ldap.rb, line 34 def ldap_error_message(e) "#{Hydra::LDAP.connection.get_operation_result.message}\nException: #{e.exception}\n#{e.backtrace.join("\n")}" end
retry_if() { || ... }
click to toggle source
Retries the LDAP command up to .tries times, or catches any other kind of LDAP error without retrying. return [block or nil]
# File lib/psu_dir/ldap.rb, line 12 def retry_if tries.times.each do result = yield return result unless unwilling? sleep(PsuDir.ldap_unwilling_sleep) end PsuDir.logger.warn 'LDAP is unwilling to perform this operation, try upping the number of tries' nil rescue Net::LDAP::Error => e PsuDir.logger.warn "Error getting LDAP response: #{ldap_error_message(e)}" nil end
tries()
click to toggle source
# File lib/psu_dir/ldap.rb, line 25 def tries 7 end
unwilling?()
click to toggle source
Numeric code returned by LDAP if it is feeling “unwilling”
# File lib/psu_dir/ldap.rb, line 30 def unwilling? Hydra::LDAP.connection.get_operation_result.code == 53 end