From 8d680f879605b8e40fe2b4a16db5d860226e17a5 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sun, 14 Apr 2002 12:26:09 +0000 Subject: Added enumerate trusted domains. (This used to be commit 3a11ce31ca3eed23f3bf82c46b2ebd2423be737d) --- source3/python/py_lsa.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'source3/python/py_lsa.c') diff --git a/source3/python/py_lsa.c b/source3/python/py_lsa.c index 1c84af5ea0..fecbf535aa 100644 --- a/source3/python/py_lsa.c +++ b/source3/python/py_lsa.c @@ -210,7 +210,7 @@ static PyObject *lsa_lookup_sids(PyObject *self, PyObject *args, result = PyList_New(num_sids); for (i = 0; i < num_sids; i++) { - PyObject *name_obj, *obj; + PyObject *obj; obj = Py_BuildValue("{sssssi}", "username", names[i], "domain", domains[i], "name_type", @@ -222,18 +222,61 @@ static PyObject *lsa_lookup_sids(PyObject *self, PyObject *args, return result; } +static PyObject *lsa_enum_trust_dom(PyObject *self, PyObject *args) +{ + lsa_policy_hnd_object *hnd = (lsa_policy_hnd_object *)self; + NTSTATUS ntstatus; + uint32 enum_ctx = 0, num_domains, i; + char **domain_names; + DOM_SID *domain_sids; + PyObject *result; + + if (!PyArg_ParseTuple(args, "")) + return NULL; + + ntstatus = cli_lsa_enum_trust_dom(hnd->cli, hnd->mem_ctx, + &hnd->pol, &enum_ctx, + &num_domains, &domain_names, + &domain_sids); + + if (!NT_STATUS_IS_OK(ntstatus)) { + PyErr_SetObject(lsa_ntstatus, py_ntstatus_tuple(ntstatus)); + return NULL; + } + + result = PyList_New(num_domains); + + for (i = 0; i < num_domains; i++) { + fstring sid_str; + + sid_to_string(sid_str, &domain_sids[i]); + PyList_SetItem( + result, i, + Py_BuildValue("(ss)", domain_names[i], sid_str)); + } + + return result; +} + /* * Method dispatch tables */ static PyMethodDef lsa_hnd_methods[] = { + /* SIDs<->names */ + { "lookup_sids", lsa_lookup_sids, METH_VARARGS | METH_KEYWORDS, "Convert sids to names." }, { "lookup_names", lsa_lookup_names, METH_VARARGS | METH_KEYWORDS, "Convert names to sids." }, + /* Trusted domains */ + + { "enum_trusted_domains", lsa_enum_trust_dom, METH_VARARGS, + "Enumerate trusted domains." }, + { NULL } }; -- cgit