Blob Blame History Raw
From c899fa3f5b404e9e28a149cc55684591482344f9 Mon Sep 17 00:00:00 2001
From: Martin Basti <mbasti@redhat.com>
Date: Thu, 23 Jul 2015 10:52:54 +0200
Subject: [PATCH] ULC: Fix stageused-add --from-delete command

Nonexistent method was used to move deleted user to staged area.
Minor fixes added:
 * handle not found error
 * return new DN

https://fedorahosted.org/freeipa/ticket/5145

Reviewed-By: David Kupka <dkupka@redhat.com>
---
 ipalib/plugins/stageuser.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/ipalib/plugins/stageuser.py b/ipalib/plugins/stageuser.py
index 49a762a922b21bd6d0824787d9305417f5e47ee6..41844712042c4456fc515afd316af60b612f164f 100644
--- a/ipalib/plugins/stageuser.py
+++ b/ipalib/plugins/stageuser.py
@@ -377,16 +377,17 @@ class stageuser_add(baseuser_add):
 
             staging_dn = self.obj.get_dn(*keys, **options)
             delete_dn = DN(staging_dn[0], self.obj.delete_container_dn, api.env.basedn)
-
+            new_dn = DN(staging_dn[0], self.obj.stage_container_dn, api.env.basedn)
             # Check that this value is a Active user
             try:
                 entry_attrs = self._exc_wrapper(keys, options, ldap.get_entry)(delete_dn, ['dn'])
             except errors.NotFound:
-                raise
-            self._exc_wrapper(keys, options, ldap.move_entry_newsuperior)(delete_dn, str(DN(self.obj.stage_container_dn, api.env.basedn)))
+                self.obj.handle_not_found(*keys)
 
+            self._exc_wrapper(keys, options, ldap.move_entry)(
+                delete_dn, new_dn)
             entry_attrs = entry_to_dict(entry_attrs, **options)
-            entry_attrs['dn'] = delete_dn
+            entry_attrs['dn'] = new_dn
 
             if self.obj.primary_key and keys[-1] is not None:
                 return dict(result=entry_attrs, value=keys[-1])
-- 
2.4.3