98
98
static void openchange_ldb_init(const char *syspath)
101
struct ldb_context *ldb_ctx;
103
struct tevent_context *ev;
105
struct ldb_result *res;
106
struct ldb_dn *tmp_dn = NULL;
107
static const char *attrs[] = {
108
"rootDomainNamingContext",
109
"defaultNamingContext",
101
struct loadparm_context *lp_ctx;
102
const char *openchangedb_backend;
114
104
if (globals.ocdb_ctx) return;
116
/* ev = tevent_context_init(talloc_autofree_context()); */
122
106
mem_ctx = talloc_zero(NULL, TALLOC_CTX);
124
/* Step 1. Retrieve a LDB context pointer on openchange.ldb database */
125
ldb_ctx = ldb_init(mem_ctx, ev);
130
/* Step 2. Connect to the database */
131
ldb_path = talloc_asprintf(mem_ctx, "%s/openchange.ldb", syspath);
132
ret = ldb_connect(ldb_ctx, ldb_path, 0, NULL);
133
if (ret != LDB_SUCCESS) {
137
/* Step 3. Search for rootDSE record */
138
ret = ldb_search(ldb_ctx, mem_ctx, &res, ldb_dn_new(mem_ctx, ldb_ctx, "@ROOTDSE"),
139
LDB_SCOPE_BASE, attrs, NULL);
140
if (ret != LDB_SUCCESS || res->count != 1) {
144
/* Step 4. Set opaque naming */
145
tmp_dn = ldb_msg_find_attr_as_dn(ldb_ctx, ldb_ctx,
146
res->msgs[0], "rootDomainNamingContext");
147
ldb_set_opaque(ldb_ctx, "rootDomainNamingContext", tmp_dn);
149
tmp_dn = ldb_msg_find_attr_as_dn(ldb_ctx, ldb_ctx,
150
res->msgs[0], "defaultNamingContext");
151
ldb_set_opaque(ldb_ctx, "defaultNamingContext", tmp_dn);
153
globals.ocdb_ctx = ldb_ctx;
107
lp_ctx = loadparm_init_global(true);
108
openchangedb_backend = lpcfg_parm_string(lp_ctx, NULL, "mapiproxy", "openchangedb");
110
if (openchangedb_backend) {
111
openchangedb_mysql_initialize(mem_ctx, lp_ctx, &globals.ocdb_ctx);
113
openchangedb_ldb_initialize(mem_ctx, syspath, &globals.ocdb_ctx);
116
if (!globals.ocdb_ctx) {
117
PyErr_SetString(PyExc_SystemError, "Cannot initialize openchangedb ldb");
154
120
(void) talloc_reference(NULL, globals.ocdb_ctx);
157
122
talloc_free(mem_ctx);
469
434
.tp_methods = mapistore_methods,
470
435
/* .tp_getset = mapistore_getsetters, */
471
436
.tp_new = py_MAPIStore_new,
472
.tp_dealloc = (destructor)py_MAPIStore_dealloc,
437
.tp_dealloc = (destructor)py_MAPIStore_dealloc,
473
438
.tp_flags = Py_TPFLAGS_DEFAULT,
476
441
static PyObject *py_mapistore_set_mapping_path(PyObject *mod, PyObject *args)
478
443
const char *mapping_path;
480
445
if (!PyArg_ParseTuple(args, "s", &mapping_path)) {