mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Optimize member/memberof searches in LDAP
When investigating if member/memberof attribute is direct/indirect we do a lot of LDAP SCOPE_SUBTREE searches when we actually search just for one item. Make sure we search only with SCOPE_BASE to improve the performance. One not so efficient iteration was also changed to list comprehension to speed things up a tiny bit. https://fedorahosted.org/freeipa/ticket/1885
This commit is contained in:
parent
7227ffe864
commit
5aa6e994d1
@ -1001,7 +1001,8 @@ class ldap2(CrudBackend, Encoder):
|
|||||||
try:
|
try:
|
||||||
(result, truncated) = self.find_entries(searchfilter,
|
(result, truncated) = self.find_entries(searchfilter,
|
||||||
attr_list, member, time_limit=time_limit,
|
attr_list, member, time_limit=time_limit,
|
||||||
size_limit=size_limit, normalize=normalize)
|
size_limit=size_limit, scope=_ldap.SCOPE_BASE,
|
||||||
|
normalize=normalize)
|
||||||
results.append(list(result[0]))
|
results.append(list(result[0]))
|
||||||
for m in result[0][1].get('member', []):
|
for m in result[0][1].get('member', []):
|
||||||
# This member may contain other members, add it to our
|
# This member may contain other members, add it to our
|
||||||
@ -1066,18 +1067,16 @@ class ldap2(CrudBackend, Encoder):
|
|||||||
try:
|
try:
|
||||||
(result, truncated) = self.find_entries(searchfilter, attr_list,
|
(result, truncated) = self.find_entries(searchfilter, attr_list,
|
||||||
group, time_limit=time_limit,size_limit=size_limit,
|
group, time_limit=time_limit,size_limit=size_limit,
|
||||||
normalize=normalize)
|
scope=_ldap.SCOPE_BASE, normalize=normalize)
|
||||||
results.extend(list(result))
|
results.extend(list(result))
|
||||||
except errors.NotFound:
|
except errors.NotFound:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
direct = []
|
direct = []
|
||||||
indirect = []
|
|
||||||
# If there is an exception here, it is likely due to a failure in
|
# If there is an exception here, it is likely due to a failure in
|
||||||
# referential integrity. All members should have corresponding
|
# referential integrity. All members should have corresponding
|
||||||
# memberOf entries.
|
# memberOf entries.
|
||||||
for m in memberof:
|
indirect = [ m.lower() for m in memberof ]
|
||||||
indirect.append(m.lower())
|
|
||||||
for r in results:
|
for r in results:
|
||||||
direct.append(r[0])
|
direct.append(r[0])
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user