Skip to content

Instantly share code, notes, and snippets.

@alexrothenberg
Created October 3, 2008 15:30
Show Gist options
  • Save alexrothenberg/14572 to your computer and use it in GitHub Desktop.
Save alexrothenberg/14572 to your computer and use it in GitHub Desktop.
class Person #existing implementation
def find_by_name name
filter = adapter.create_equality_filter('uid', "*#{name}*")
results = find(:base => '', :attributes => attribute_mapping.values, :filter => filter)
build_array_of_people_from results
end
def find_by_exact_name name
filter = adapter.create_equality_filter('uid', "#{name}")
results = find(:base => '', :attributes => attribute_mapping.values, :filter => filter)
if (results.size > 1)
raise LDAPException, "Multiple values found"
end
person = build_array_of_people_from results
end
end
class Person #Proposed changes
def find_by_name(name)
puts 'WARNING: find_by_name deprecated. Please use find_all_by_ads_name'
find_all_by_ads_name name
end
def find_by_exact_name(name)
puts 'WARNING: find_by_exact_name deprecated. Please use find_by_ads_name!'
find_by_ads_name! name
end
def find_by_ads_name!(name)
#lookup exact match to ADS name (uid attribute).
# throw exception if >1 match
end
def find_all_by_ads_name(name)
#lookup fuzzy match to ADS name (uid attribute).
# return list of results (list can have 0, 1, or many entries)
end
def find_by_distinguished_name!(name)
#lookup exact match to DOMINO dn
# throw exception if >1 match
end
def find_all_by_distinguished_name(name)
#lookup fuzzy match to DOMINO dn.
# return list of results (list can have 0, 1, or many entries)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment