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

PR body:
"""
    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
"""

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 b297ae1338229bcceaa019ea5621adba9bcde44e 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 | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/ipaserver/plugins/user.py b/ipaserver/plugins/user.py
index 948a19898e..658d0ecae0 100644
--- a/ipaserver/plugins/user.py
+++ b/ipaserver/plugins/user.py
@@ -603,11 +603,14 @@ def post_callback(self, ldap, dn, entry_attrs, *keys, **options):
             if not options.get('all', False):
                 desc_attr = ldap.get_entry(dn, ['description'])
                 entry_attrs.update(desc_attr)
+                entry_attrs._orig['description'] = list(
+                    desc_attr['description'])  # The entry_attrs.update()
+                # does not change the entry_attrs._orig
             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)
+                    self._exc_wrapper(
+                        keys[-1], options, ldap.update_entry)(entry_attrs)
                 except (errors.EmptyModlist, errors.NotFound):
                     pass
 
_______________________________________________
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