summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ipalib/errors.py15
-rw-r--r--ipalib/plugins/baseldap.py4
-rw-r--r--ipapython/ipaldap.py2
3 files changed, 19 insertions, 2 deletions
diff --git a/ipalib/errors.py b/ipalib/errors.py
index f0426583d..89b1ef2e0 100644
--- a/ipalib/errors.py
+++ b/ipalib/errors.py
@@ -1329,6 +1329,21 @@ class PosixGroupViolation(ExecutionError):
errno = 4030
format = _('This is already a posix group and cannot be converted to external one')
+class EmptyResult(NotFound):
+ """
+ **4031** Raised when a LDAP search returned no results.
+
+ For example:
+
+ >>> raise EmptyResult(reason='no matching entry found')
+ Traceback (most recent call last):
+ ...
+ EmptyResult: no matching entry found
+
+ """
+
+ errno = 4031
+
class BuiltinError(ExecutionError):
"""
**4100** Base class for builtin execution errors (*4100 - 4199*).
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py
index 375441c0f..4b1c70192 100644
--- a/ipalib/plugins/baseldap.py
+++ b/ipalib/plugins/baseldap.py
@@ -1995,8 +1995,10 @@ class LDAPSearch(BaseLDAPCommand, crud.Search):
time_limit=options.get('timelimit', None),
size_limit=options.get('sizelimit', None)
)
- except errors.NotFound:
+ except errors.EmptyResult:
(entries, truncated) = ([], False)
+ except errors.NotFound:
+ self.api.Object[self.obj.parent_object].handle_not_found(*args[:-1])
for callback in self.get_callbacks('post'):
truncated = callback(self, ldap, entries, truncated, *args, **options)
diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py
index 1702daa25..ce07006eb 100644
--- a/ipapython/ipaldap.py
+++ b/ipapython/ipaldap.py
@@ -1527,7 +1527,7 @@ class LDAPClient(object):
break
if not res and not truncated:
- raise errors.NotFound(reason='no such entry')
+ raise errors.EmptyResult(reason='no matching entry found')
return (res, truncated)