diff options
author | Andrew Tridgell <tridge@samba.org> | 2010-09-09 17:59:40 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2010-09-09 21:39:24 +1000 |
commit | c95c3863dfec8e0160ff3bb217c6922666feed05 (patch) | |
tree | 67e6439bf9e9745cf6d2364997fb00ad7297fc8d | |
parent | c44bdbc01d53efcccb725600764b981216b1ff10 (diff) | |
download | samba-c95c3863dfec8e0160ff3bb217c6922666feed05.tar.gz samba-c95c3863dfec8e0160ff3bb217c6922666feed05.tar.bz2 samba-c95c3863dfec8e0160ff3bb217c6922666feed05.zip |
pyldb: expose PyLdbDn_FromDn()
This is needed by the dsdb python interface
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
-rw-r--r-- | source4/lib/ldb/pyldb.c | 18 | ||||
-rw-r--r-- | source4/lib/ldb/pyldb_util.c | 29 |
2 files changed, 29 insertions, 18 deletions
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index b60f4fc3ee..57407ba0b6 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -357,24 +357,6 @@ static PyObject *py_ldb_dn_new(PyTypeObject *type, PyObject *args, PyObject *kwa return (PyObject *)py_ret; } -PyObject *PyLdbDn_FromDn(struct ldb_dn *dn) -{ - PyLdbDnObject *py_ret; - - if (dn == NULL) { - Py_RETURN_NONE; - } - - py_ret = (PyLdbDnObject *)PyLdbDn.tp_alloc(&PyLdbDn, 0); - if (py_ret == NULL) { - PyErr_NoMemory(); - return NULL; - } - py_ret->mem_ctx = talloc_new(NULL); - py_ret->dn = talloc_reference(py_ret->mem_ctx, dn); - return (PyObject *)py_ret; -} - static void py_ldb_dn_dealloc(PyLdbDnObject *self) { talloc_free(self->mem_ctx); diff --git a/source4/lib/ldb/pyldb_util.c b/source4/lib/ldb/pyldb_util.c index 41bcb55bd1..170c291698 100644 --- a/source4/lib/ldb/pyldb_util.c +++ b/source4/lib/ldb/pyldb_util.c @@ -79,3 +79,32 @@ bool PyObject_AsDn(TALLOC_CTX *mem_ctx, PyObject *object, PyErr_SetString(PyExc_TypeError, "Expected DN"); return false; } + +PyObject *PyLdbDn_FromDn(struct ldb_dn *dn) +{ + PyLdbDnObject *py_ret; + PyTypeObject *PyLdb_Dn_Type; + + if (dn == NULL) { + Py_RETURN_NONE; + } + + if (ldb_module == NULL) { + ldb_module = PyImport_ImportModule("ldb"); + if (ldb_module == NULL) + return NULL; + } + + PyLdb_Dn_Type = (PyTypeObject *)PyObject_GetAttrString(ldb_module, "Dn"); + if (PyLdb_Dn_Type == NULL) + return NULL; + + py_ret = (PyLdbDnObject *)PyLdb_Dn_Type->tp_alloc(PyLdb_Dn_Type, 0); + if (py_ret == NULL) { + PyErr_NoMemory(); + return NULL; + } + py_ret->mem_ctx = talloc_new(NULL); + py_ret->dn = talloc_reference(py_ret->mem_ctx, dn); + return (PyObject *)py_ret; +} |