403b09
From 95d17d4e632effc37eda54e77a71cbf2cf2f888c Mon Sep 17 00:00:00 2001
403b09
From: Martin Babinsky <mbabinsk@redhat.com>
403b09
Date: Thu, 1 Sep 2016 09:30:23 +0200
403b09
Subject: [PATCH] Always fetch forest info from root DCs when establishing
403b09
 two-way trust
403b09
403b09
Prior To Windows Server 2012R2, the `netr_DsRGetForestTrustInformation` calls
403b09
performed against non-root forest domain DCs were automatically routed to the
403b09
root domain DCs to resolve trust topology information.
403b09
403b09
This is no longer the case, so the `dcerpc.fetch_domains` function must
403b09
explicitly contact root domain DCs even in the case when an external two-way
403b09
trust to non-root domain is requested.
403b09
403b09
https://fedorahosted.org/freeipa/ticket/6057
403b09
403b09
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
403b09
---
403b09
 ipaserver/plugins/trust.py | 29 +++++++++++++++++++++--------
403b09
 1 file changed, 21 insertions(+), 8 deletions(-)
403b09
403b09
diff --git a/ipaserver/plugins/trust.py b/ipaserver/plugins/trust.py
403b09
index 8ed96c253e7c7862f60ad668aa6c252038274624..b3cb56c14496c0d56d3f3fedddee8d123f929344 100644
403b09
--- a/ipaserver/plugins/trust.py
403b09
+++ b/ipaserver/plugins/trust.py
403b09
@@ -770,7 +770,7 @@ sides.
403b09
                 # Bidirectional trust allows us to use cross-realm TGT, so we can
403b09
                 # run the call under original user's credentials
403b09
                 res = fetch_domains_from_trust(self.api, self.trustinstance,
403b09
-                                               result['result'], **options)
403b09
+                                               **options)
403b09
                 domains = add_new_domains_from_trust(self.api, self.trustinstance,
403b09
                                                      result['result'], res, **options)
403b09
             else:
403b09
@@ -1631,8 +1631,21 @@ class trustdomain_del(LDAPDelete):
403b09
         return result
403b09
 
403b09
 
403b09
-def fetch_domains_from_trust(myapi, trustinstance, trust_entry, **options):
403b09
-    trust_name = trust_entry['cn'][0]
403b09
+def fetch_domains_from_trust(myapi, trustinstance, **options):
403b09
+    """
403b09
+    Contact trust forest root DC and fetch trusted forest topology information.
403b09
+
403b09
+    :param myapi: API instance
403b09
+    :param trustinstance: Initialized instance of `dcerpc.TrustDomainJoins`
403b09
+        class
403b09
+    :param options: options passed from API command's `execute()` method
403b09
+
403b09
+    :returns: dict containing forest domain information and forest-wide UPN
403b09
+        suffixes (if any)
403b09
+    """
403b09
+
403b09
+    forest_root_name = trustinstance.remote_domain.info['dns_forest']
403b09
+
403b09
     # We want to use Kerberos if we have admin credentials even with SMB calls
403b09
     # as eventually use of NTLMSSP will be deprecated for trusted domain operations
403b09
     # If admin credentials are missing, 'creds' will be None and fetch_domains
403b09
@@ -1640,10 +1653,10 @@ def fetch_domains_from_trust(myapi, trustinstance, trust_entry, **options):
403b09
     # as well.
403b09
     creds = generate_creds(trustinstance, style=CRED_STYLE_KERBEROS, **options)
403b09
     server = options.get('realm_server', None)
403b09
-    domains = ipaserver.dcerpc.fetch_domains(myapi,
403b09
-                                             trustinstance.local_flatname,
403b09
-                                             trust_name, creds=creds,
403b09
-                                             server=server)
403b09
+    domains = ipaserver.dcerpc.fetch_domains(
403b09
+        myapi, trustinstance.local_flatname, forest_root_name, creds=creds,
403b09
+        server=server)
403b09
+
403b09
     return domains
403b09
 
403b09
 
403b09
@@ -1749,7 +1762,7 @@ class trust_fetch_domains(LDAPRetrieve):
403b09
                     'on the IPA server first'
403b09
                 )
403b09
             )
403b09
-        res = fetch_domains_from_trust(self.api, trustinstance, trust, **options)
403b09
+        res = fetch_domains_from_trust(self.api, trustinstance, **options)
403b09
         domains = add_new_domains_from_trust(self.api, trustinstance, trust, res, **options)
403b09
 
403b09
         if len(domains) > 0:
403b09
-- 
403b09
2.7.4
403b09