Blob Blame History Raw
From fef36da6e8d5f6f057a80c7b9bca0eae2ed2c367 Mon Sep 17 00:00:00 2001
From: Alexander Bokovoy <abokovoy@redhat.com>
Date: Thu, 9 Jun 2022 18:29:59 +0300
Subject: [PATCH] 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>
---
 ipaserver/plugins/idviews.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/ipaserver/plugins/idviews.py b/ipaserver/plugins/idviews.py
index 018c1f6056f514c5c99e6b47c7d78c2c7165bf55..7dc298a14ec7d7cce85f631e00675fea93800493 100644
--- a/ipaserver/plugins/idviews.py
+++ b/ipaserver/plugins/idviews.py
@@ -746,8 +746,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(
@@ -991,7 +995,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
-- 
2.37.3