]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
netcmd: Refactor seizing DNS roles while restoring from a backup
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Thu, 27 May 2021 03:38:03 +0000 (15:38 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 11 Jun 2021 07:41:38 +0000 (07:41 +0000)
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
python/samba/netcmd/domain_backup.py

index b5874b305b2ab36b8d927c12e1312b8ecd1ad0ac..1246062b7c4d713dbfaf42d0a7b9dae7fd74b2a5 100644 (file)
@@ -660,18 +660,11 @@ class cmd_domain_backup_restore(cmd_fsmo_seize):
         # Seize DNS roles
         domain_dn = samdb.domain_dn()
         forest_dn = samba.dn_from_dns_name(samdb.forest_dns_name())
-        domaindns_dn = ("CN=Infrastructure,DC=DomainDnsZones,", domain_dn)
-        forestdns_dn = ("CN=Infrastructure,DC=ForestDnsZones,", forest_dn)
-        for dn_prefix, dns_dn in [forestdns_dn, domaindns_dn]:
-            if dns_dn not in ncs:
-                continue
-            full_dn = dn_prefix + dns_dn
-            m = ldb.Message()
-            m.dn = ldb.Dn(samdb, full_dn)
-            m["fSMORoleOwner"] = ldb.MessageElement(samdb.get_dsServiceName(),
-                                                    ldb.FLAG_MOD_REPLACE,
-                                                    "fSMORoleOwner")
-            samdb.modify(m)
+        dns_roles = [("domaindns", domain_dn),
+                     ("forestdns", forest_dn)]
+        for role, dn in dns_roles:
+            if dn in ncs:
+                self.seize_dns_role(role, samdb, None, None, None, force=True)
 
         # Seize other roles
         for role in ['rid', 'pdc', 'naming', 'infrastructure', 'schema']: