Raise proper exception when LDAP limits are exceeded

ldap2 plugin returns NotFound error for find_entries/get_entry
queries when the server did not manage to return an entry
due to time limits. This may be confusing for user when the
entry he searches actually exists.

This patch fixes the behavior in ldap2 plugin to
1) Return even a zero search results + truncated bool set in
   ldap2.find_entries
2) Raise LimitsExceeded in ldap2.get_entry and
   ldap2.find_entry_by_attr instead of NotFound error

This changed several assumptions about ldap2.find_entries
results. Several calls accross IPA code base had to be
amended.

https://fedorahosted.org/freeipa/ticket/2606
This commit is contained in:
Martin Kosek
2012-04-17 09:56:04 +02:00
committed by Rob Crittenden
parent adf16a9b1c
commit a663e83cb2
2 changed files with 20 additions and 6 deletions

View File

@@ -724,6 +724,8 @@ class automountkey(LDAPObject):
basedn, _ldap.SCOPE_ONELEVEL)
if len(entries) > 1:
raise errors.NotFound(reason=_('More than one entry with key %(key)s found, use --info to select specific entry.') % dict(key=pkey))
if truncated:
raise errors.LimitsExceeded()
dn = entries[0][0]
return dn