ldb: tests for <= and >= integer indexing
[nivanova/samba-autobuild/.git] / lib / ldb-samba / pyldb.c
index 0cf550bc7a5b2a895eb92df1df903c39825a0e70..397e11062b6e68188a7d0e61a0a1518009e98724 100644 (file)
@@ -30,6 +30,7 @@
 #include "lib/ldb-samba/ldif_handlers.h"
 #include "auth/pyauth.h"
 #include "source4/dsdb/common/util.h"
+#include "lib/ldb/include/ldb_private.h"
 
 
 static PyObject *pyldb_module;
@@ -202,6 +203,29 @@ static PyObject *py_ldb_set_session_info(PyObject *self, PyObject *args)
        Py_RETURN_NONE;
 }
 
+static PyObject *py_ldb_samba_schema_attribute_add(PyLdbObject *self,
+                                                  PyObject *args)
+{
+       char *attribute, *syntax;
+       const struct ldb_schema_syntax *s;
+       unsigned int flags;
+       int ret;
+       struct ldb_context *ldb_ctx;
+
+       if (!PyArg_ParseTuple(args, "sIs", &attribute, &flags, &syntax))
+               return NULL;
+
+       ldb_ctx = pyldb_Ldb_AsLdbContext(self);
+
+       s = ldb_samba_syntax_by_name(ldb_ctx, syntax);
+       ret = ldb_schema_attribute_add_with_syntax(ldb_ctx, attribute,
+                                                  flags, s);
+
+       PyErr_LDB_ERROR_IS_ERR_RAISE(py_ldb_error, ret, ldb_ctx);
+
+       Py_RETURN_NONE;
+}
+
 static PyObject *py_ldb_register_samba_handlers(PyObject *self)
 {
        struct ldb_context *ldb;
@@ -237,6 +261,9 @@ static PyMethodDef py_samba_ldb_methods[] = {
        { "set_session_info", (PyCFunction)py_ldb_set_session_info, METH_VARARGS,
                "set_session_info(session_info)\n"
                "Set session info to use when connecting." },
+       { "samba_schema_attribute_add",
+               (PyCFunction)py_ldb_samba_schema_attribute_add,
+               METH_VARARGS, NULL },
        { NULL },
 };
 
@@ -255,6 +282,7 @@ static PyTypeObject PySambaLdb = {
        .tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,
 };
 
+
 MODULE_INIT_FUNC(_ldb)
 {
        PyObject *m;
@@ -283,5 +311,8 @@ MODULE_INIT_FUNC(_ldb)
        Py_INCREF(&PySambaLdb);
        PyModule_AddObject(m, "Ldb", (PyObject *)&PySambaLdb);
 
+#define ADD_LDB_STRING(val)  PyModule_AddStringConstant(m, #val, LDB_## val)
+       ADD_LDB_STRING(SYNTAX_SAMBA_INT32);
+
        return m;
 }