Took a suggestion from Andre Nathan (andre@digirati.com.br)

to change the behavior of Net::LDAP::Filter#method_missing
to allow case-insensitive attribute names.
This commit is contained in:
blackhedd 2006-05-18 03:52:38 +00:00
parent 7de0147b21
commit 241d9b8fb3
2 changed files with 10 additions and 4 deletions

View file

@ -50,7 +50,7 @@ class LDAP
# restrict the range of characters allowed in attribute names. # restrict the range of characters allowed in attribute names.
# To simplify handling attribute names, Net::LDAP::Entry # To simplify handling attribute names, Net::LDAP::Entry
# internally converts them to a standard format. Therefore, the # internally converts them to a standard format. Therefore, the
# methods which take attribute names can take Strings or Synmbols, # methods which take attribute names can take Strings or Symbols,
# and work correctly regardless of case or capitalization. # and work correctly regardless of case or capitalization.
# #
# An attribute consists of zero or more data items called # An attribute consists of zero or more data items called
@ -140,7 +140,7 @@ class LDAP
# arguments or a block... # arguments or a block...
# #
def method_missing *args, &block # :nodoc: def method_missing *args, &block # :nodoc:
s = args[0] s = args[0].to_s.downcase.intern
if attribute_names.include?(s) if attribute_names.include?(s)
self[s] self[s]
elsif s.to_s[-1] == 61 and s.to_s.length > 1 elsif s.to_s[-1] == 61 and s.to_s.length > 1

View file

@ -272,8 +272,14 @@ class Filter
# Converts an LDAP filter-string (in the prefix syntax specified in RFC-2254) # Converts an LDAP filter-string (in the prefix syntax specified in RFC-2254)
# to a Net::LDAP::Filter. # to a Net::LDAP::Filter.
def self.from_rfc2254 str def self.construct ldap_filter_string
FilterParser.new(str).filter FilterParser.new(ldap_filter_string).filter
end
# Synonym for #construct.
# to a Net::LDAP::Filter.
def self.from_rfc2254 ldap_filter_string
construct ldap_filter_string
end end
end # class Net::LDAP::Filter end # class Net::LDAP::Filter