diff options
author | Andrew Bartlett <abartlet@samba.org> | 2015-09-22 15:32:57 +1200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2015-10-26 05:11:21 +0100 |
commit | 2191fcaedc5efb703730839f09606fd0fd27da94 (patch) | |
tree | f3a22865b3c630772f370114ac80d650530c57bf /source4/dns_server/pydns.c | |
parent | b48776d78b446ad4abd4a6bc2ba6b488a29b11d2 (diff) | |
download | samba-2191fcaedc5efb703730839f09606fd0fd27da94.tar.gz |
dns_server: Add python method to extract a DNS entry from a ldb.MessageElement
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Diffstat (limited to 'source4/dns_server/pydns.c')
-rw-r--r-- | source4/dns_server/pydns.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/source4/dns_server/pydns.c b/source4/dns_server/pydns.c index 1fad6922ed0..2f631bdcd1c 100644 --- a/source4/dns_server/pydns.c +++ b/source4/dns_server/pydns.c @@ -141,6 +141,40 @@ static PyObject *py_dsdb_dns_lookup(PyObject *self, PyObject *args) return py_dnsp_DnssrvRpcRecord_get_list(records, num_records); } +static PyObject *py_dsdb_dns_extract(PyObject *self, PyObject *args) +{ + PyObject *py_dns_el; + TALLOC_CTX *frame; + WERROR werr; + struct ldb_message_element *dns_el; + struct dnsp_DnssrvRpcRecord *records; + uint16_t num_records; + + if (!PyArg_ParseTuple(args, "O", &py_dns_el)) { + return NULL; + } + + if (!py_check_dcerpc_type(py_dns_el, "ldb", "MessageElement")) { + PyErr_SetString(py_ldb_get_exception(), + "ldb MessageElement object required"); + return NULL; + } + dns_el = pyldb_MessageElement_AsMessageElement(py_dns_el); + + frame = talloc_stackframe(); + + werr = dns_common_extract(dns_el, + frame, + &records, + &num_records); + if (!W_ERROR_IS_OK(werr)) { + PyErr_SetWERROR(werr); + return NULL; + } + + return py_dnsp_DnssrvRpcRecord_get_list(records, num_records); +} + static PyObject *py_dsdb_dns_replace(PyObject *self, PyObject *args) { struct ldb_context *samdb; @@ -209,6 +243,8 @@ static PyMethodDef py_dsdb_dns_methods[] = { METH_VARARGS, "Get the DNS database entries for a DNS name"}, { "replace", (PyCFunction)py_dsdb_dns_replace, METH_VARARGS, "Replace the DNS database entries for a DNS name"}, + { "extract", (PyCFunction)py_dsdb_dns_extract, + METH_VARARGS, "Return the DNS database entry as a python structure from an Ldb.MessageElement of type dnsRecord"}, { NULL } }; |