filter_lookup.rb 590 B

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