https://fedorahosted.org/freeipa/ticket/5634

Patch attached.
From c3ff150ac9787608f0bb7b27802a499a05084b49 Mon Sep 17 00:00:00 2001
From: Martin Basti <mba...@redhat.com>
Date: Tue, 26 Jan 2016 13:47:56 +0100
Subject: [PATCH] Warn user when ipa *-find reach limit

Truncated entries were silently ignored, now a user receives warning.

https://fedorahosted.org/freeipa/ticket/5634
---
 ipalib/messages.py         | 10 ++++++++++
 ipalib/plugins/baseldap.py |  8 +++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/ipalib/messages.py b/ipalib/messages.py
index 078e13f596f448601a74d0241801bc9ee858548f..bc39b0e17270fdd2f1de356ae024f51c1511b3c1 100644
--- a/ipalib/messages.py
+++ b/ipalib/messages.py
@@ -331,6 +331,16 @@ class ExternalCommandOutput(PublicMessage):
     format = _("%(line)s")
 
 
+class SearchResultTruncated(PublicMessage):
+    """
+    **13017** Results of LDAP search has been truncated
+    """
+
+    errno = 13017
+    type = "warning"
+    format = _("Search result has been truncated, please increase search limit")
+
+
 def iter_messages(variables, base):
     """Return a tuple with all subclasses
     """
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py
index 5f7b7fba1dbf782cfcbffadce55d1610122cb72c..03a255ca1303091f8a9f08f6ae1d0f76281937a0 100644
--- a/ipalib/plugins/baseldap.py
+++ b/ipalib/plugins/baseldap.py
@@ -35,6 +35,7 @@ from ipalib import output
 from ipalib.text import _
 from ipalib.util import json_serialize, validate_hostname
 from ipalib.capabilities import client_has_capability
+from ipalib.messages import add_message, SearchResultTruncated
 from ipapython.dn import DN
 from ipapython.version import API_VERSION
 
@@ -2101,12 +2102,17 @@ class LDAPSearch(BaseLDAPCommand, crud.Search):
             entries[i] = entry_to_dict(e, **options)
             entries[i]['dn'] = e.dn
 
-        return dict(
+        result = dict(
             result=entries,
             count=len(entries),
             truncated=truncated,
         )
 
+        if truncated:
+            add_message(options['version'], result, SearchResultTruncated())
+
+        return result
+
     def pre_callback(self, ldap, filters, attrs_list, base_dn, scope, *args, **options):
         assert isinstance(base_dn, DN)
         return (filters, base_dn, scope)
-- 
2.5.0

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to