URL: https://github.com/freeipa/freeipa/pull/810
Author: Tiboris
 Title: #810: user.py: replace user_mod with ldap.update_entry()
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/810/head:pr810
git checkout pr810
From e926b65ce6834a8819309fa2fc592212d9d82afa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tibor=20Dudl=C3=A1k?= <tibor.dud...@gmail.com>
Date: Wed, 24 May 2017 10:56:15 +0200
Subject: [PATCH] user.py: replace user_mod with ldap.update_entry()

Refactoring user_add class to use 'ldap.update_entry()' call
instead of api call 'user_mod' when --noprivate option is used.

https://pagure.io/freeipa/issue/5788
---
 ipaserver/plugins/user.py | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/ipaserver/plugins/user.py b/ipaserver/plugins/user.py
index 948a19898e..b714bd2eb9 100644
--- a/ipaserver/plugins/user.py
+++ b/ipaserver/plugins/user.py
@@ -598,22 +598,16 @@ def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
         except errors.AlreadyGroupMember:
             pass
 
-        # delete description attribute NO_UPG_MAGIC if present
-        if options.get('noprivate', False):
-            if not options.get('all', False):
-                desc_attr = ldap.get_entry(dn, ['description'])
-                entry_attrs.update(desc_attr)
-            if 'description' in entry_attrs and NO_UPG_MAGIC in entry_attrs['description']:
-                entry_attrs['description'].remove(NO_UPG_MAGIC)
-                kw = {'setattr': unicode('description=%s' % ','.join(entry_attrs['description']))}
-                try:
-                    self.api.Command['user_mod'](keys[-1], **kw)
-                except (errors.EmptyModlist, errors.NotFound):
-                    pass
-
         # Fetch the entry again to update memberof, mep data, etc updated
         # at the end of the transaction.
         newentry = ldap.get_entry(dn, ['*'])
+
+        # delete description attribute NO_UPG_MAGIC if present
+        if options.get('noprivate', False) and 'description' in newentry and \
+                NO_UPG_MAGIC in newentry['description']:
+            newentry['description'].remove(NO_UPG_MAGIC)
+            ldap.update_entry(newentry)
+
         entry_attrs.update(newentry)
 
         if options.get('random', False):
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to