join.py: Don't add replica locations without the backend
authorGarming Sam <garming@catalyst.net.nz>
Thu, 21 Jul 2016 04:01:20 +0000 (16:01 +1200)
committerGarming Sam <garming@samba.org>
Thu, 21 Jul 2016 04:37:08 +0000 (06:37 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=9200

Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/join.py

index d84da6312f894e94a24449d7e96ce4ad3577ffec..d1a1b085883af4baceda72bc64f078b4eb827ea8 100644 (file)
@@ -603,18 +603,21 @@ class dc_join(object):
             # Add the Replica-Locations or RO-Replica-Locations attributes
             # TODO Is this supposed to be for the schema partition too?
             expr = "(&(objectClass=crossRef)(ncName=%s))" % ldb.binary_encode(ctx.domaindns_zone)
-            domain = ctx.samdb.search(scope=ldb.SCOPE_ONELEVEL,
+            domain = (ctx.samdb.search(scope=ldb.SCOPE_ONELEVEL,
                                       attrs=[],
                                       base=ctx.samdb.get_partitions_dn(),
-                                      expression=expr)
+                                      expression=expr), ctx.domaindns_zone)
 
             expr = "(&(objectClass=crossRef)(ncName=%s))" % ldb.binary_encode(ctx.forestdns_zone)
-            forest = ctx.samdb.search(scope=ldb.SCOPE_ONELEVEL,
+            forest = (ctx.samdb.search(scope=ldb.SCOPE_ONELEVEL,
                                       attrs=[],
                                       base=ctx.samdb.get_partitions_dn(),
-                                      expression=expr)
+                                      expression=expr), ctx.forestdns_zone)
+
+            for part, zone in (domain, forest):
+                if zone not in ctx.nc_list:
+                    continue
 
-            for part in (domain, forest):
                 if len(part) == 1:
                     m = ldb.Message()
                     m.dn = part[0].dn
@@ -896,8 +899,6 @@ class dc_join(object):
             # At this point we should already have an entry in the ForestDNS
             # and DomainDNS NC (those under CN=Partions,DC=...) in order to
             # indicate that we hold a replica for this NC.
-            #
-            # FIXME make this optional based on --dns-backend=
             for nc in (ctx.domaindns_zone, ctx.forestdns_zone):
                 if nc in ctx.nc_list:
                     print "Replicating %s" % (str(nc))