idviews: use cached ipaOriginalUid value when resolving ID override anchor

For ID overrides 'ipaOriginalUid' value should be the human-readable
version of the ID override anchor. Since we would have it already set in
the ID override entry, prefer using it instead of looking up the
override anchor.

This should speed up significantly operations which list all ID
overrides in the view, like Web UI views.

Fixes: https://pagure.io/freeipa/issue/9178
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
Alexander Bokovoy committed 2022-06-14 15:58:55 +03:00
1 parent 05d96e16dc
commit e06f0cc9b4
1 file changed
+6 -2
+6 -2
View File
@@ -809,8 +809,12 @@ class baseidoverride(LDAPObject):
def convert_anchor_to_human_readable_form(self, entry_attrs, **options):
if not options.get('raw'):
anchor = entry_attrs.single_value['ipaanchoruuid']
if 'ipaoriginaluid' in entry_attrs:
originaluid = entry_attrs.single_value['ipaoriginaluid']
entry_attrs.single_value['ipaanchoruuid'] = originaluid
return
anchor = entry_attrs.single_value['ipaanchoruuid']
if anchor:
try:
object_name = resolve_anchor_to_object_name(
@@ -1067,7 +1071,7 @@ class idoverrideuser(baseidoverride):
original_uid = resolve_anchor_to_object_name(self.backend,
self.override_object,
anchor)
entry_attrs['ipaOriginalUid'] = original_uid
entry_attrs['ipaoriginaluid'] = original_uid
except (errors.NotFound, errors.ValidationError):
# Anchor could not be resolved, this means we had to specify the