diff options
author | Matthias Dieter Wallnöfer <mdw@samba.org> | 2011-11-22 22:26:06 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2011-11-26 10:34:58 +0100 |
commit | 179bf9b51c9de5f9f8e78893bd20b9821e39e7e4 (patch) | |
tree | 59721053b3f28f14f9fcbe8ac6b8a293cd034652 /source4/libnet/py_net.c | |
parent | dec1435a42e16269d1e343707e924256ee8a5050 (diff) | |
download | samba-179bf9b51c9de5f9f8e78893bd20b9821e39e7e4.tar.gz |
s4:libnet/py_net.c: "py_net_finddc" - add an "address" parameter
This is useful for a new "samba-tool domain info" command.
Patch inspired by Matthieu Patou.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source4/libnet/py_net.c')
-rw-r--r-- | source4/libnet/py_net.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/source4/libnet/py_net.c b/source4/libnet/py_net.c index a8db2976a66..7c90572e126 100644 --- a/source4/libnet/py_net.c +++ b/source4/libnet/py_net.c @@ -580,23 +580,31 @@ static PyObject *py_net_replicate_chunk(py_net_Object *self, PyObject *args, PyO /* find a DC given a domain name and server type */ -static PyObject *py_net_finddc(py_net_Object *self, PyObject *args) +static PyObject *py_net_finddc(py_net_Object *self, PyObject *args, PyObject *kwargs) { - const char *domain_name; + const char *domain = NULL, *address = NULL; unsigned server_type; NTSTATUS status; struct finddcs *io; TALLOC_CTX *mem_ctx; PyObject *ret; + const char * const kwnames[] = { "flags", "domain", "address", NULL }; - if (!PyArg_ParseTuple(args, "sI", &domain_name, &server_type)) { + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "I|ss", + discard_const_p(char *, kwnames), + &server_type, &domain, &address)) { return NULL; } mem_ctx = talloc_new(self->mem_ctx); io = talloc_zero(mem_ctx, struct finddcs); - io->in.domain_name = domain_name; + if (domain != NULL) { + io->in.domain_name = domain; + } + if (address != NULL) { + io->in.server_address = address; + } io->in.minimum_dc_flags = server_type; status = finddcs_cldap(io, io, @@ -624,8 +632,8 @@ static const char py_net_replicate_init_doc[] = "replicate_init(samdb, lp, drspi static const char py_net_replicate_chunk_doc[] = "replicate_chunk(state, level, ctr, schema)\n" "Process replication for one chunk"; -static const char py_net_finddc_doc[] = "finddc(domain, server_type)\n" - "find a DC with the specified server_type bits. Return the DNS name"; +static const char py_net_finddc_doc[] = "finddc(flags=server_type, domain=None, address=None)\n" + "Find a DC with the specified 'server_type' bits. The 'domain' and/or 'address' have to be used as additional search criteria. Returns the whole netlogon struct"; static PyMethodDef net_obj_methods[] = { {"join_member", (PyCFunction)py_net_join_member, METH_VARARGS|METH_KEYWORDS, py_net_join_member_doc}, @@ -638,7 +646,7 @@ static PyMethodDef net_obj_methods[] = { {"vampire", (PyCFunction)py_net_vampire, METH_VARARGS|METH_KEYWORDS, py_net_vampire_doc}, {"replicate_init", (PyCFunction)py_net_replicate_init, METH_VARARGS|METH_KEYWORDS, py_net_replicate_init_doc}, {"replicate_chunk", (PyCFunction)py_net_replicate_chunk, METH_VARARGS|METH_KEYWORDS, py_net_replicate_chunk_doc}, - {"finddc", (PyCFunction)py_net_finddc, METH_VARARGS, py_net_finddc_doc}, + {"finddc", (PyCFunction)py_net_finddc, METH_KEYWORDS, py_net_finddc_doc}, { NULL } }; |