diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-08-24 22:08:27 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-08-25 08:40:04 +1000 |
commit | 8438da96ba632671327506423239169402917c51 (patch) | |
tree | 990dad89e68e2841d9046745872ce7d900912b3d /source4 | |
parent | 495bd182f5e26cbcb721ab8209f8acad4d612726 (diff) | |
download | samba-8438da96ba632671327506423239169402917c51.tar.gz samba-8438da96ba632671327506423239169402917c51.tar.bz2 samba-8438da96ba632671327506423239169402917c51.zip |
s4-dsdb: added get_attid_from_lDAPDisplayName() on samdb
This can be used to form the partial_attribute_set list for
GetNCChanges
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4')
-rw-r--r-- | source4/dsdb/pydsdb.c | 46 | ||||
-rw-r--r-- | source4/scripting/python/samba/samdb.py | 3 |
2 files changed, 49 insertions, 0 deletions
diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c index 1967b33e4a..e51c3640c6 100644 --- a/source4/dsdb/pydsdb.c +++ b/source4/dsdb/pydsdb.c @@ -258,6 +258,50 @@ static PyObject *py_dsdb_get_oid_from_attid(PyObject *self, PyObject *args) return ret; } + +static PyObject *py_dsdb_get_attid_from_lDAPDisplayName(PyObject *self, PyObject *args) +{ + PyObject *py_ldb, *is_schema_nc; + struct ldb_context *ldb; + struct dsdb_schema *schema; + const char *ldap_display_name; + bool schema_nc = false; + const struct dsdb_attribute *a; + uint32_t attid; + + if (!PyArg_ParseTuple(args, "OsO", &py_ldb, &ldap_display_name, &is_schema_nc)) + return NULL; + + PyErr_LDB_OR_RAISE(py_ldb, ldb); + + if (is_schema_nc) { + if (!PyBool_Check(is_schema_nc)) { + PyErr_SetString(PyExc_TypeError, "Expected boolean is_schema_nc"); + return NULL; + } + if (is_schema_nc == Py_True) { + schema_nc = true; + } + } + + 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_lDAPDisplayName(schema, ldap_display_name); + if (a == NULL) { + PyErr_Format(PyExc_RuntimeError, "Failed to find attribute '%s'", ldap_display_name); + return NULL; + } + + attid = dsdb_attribute_get_attid(a, schema_nc); + + return PyLong_FromUnsignedLong(attid); +} + static PyObject *py_dsdb_set_ntds_invocation_id(PyObject *self, PyObject *args) { PyObject *py_ldb, *py_guid; @@ -485,6 +529,8 @@ static PyMethodDef py_dsdb_methods[] = { "Set NTDS Settings DN for this LDB (allows it to be set before the DB fully exists)." }, { "_dsdb_get_oid_from_attid", (PyCFunction)py_dsdb_get_oid_from_attid, METH_VARARGS, NULL }, + { "_dsdb_get_attid_from_lDAPDisplayName", (PyCFunction)py_dsdb_get_attid_from_lDAPDisplayName, + METH_VARARGS, NULL }, { "_dsdb_set_ntds_invocation_id", (PyCFunction)py_dsdb_set_ntds_invocation_id, METH_VARARGS, NULL }, diff --git a/source4/scripting/python/samba/samdb.py b/source4/scripting/python/samba/samdb.py index 14c21bc0b6..cc82e53907 100644 --- a/source4/scripting/python/samba/samdb.py +++ b/source4/scripting/python/samba/samdb.py @@ -440,6 +440,9 @@ accountExpires: %u def get_oid_from_attid(self, attid): return dsdb._dsdb_get_oid_from_attid(self, attid) + def get_attid_from_lDAPDisplayName(self, ldap_display_name, is_schema_nc=False): + return dsdb._dsdb_get_attid_from_lDAPDisplayName(self, ldap_display_name, is_schema_nc) + def get_invocation_id(self): "Get the invocation_id id" return dsdb._samdb_ntds_invocation_id(self) |