summaryrefslogtreecommitdiff
path: root/source4/dsdb/pydsdb.c
diff options
context:
space:
mode:
authorMatthieu Patou <mat@matws.net>2010-04-13 00:51:00 +0400
committerJelmer Vernooij <jelmer@samba.org>2010-04-15 18:45:41 +0200
commitd784ecec555a3d9737e6f4b3894f27904d2b833c (patch)
treeeda874de5e061c58bc04b56bd8dde8a6601d99cd /source4/dsdb/pydsdb.c
parent9c2aed862d2ecbc4047cd0326250096767731c05 (diff)
downloadsamba-d784ecec555a3d9737e6f4b3894f27904d2b833c.tar.gz
samba-d784ecec555a3d9737e6f4b3894f27904d2b833c.tar.bz2
samba-d784ecec555a3d9737e6f4b3894f27904d2b833c.zip
s4 python: Add a function to get the oid of an attribute when the attid is known
This function is mainly to help decoding replPropertyMetaData in python Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Diffstat (limited to 'source4/dsdb/pydsdb.c')
-rw-r--r--source4/dsdb/pydsdb.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c
index 1d71c6b7de..39f20672ce 100644
--- a/source4/dsdb/pydsdb.c
+++ b/source4/dsdb/pydsdb.c
@@ -19,6 +19,7 @@
#include <Python.h>
#include "includes.h"
+#include "libcli/util/pyerrors.h"
#include "dsdb/samdb/samdb.h"
#include "lib/ldb/pyldb.h"
#include "libcli/security/security.h"
@@ -183,6 +184,40 @@ static PyObject *py_samdb_ntds_invocation_id(PyObject *self, PyObject *args)
return result;
}
+static PyObject *py_dsdb_get_oid_from_attid(PyObject *self, PyObject *args)
+{
+ PyObject *py_ldb;
+ struct ldb_context *ldb;
+ uint32_t attid;
+ struct dsdb_schema *schema;
+ const char *oid;
+ TALLOC_CTX *mem_ctx;
+ WERROR status;
+
+ mem_ctx = talloc_new(NULL);
+ if (mem_ctx == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ if (!PyArg_ParseTuple(args, "Oi", &py_ldb, &attid))
+ return NULL;
+
+ PyErr_LDB_OR_RAISE(py_ldb, ldb);
+
+ schema = dsdb_get_schema(ldb, NULL);
+
+ if (!schema) {
+ PyErr_SetString(PyExc_RuntimeError, "Failed to find a schema from ldb \n");
+ return NULL;
+ }
+ status = dsdb_schema_pfm_oid_from_attid(schema->prefixmap, attid,
+ mem_ctx, &oid);
+ PyErr_WERROR_IS_ERR_RAISE(status);
+
+ return PyString_FromString(oid);
+}
+
static PyObject *py_dsdb_set_ntds_invocation_id(PyObject *self, PyObject *args)
{
PyObject *py_ldb, *py_guid;
@@ -314,6 +349,8 @@ static PyMethodDef py_dsdb_methods[] = {
"Get SID of domain in use." },
{ "samdb_ntds_invocation_id", (PyCFunction)py_samdb_ntds_invocation_id,
METH_VARARGS, "get the NTDS invocation ID GUID as a string"},
+ { "dsdb_get_oid_from_attid", (PyCFunction)py_dsdb_get_oid_from_attid, METH_VARARGS,
+ NULL },
{ "dsdb_set_ntds_invocation_id",
(PyCFunction)py_dsdb_set_ntds_invocation_id, METH_VARARGS,
NULL },