Allow a search using only the exact search filter

This commit is contained in:
Rob Crittenden 2009-03-23 15:13:40 -04:00
parent 1b1f9af01c
commit cf09aab18b

View File

@ -371,6 +371,7 @@ class ldap(CrudBackend):
attributes = kw.get('attributes') attributes = kw.get('attributes')
base = kw.get('base') base = kw.get('base')
scope = kw.get('scope') scope = kw.get('scope')
exactonly = kw.get('exactonly', None)
if attributes: if attributes:
del kw['attributes'] del kw['attributes']
else: else:
@ -383,6 +384,8 @@ class ldap(CrudBackend):
del kw['filter'] del kw['filter']
if scope: if scope:
del kw['scope'] del kw['scope']
if exactonly is not None:
del kw['exactonly']
(exact_match_filter, partial_match_filter) = self._generate_search_filters(**kw) (exact_match_filter, partial_match_filter) = self._generate_search_filters(**kw)
if objectclass: if objectclass:
exact_match_filter = "(&(objectClass=%s)%s)" % (objectclass, exact_match_filter) exact_match_filter = "(&(objectClass=%s)%s)" % (objectclass, exact_match_filter)
@ -403,10 +406,13 @@ class ldap(CrudBackend):
except errors2.NotFound: except errors2.NotFound:
exact_results = [0] exact_results = [0]
try: if not exactonly:
partial_results = servercore.search(search_base, try:
partial_match_filter, attributes, scope=search_scope) partial_results = servercore.search(search_base,
except errors2.NotFound: partial_match_filter, attributes, scope=search_scope)
except errors2.NotFound:
partial_results = [0]
else:
partial_results = [0] partial_results = [0]
exact_counter = exact_results[0] exact_counter = exact_results[0]