fef02c
From 99c93ce55d740fd8c6901dc3cfa3ecbf71edbff8 Mon Sep 17 00:00:00 2001
fef02c
From: Alexander Bokovoy <abokovoy@redhat.com>
fef02c
Date: Mon, 31 Oct 2016 18:17:35 +0200
fef02c
Subject: [PATCH] trustdomain-del: fix the way how subdomain is searched
fef02c
fef02c
With FreeIPA 4.4 we moved child domains behind the 'trustdomain' topic.
fef02c
Update 'ipa trustdomain-del' command to properly calculate DN to the
fef02c
actual child domain and handle the case when it is missing correctly.
fef02c
fef02c
Fixes https://fedorahosted.org/freeipa/ticket/6445
fef02c
fef02c
Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
fef02c
---
fef02c
 ipaserver/plugins/trust.py | 15 +++++++++------
fef02c
 1 file changed, 9 insertions(+), 6 deletions(-)
fef02c
fef02c
diff --git a/ipaserver/plugins/trust.py b/ipaserver/plugins/trust.py
fef02c
index 720a45a4d12d59f00e3e63f2b4f62edd45646065..723dba6a26311752ecde8589d22e2911b72e8044 100644
fef02c
--- a/ipaserver/plugins/trust.py
fef02c
+++ b/ipaserver/plugins/trust.py
fef02c
@@ -1614,13 +1614,16 @@ class trustdomain_del(LDAPDelete):
fef02c
         # to always receive empty keys. We need to catch the case when root domain is being deleted
fef02c
 
fef02c
         for domain in keys[1]:
fef02c
-            # Fetch the trust to verify that the entered domain is trusted
fef02c
-            self.api.Command.trust_show(domain)
fef02c
+            try:
fef02c
+                self.obj.get_dn_if_exists(keys[0], domain, trust_type=u'ad')
fef02c
+            except errors.NotFound:
fef02c
+                if keys[0].lower() == domain:
fef02c
+                    raise errors.ValidationError(
fef02c
+                        name='domain',
fef02c
+                        error=_("cannot delete root domain of the trust, "
fef02c
+                                "use trust-del to delete the trust itself"))
fef02c
+                self.obj.handle_not_found(keys[0], domain)
fef02c
 
fef02c
-            if keys[0].lower() == domain:
fef02c
-                raise errors.ValidationError(name='domain',
fef02c
-                    error=_("cannot delete root domain of the trust, "
fef02c
-                            "use trust-del to delete the trust itself"))
fef02c
             try:
fef02c
                 res = self.api.Command.trustdomain_enable(keys[0], domain)
fef02c
             except errors.AlreadyActive:
fef02c
-- 
fef02c
2.7.4
fef02c