590d18
From c899fa3f5b404e9e28a149cc55684591482344f9 Mon Sep 17 00:00:00 2001
590d18
From: Martin Basti <mbasti@redhat.com>
590d18
Date: Thu, 23 Jul 2015 10:52:54 +0200
590d18
Subject: [PATCH] ULC: Fix stageused-add --from-delete command
590d18
590d18
Nonexistent method was used to move deleted user to staged area.
590d18
Minor fixes added:
590d18
 * handle not found error
590d18
 * return new DN
590d18
590d18
https://fedorahosted.org/freeipa/ticket/5145
590d18
590d18
Reviewed-By: David Kupka <dkupka@redhat.com>
590d18
---
590d18
 ipalib/plugins/stageuser.py | 9 +++++----
590d18
 1 file changed, 5 insertions(+), 4 deletions(-)
590d18
590d18
diff --git a/ipalib/plugins/stageuser.py b/ipalib/plugins/stageuser.py
590d18
index 49a762a922b21bd6d0824787d9305417f5e47ee6..41844712042c4456fc515afd316af60b612f164f 100644
590d18
--- a/ipalib/plugins/stageuser.py
590d18
+++ b/ipalib/plugins/stageuser.py
590d18
@@ -377,16 +377,17 @@ class stageuser_add(baseuser_add):
590d18
 
590d18
             staging_dn = self.obj.get_dn(*keys, **options)
590d18
             delete_dn = DN(staging_dn[0], self.obj.delete_container_dn, api.env.basedn)
590d18
-
590d18
+            new_dn = DN(staging_dn[0], self.obj.stage_container_dn, api.env.basedn)
590d18
             # Check that this value is a Active user
590d18
             try:
590d18
                 entry_attrs = self._exc_wrapper(keys, options, ldap.get_entry)(delete_dn, ['dn'])
590d18
             except errors.NotFound:
590d18
-                raise
590d18
-            self._exc_wrapper(keys, options, ldap.move_entry_newsuperior)(delete_dn, str(DN(self.obj.stage_container_dn, api.env.basedn)))
590d18
+                self.obj.handle_not_found(*keys)
590d18
 
590d18
+            self._exc_wrapper(keys, options, ldap.move_entry)(
590d18
+                delete_dn, new_dn)
590d18
             entry_attrs = entry_to_dict(entry_attrs, **options)
590d18
-            entry_attrs['dn'] = delete_dn
590d18
+            entry_attrs['dn'] = new_dn
590d18
 
590d18
             if self.obj.primary_key and keys[-1] is not None:
590d18
                 return dict(result=entry_attrs, value=keys[-1])
590d18
-- 
590d18
2.4.3
590d18