summaryrefslogtreecommitdiff
path: root/source4/librpc
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-12-30 21:46:32 +0100
committerAndrew Tridgell <tridge@samba.org>2009-12-31 17:33:30 +1100
commitea5af6e30ca91df3325581f67daab96d688d58fc (patch)
treed4a128c34a5239cfe552c86d37dd7b6552161e2a /source4/librpc
parent7effe2d2e30191c067ae1290224d388d96701b53 (diff)
downloadsamba-ea5af6e30ca91df3325581f67daab96d688d58fc.tar.gz
samba-ea5af6e30ca91df3325581f67daab96d688d58fc.tar.bz2
samba-ea5af6e30ca91df3325581f67daab96d688d58fc.zip
pyldb: Add dom_sid.split in favor of less powerful dom_sid_to_rid().
Signed-off-by: Andrew Tridgell <tridge@samba.org>
Diffstat (limited to 'source4/librpc')
-rw-r--r--source4/librpc/ndr/py_security.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/source4/librpc/ndr/py_security.c b/source4/librpc/ndr/py_security.c
index 02dc059f05..d04e2579f5 100644
--- a/source4/librpc/ndr/py_security.c
+++ b/source4/librpc/ndr/py_security.c
@@ -41,6 +41,33 @@ static void PyType_AddMethods(PyTypeObject *type, PyMethodDef *methods)
}
}
+static PyObject *py_dom_sid_split(PyObject *py_self, PyObject *args)
+{
+ struct dom_sid *self = py_talloc_get_ptr(py_self);
+ struct dom_sid *domain_sid;
+ TALLOC_CTX *mem_ctx;
+ uint32_t rid;
+ NTSTATUS status;
+ PyObject *py_domain_sid;
+
+ mem_ctx = talloc_new(NULL);
+ if (mem_ctx == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ status = dom_sid_split_rid(mem_ctx, self, &domain_sid, &rid);
+ if (!NT_STATUS_IS_OK(status)) {
+ PyErr_SetString(PyExc_RuntimeError, "dom_sid_split_rid failed");
+ talloc_free(mem_ctx);
+ return NULL;
+ }
+
+ py_domain_sid = py_talloc_steal(&dom_sid_Type, domain_sid);
+ talloc_free(mem_ctx);
+ return Py_BuildValue("(OI)", py_domain_sid, rid);
+}
+
static int py_dom_sid_cmp(PyObject *py_self, PyObject *py_other)
{
struct dom_sid *self = py_talloc_get_ptr(py_self), *other;
@@ -86,12 +113,21 @@ static int py_dom_sid_init(PyObject *self, PyObject *args, PyObject *kwargs)
return 0;
}
+static PyMethodDef py_dom_sid_extra_methods[] = {
+ { "split", (PyCFunction)py_dom_sid_split, METH_NOARGS,
+ "S.split() -> (domain_sid, rid)\n"
+ "Split a domain sid" },
+ { NULL }
+};
+
+
static void py_dom_sid_patch(PyTypeObject *type)
{
type->tp_init = py_dom_sid_init;
type->tp_str = py_dom_sid_str;
type->tp_repr = py_dom_sid_repr;
type->tp_compare = py_dom_sid_cmp;
+ PyType_AddMethods(type, py_dom_sid_extra_methods);
}
#define PY_DOM_SID_PATCH py_dom_sid_patch