mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
differentiate between limit types when LDAP search exceeds configured limits
When LDAP search fails on exceeded limits, we should raise an specific exception for the type of limit raised (size, time, administrative) so that the consumer can distinguish between e.g. searches returning too many entries and those timing out. https://fedorahosted.org/freeipa/ticket/5677 Reviewed-By: Petr Spacek <pspacek@redhat.com>
This commit is contained in:
committed by
Martin Basti
parent
b23ad42269
commit
1f0959735f
@@ -97,10 +97,8 @@ class KDCProxyConfig(object):
|
||||
def _find_entry(self, dn, attrs, filter, scope=IPAdmin.SCOPE_BASE):
|
||||
"""Find an LDAP entry, handles NotFound and Limit"""
|
||||
try:
|
||||
entries, truncated = self.con.find_entries(
|
||||
filter, attrs, dn, scope, time_limit=self.time_limit)
|
||||
if truncated:
|
||||
raise errors.LimitsExceeded()
|
||||
entries = self.con.get_entries(
|
||||
dn, scope, filter, attrs, time_limit=self.time_limit)
|
||||
except errors.NotFound:
|
||||
self.log.debug('Entry not found: %s', dn)
|
||||
return None
|
||||
|
||||
@@ -160,14 +160,12 @@ def get_config(dirsrv):
|
||||
wait_for_open_ports(host, [int(port)], timeout=api.env.startup_timeout)
|
||||
con = IPAdmin(ldap_uri=api.env.ldap_uri)
|
||||
con.do_external_bind()
|
||||
res, truncated = con.find_entries(
|
||||
res = con.get_entries(
|
||||
base,
|
||||
filter=srcfilter,
|
||||
attrs_list=attrs,
|
||||
base_dn=base,
|
||||
scope=con.SCOPE_SUBTREE,
|
||||
time_limit=10)
|
||||
if truncated:
|
||||
raise errors.LimitsExceeded()
|
||||
except errors.NetworkError:
|
||||
# LSB status code 3: program is not running
|
||||
raise IpactlError("Failed to get list of services to probe status:\n" +
|
||||
|
||||
Reference in New Issue
Block a user