filter_lookup.rb 513 B

1234567891011121314151617181920212223
  1. class Ldap
  2. module FilterLookup
  3. # Returns the first of a list of filters which has entries.
  4. #
  5. # @example
  6. # instance.lookup_filter(['filter1', 'filter2'])
  7. # #=> 'filter2'
  8. #
  9. # @return [String, nil] The first filter with entries or nil.
  10. def lookup_filter(possible_filters)
  11. result = nil
  12. possible_filters.each do |possible_filter|
  13. next if !@ldap.entries?(possible_filter)
  14. result = possible_filter
  15. break
  16. end
  17. result
  18. end
  19. end
  20. end