diff options
author | Amitay Isaacs <amitay@gmail.com> | 2011-08-12 17:09:19 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-08-13 12:31:09 +1000 |
commit | e580f33b131471b9fa70764d3fc395db592accd2 (patch) | |
tree | 34307d214b8735c93f1ce6607f140f14703b2c3f /source3/passdb | |
parent | a252e69db28c1e65fe1ba74ce5b6db7d34c2bcff (diff) | |
download | samba-e580f33b131471b9fa70764d3fc395db592accd2.tar.gz samba-e580f33b131471b9fa70764d3fc395db592accd2.tar.bz2 samba-e580f33b131471b9fa70764d3fc395db592accd2.zip |
s3-passdb: Return dom_sid and guid with correct python types.
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source3/passdb')
-rw-r--r-- | source3/passdb/py_passdb.c | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/source3/passdb/py_passdb.c b/source3/passdb/py_passdb.c index 8d1ee5681c..3fac27c8b9 100644 --- a/source3/passdb/py_passdb.c +++ b/source3/passdb/py_passdb.c @@ -39,6 +39,7 @@ static PyTypeObject *dom_sid_Type = NULL; +static PyTypeObject *guid_Type = NULL; staticforward PyTypeObject PySamu; staticforward PyTypeObject PyPDB; @@ -960,6 +961,8 @@ static PyObject *py_pdb_domain_info(pytalloc_Object *self, PyObject *args) struct pdb_domain_info *domain_info; PyObject *py_domain_info; TALLOC_CTX *tframe; + struct dom_sid *sid; + struct GUID *guid; methods = pytalloc_get_ptr(self); @@ -973,6 +976,21 @@ static PyObject *py_pdb_domain_info(pytalloc_Object *self, PyObject *args) Py_RETURN_NONE; } + sid = dom_sid_dup(tframe, &domain_info->sid); + if (sid == NULL) { + PyErr_NoMemory(); + talloc_free(tframe); + return NULL; + } + + guid = talloc(tframe, struct GUID); + if (guid == NULL) { + PyErr_NoMemory(); + talloc_free(tframe); + return NULL; + } + *guid = domain_info->guid; + if ((py_domain_info = PyDict_New()) == NULL) { PyErr_NoMemory(); return NULL; @@ -981,10 +999,8 @@ static PyObject *py_pdb_domain_info(pytalloc_Object *self, PyObject *args) PyDict_SetItemString(py_domain_info, "name", PyString_FromString(domain_info->name)); PyDict_SetItemString(py_domain_info, "dns_domain", PyString_FromString(domain_info->name)); PyDict_SetItemString(py_domain_info, "dns_forest", PyString_FromString(domain_info->name)); - /* - struct dom_sid sid; - struct GUID guid; - */ + PyDict_SetItemString(py_domain_info, "dom_sid", pytalloc_steal(dom_sid_Type, sid)); + PyDict_SetItemString(py_domain_info, "guid", pytalloc_steal(guid_Type, guid)); talloc_free(tframe); @@ -1577,7 +1593,15 @@ void initpassdb(void) return; } - /* FIXME: Load passdb backends - * Currently there is no equivalent public function for lazy_initialize_passdb() - */ + /* Import GUID type from dcerpc.misc */ + mod = PyImport_ImportModule("samba.dcerpc.misc"); + if (mod == NULL) { + return; + } + + guid_Type = (PyTypeObject *)PyObject_GetAttrString(mod, "GUID"); + Py_DECREF(mod); + if (guid_Type == NULL) { + return; + } } |