From 02562a0ca988b5b1e0796a445aabc96dddb408d2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 11 Jul 2011 14:27:21 +1000 Subject: dsdb: added get_lDAPDisplayName_by_attid this allows conversion from a DRS attribute ID to a LDAP display name Pair-Programmed-With: Amitay Isaacs Pair-Programmed-With: Andrew Bartlett --- source4/dsdb/pydsdb.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'source4/dsdb/pydsdb.c') diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c index 2440ac83d3..463a2f99d9 100644 --- a/source4/dsdb/pydsdb.c +++ b/source4/dsdb/pydsdb.c @@ -394,6 +394,37 @@ static PyObject *py_dsdb_get_linkId_from_lDAPDisplayName(PyObject *self, PyObjec return PyInt_FromLong(attribute->linkID); } + +static PyObject *py_dsdb_get_lDAPDisplayName_by_attid(PyObject *self, PyObject *args) +{ + PyObject *py_ldb; + struct ldb_context *ldb; + struct dsdb_schema *schema; + const struct dsdb_attribute *a; + uint32_t attid; + + 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"); + return NULL; + } + + a = dsdb_attribute_by_attributeID_id(schema, attid); + if (a == NULL) { + PyErr_Format(PyExc_RuntimeError, "Failed to find attribute '0x%08x'", attid); + return NULL; + } + + return PyString_FromString(a->lDAPDisplayName); +} + + /* return the attribute syntax oid as a string from the attribute name */ @@ -904,6 +935,8 @@ static PyMethodDef py_dsdb_methods[] = { METH_VARARGS, NULL }, { "_dsdb_get_linkId_from_lDAPDisplayName", (PyCFunction)py_dsdb_get_linkId_from_lDAPDisplayName, METH_VARARGS, NULL }, + { "_dsdb_get_lDAPDisplayName_by_attid", (PyCFunction)py_dsdb_get_lDAPDisplayName_by_attid, + METH_VARARGS, NULL }, { "_dsdb_set_ntds_invocation_id", (PyCFunction)py_dsdb_set_ntds_invocation_id, METH_VARARGS, NULL }, -- cgit