diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2010-04-04 00:21:09 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2010-04-04 00:21:09 +0200 |
commit | 8afd52a6418125100a5e8a6a4312c0460e57ac88 (patch) | |
tree | 926dfbb6722f792a1f5239f8ef41dbf8ed72b8f9 /source4/dsdb | |
parent | 31a517e1721fc0080473b376cd59c090cfab6456 (diff) | |
download | samba-8afd52a6418125100a5e8a6a4312c0460e57ac88.tar.gz samba-8afd52a6418125100a5e8a6a4312c0460e57ac88.tar.bz2 samba-8afd52a6418125100a5e8a6a4312c0460e57ac88.zip |
s4-python: Move samdb_server_site_name to dsdb module.
Diffstat (limited to 'source4/dsdb')
-rw-r--r-- | source4/dsdb/pydsdb.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c index b365744e42..248bc1a07a 100644 --- a/source4/dsdb/pydsdb.c +++ b/source4/dsdb/pydsdb.c @@ -20,8 +20,46 @@ #include <Python.h> #include "includes.h" #include "dsdb/samdb/samdb.h" +#include "lib/ldb/pyldb.h" + +/* FIXME: These should be in a header file somewhere, once we finish moving + * away from SWIG .. */ +#define PyErr_LDB_OR_RAISE(py_ldb, ldb) \ +/* if (!PyLdb_Check(py_ldb)) { \ + PyErr_SetString(py_ldb_get_exception(), "Ldb connection object required"); \ + return NULL; \ + } */\ + ldb = PyLdb_AsLdbContext(py_ldb); + +static PyObject *py_samdb_server_site_name(PyObject *self, PyObject *args) +{ + PyObject *py_ldb, *result; + struct ldb_context *ldb; + const char *site; + TALLOC_CTX *mem_ctx = talloc_new(NULL); + + if (!PyArg_ParseTuple(args, "O", &py_ldb)) { + talloc_free(mem_ctx); + return NULL; + } + + PyErr_LDB_OR_RAISE(py_ldb, ldb); + + site = samdb_server_site_name(ldb, mem_ctx); + if (site == NULL) { + PyErr_SetString(PyExc_RuntimeError, "Failed to find server site"); + talloc_free(mem_ctx); + return NULL; + } + + result = PyString_FromString(site); + talloc_free(mem_ctx); + return result; +} static PyMethodDef py_dsdb_methods[] = { + { "server_site_name", (PyCFunction)py_samdb_server_site_name, METH_VARARGS, + "get the server site name as a string"}, { NULL } }; |