session_info=system_session(),
credentials=creds, lp=lp)
- remove_dc.remove_dns_references(samdb, logger, dnshostname)
+ remove_dc.remove_dns_references(samdb, logger, dnshostname,
+ ignore_no_name=True)
class cmd_dns(SuperCommand):
raise
-def remove_dns_references(samdb, logger, dnsHostName):
+def remove_dns_references(samdb, logger, dnsHostName, ignore_no_name=False):
# Check we are using in-database DNS
zones = samdb.search(base="", scope=ldb.SCOPE_SUBTREE,
(dn, primary_recs) = samdb.dns_lookup(dnsHostName)
except RuntimeError as (enum, estr):
if enum == werror.WERR_DNS_ERROR_NAME_DOES_NOT_EXIST:
- return
+ if ignore_no_name:
+ remove_hanging_dns_references(samdb, logger,
+ dnsHostNameUpper,
+ zones)
+ return
raise DemoteException("lookup of %s failed: %s" % (dnsHostName, estr))
samdb.dns_replace(dnsHostName, [])
(a_name, len(a_recs), orig_num_recs - len(a_recs)))
samdb.dns_replace(a_name, a_recs)
+ remove_hanging_dns_references(samdb, logger, dnsHostNameUpper, zones)
+
+
+def remove_hanging_dns_references(samdb, logger, dnsHostNameUpper, zones):
+
# Find all the CNAME, NS, PTR and SRV records that point at the
# name we are removing
# has been done in the list comprehension above
samdb.dns_replace_by_dn(record.dn, values)
+
def offline_remove_server(samdb, logger,
server_dn,
remove_computer_obj=False,