On 26.01.2016 15:17, Petr Spacek wrote:
On 26.1.2016 15:06, Martin Basti wrote:

On 26.01.2016 15:00, Gabe Alford wrote:
On Tue, Jan 26, 2016 at 6:56 AM, Martin Basti <mba...@redhat.com
<mailto:mba...@redhat.com>> wrote:



     On 26.01.2016 14:55, Petr Spacek wrote:

         On 26.1.2016 14:02, Martin Basti wrote:

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

             Patch attached.

         It works for me in API, CLI, and Web UI. The warning is shown
         as expected.

         Interestingly, Web UI behaves strangely when search limit is
         hit. This needs
         more investigation because it happens even without this patch :-)

     I found different bug there, webUI passes sizelimit: 0
     (unlimited), but this values is not passed to some searches inside
     BaseldapSearch which raise error, I will file a ticket na provide
     details there


Works for me as well. However, it would be nice to have what ipasearchlimit
is limited to in the error message as well. So something like:
thanks for testing.

"Search result has been truncated, the current search limit is set to 10.
Please increase the search limit."
Well this is not so easy to achieve in framework, I prefer not to add number
there, it requires bigger change in framework or an extra ldap search.
Does this also address https://fedorahosted.org/freeipa/ticket/4022?
It should.
Maybe we can use some generic phrase like:
"Search result has been truncated to configured search limit."
and avoid advice like 'increase search limit' which may not be possible to do,
e.g. because user does not have permission to do that etc.

Updated patch attached.
From 56f80feb7a4b4fb33f0c04e9dd718cdcb212199f 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..e43584b108eda0055419f605c4c0c1893ec9a6d0 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 to configured 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