Ensure list of attrs to retrieve is unique, optimize getting indirect members

This fixes search where we were asking for the member attribute 10 or more times.


When retrieving indirect members make sure we always pass around the size and time limits so we don't have to look it up with every call to find_entries()

I saw this while doing a group_find and watching the LDAP access log.

ticket 557

rob
>From 89a27558ad6461eadf59346120d2fdabeb0e285f Mon Sep 17 00:00:00 2001
From: Rob Crittenden <rcrit...@redhat.com>
Date: Fri, 3 Dec 2010 17:23:38 -0500
Subject: [PATCH] Ensure list of attrs to retrieve is unique, optimize getting indirect members

This fixes search where we were asking for the member attribute 10 or more
times.

When retrieving indirect members make sure we always pass around the
size and time limits so we don't have to look it up with every call to
find_entries()

ticket 557
---
 ipaserver/plugins/ldap2.py |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/ipaserver/plugins/ldap2.py b/ipaserver/plugins/ldap2.py
index cbb8ddb..3960600 100644
--- a/ipaserver/plugins/ldap2.py
+++ b/ipaserver/plugins/ldap2.py
@@ -528,6 +528,9 @@ class ldap2(CrudBackend, Encoder):
         if not isinstance(time_limit, float):
             time_limit = float(time_limit)
 
+        if attrs_list:
+            attrs_list = list(set(attrs_list))
+
         # pass arguments to python-ldap
         try:
             id = self.conn.search_ext(
@@ -850,12 +853,14 @@ class ldap2(CrudBackend, Encoder):
         # accounts container.
         try:
             (results, truncated) = self.find_entries(searchfilter, attr_list,
-                api.env.container_accounts, time_limit=time_limit, size_limit = size_limit, normalize=normalize)
+                api.env.container_accounts, time_limit=time_limit,
+                size_limit=size_limit, normalize=normalize)
         except errors.NotFound:
             results = []
         try:
             (netresults, truncated) = self.find_entries(searchfilter, attr_list,
-                api.env.container_netgroup, time_limit=time_limit, size_limit = size_limit, normalize=normalize)
+                api.env.container_netgroup, time_limit=time_limit,
+                size_limit=size_limit, normalize=normalize)
         except errors.NotFound:
             netresults = []
         results = results + netresults
@@ -867,7 +872,8 @@ class ldap2(CrudBackend, Encoder):
 
             return entries
 
-        (dn, group) = self.get_entry(group_dn, ['dn', 'member'])
+        (dn, group) = self.get_entry(group_dn, ['dn', 'member'],
+            size_limit=size_limit, time_limit=time_limit)
         real_members = group.get('member')
         if isinstance(real_members, basestring):
             real_members = [real_members]
-- 
1.7.2.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to