pydns: Also return the DN of the LDB object when finding a DNS record
authorAndrew Bartlett <abartlet@samba.org>
Mon, 27 Feb 2017 04:09:56 +0000 (17:09 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 10 Jun 2017 19:48:20 +0000 (21:48 +0200)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
python/samba/remove_dc.py
source4/dns_server/pydns.c

index 61b5937ba7a9e46af83570bf62355782e3080839..4c8ee89246431739bf485bb18d991e7d18a61067 100644 (file)
@@ -97,7 +97,7 @@ def remove_dns_references(samdb, logger, dnsHostName):
     dnsHostNameUpper = dnsHostName.upper()
 
     try:
-        primary_recs = samdb.dns_lookup(dnsHostName)
+        (dn, primary_recs) = samdb.dns_lookup(dnsHostName)
     except RuntimeError as (enum, estr):
         if enum == werror.WERR_DNS_ERROR_NAME_DOES_NOT_EXIST:
               return
@@ -140,7 +140,7 @@ def remove_dns_references(samdb, logger, dnsHostName):
     for a_name in a_names_to_remove_from:
         try:
             logger.debug("checking for DNS records to remove on %s" % a_name)
-            a_recs = samdb.dns_lookup(a_name)
+            (a_rec_dn, a_recs) = samdb.dns_lookup(a_name)
         except RuntimeError as (enum, estr):
             if enum == werror.WERR_DNS_ERROR_NAME_DOES_NOT_EXIST:
                 return
index 18c3c2953d908913e13ff994136ca99c8f2f5c4c..3de9739f1f11a0e50d64817ee341cf37f298b7e3 100644 (file)
@@ -105,7 +105,7 @@ static int py_dnsp_DnssrvRpcRecord_get_array(PyObject *value,
 static PyObject *py_dsdb_dns_lookup(PyObject *self, PyObject *args)
 {
        struct ldb_context *samdb;
-       PyObject *py_ldb;
+       PyObject *py_ldb, *ret, *pydn;
        char *dns_name;
        TALLOC_CTX *frame;
        NTSTATUS status;
@@ -149,8 +149,9 @@ static PyObject *py_dsdb_dns_lookup(PyObject *self, PyObject *args)
        }
 
        ret = py_dnsp_DnssrvRpcRecord_get_list(records, num_records);
+       pydn = pyldb_Dn_FromDn(dn);
        talloc_free(frame);
-       return ret;
+       return Py_BuildValue("(OO)", pydn, ret);
 }
 
 static PyObject *py_dsdb_dns_extract(PyObject *self, PyObject *args)