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

Requires patch freeipa-jcholast-471.1.
--
David Kupka
From 3fbef326a6235297b95703edd2e77f8e7ab4e446 Mon Sep 17 00:00:00 2001
From: David Kupka <dku...@redhat.com>
Date: Thu, 13 Aug 2015 08:11:38 +0200
Subject: [PATCH] user-undel: Fix error messages.

https://fedorahosted.org/freeipa/ticket/5207
---
 ipalib/plugins/user.py | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/ipalib/plugins/user.py b/ipalib/plugins/user.py
index 4ea770ede7525149780f1486b5e4eb44699c8533..1d1e4f1749c590d02e52babc1addfbc6039a061e 100644
--- a/ipalib/plugins/user.py
+++ b/ipalib/plugins/user.py
@@ -686,7 +686,7 @@ class user_del(baseuser_del):
             if restoreAttr:
                 self._exc_wrapper(keys, options, ldap.update_entry)(entry_attrs)
 
-            val = dict(result=dict(failed=[]), value=[keys[-1][0]])
+            val = dict(result=dict(failed=[]), value=[keys[-1]])
             return val
         else:
             return super(user_del, self).execute(*keys, **options)
@@ -819,16 +819,14 @@ class user_undel(LDAPQuery):
 
         # First check that the user exists and is a delete one
         delete_dn = self.obj.get_either_dn(*keys, **options)
-        if delete_dn.endswith(DN(self.obj.active_container_dn, api.env.basedn)):
-            raise errors.ValidationError(
-                        name=self.obj.primary_key.cli_name,
-                        error=_('User %r is already active') % keys[-1][0])
         try:
             entry_attrs = self._exc_wrapper(keys, options, ldap.get_entry)(delete_dn)
         except errors.NotFound:
-            raise errors.ValidationError(
-                        name=self.obj.primary_key.cli_name,
-                        error=_('User %r not found') % keys[-1][0])
+            self.obj.handle_not_found(*keys)
+        if delete_dn.endswith(DN(self.obj.active_container_dn,
+                                 api.env.basedn)):
+            raise errors.InvocationError(
+                message=_('user "%s" is already active') % keys[-1])
 
         active_dn = DN(delete_dn[0], self.obj.active_container_dn, api.env.basedn)
 
-- 
2.4.3

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to