return LDB_ERR_OPERATIONS_ERROR;
}
-static int extended_search_async(struct ldb_module *module, struct ldb_control *control, struct ldb_request *req)
+static int extended_search_async(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_control *control;
struct ldb_extended_dn_control *extended_ctrl;
struct ldb_control **saved_controls;
struct extended_async_context *ac;
char **new_attrs;
int ret;
+ /* check if there's an extended dn control */
+ control = get_control_from_list(req->controls, LDB_CONTROL_EXTENDED_DN_OID);
+ if (control == NULL) {
+ /* not found go on */
+ return ldb_next_request(module, req);
+ }
+
extended_ctrl = talloc_get_type(control->data, struct ldb_extended_dn_control);
if (!extended_ctrl) {
return LDB_ERR_PROTOCOL_ERROR;
case LDB_REQ_SEARCH:
return extended_search(module, control, req);
- case LDB_ASYNC_SEARCH:
- return extended_search_async(module, control, req);
-
default:
return LDB_ERR_OPERATIONS_ERROR;
static const struct ldb_module_ops extended_dn_ops = {
.name = "extended_dn",
+ .search = extended_search_async,
.request = extended_request,
.init_context = extended_init
};
switch (req->operation) {
case LDB_REQ_ADD:
- case LDB_ASYNC_ADD:
case LDB_REQ_MODIFY:
- case LDB_ASYNC_MODIFY:
case LDB_REQ_DELETE:
- case LDB_ASYNC_DELETE:
case LDB_REQ_RENAME:
- case LDB_ASYNC_RENAME:
return kludge_acl_change(module, req);
case LDB_REQ_SEARCH:
return kludge_acl_search(module, req);
- case LDB_ASYNC_SEARCH:
- return kludge_acl_search_async(module, req);
-
case LDB_REQ_REGISTER:
return ldb_next_request(module, req);
static const struct ldb_module_ops kludge_acl_ops = {
.name = "kludge_acl",
+ .search = kludge_acl_search_async,
+ .add = kludge_acl_change,
+ .modify = kludge_acl_change,
+ .del = kludge_acl_change,
+ .rename = kludge_acl_change,
.request = kludge_acl_request,
.start_transaction = kludge_acl_start_trans,
.end_transaction = kludge_acl_end_trans,
case LDB_REQ_ADD:
return objectguid_add(module, req);
- case LDB_ASYNC_ADD:
- return objectguid_add_async(module, req);
-
default:
return ldb_next_request(module, req);
static const struct ldb_module_ops objectguid_ops = {
.name = "objectguid",
+ .add = objectguid_add_async,
.request = objectguid_request
};
case LDB_REQ_MODIFY:
return password_hash_modify(module, req);
- case LDB_ASYNC_ADD:
- return password_hash_add_async(module, req);
-
- case LDB_ASYNC_MODIFY:
- return password_hash_modify_async(module, req);
-
default:
return ldb_next_request(module, req);
static const struct ldb_module_ops password_hash_ops = {
.name = "password_hash",
+ .add = password_hash_add_async,
+ .modify = password_hash_modify_async,
.request = password_hash_request,
.async_wait = password_hash_async_wait
};
case LDB_REQ_SEARCH:
return rootdse_search_bytree(module, req);
- case LDB_ASYNC_SEARCH:
- return rootdse_search_async(module, req);
-
case LDB_REQ_REGISTER:
return rootdse_register_control(module, req);
static const struct ldb_module_ops rootdse_ops = {
.name = "rootdse",
.init_context = rootdse_init,
+ .search = rootdse_search_async,
.request = rootdse_request
};
case LDB_REQ_ADD:
return samldb_add(module, req);
- case LDB_ASYNC_ADD:
- return samldb_add_async(module, req);
-
default:
return ldb_next_request(module, req);
static const struct ldb_module_ops samldb_ops = {
.name = "samldb",
.init_context = samldb_init,
+ .add = samldb_add_async,
.request = samldb_request
};
*/
int ldb_request(struct ldb_context *ldb, struct ldb_request *req)
{
- int status, started_transaction=0;
+ struct ldb_module *module;
+ int ret, started_transaction=0;
ldb_reset_err_string(ldb);
req->op.search.res = NULL;
}
- /* start a transaction if not async and not search */
+ /* start a transaction if SYNC and not search */
if ((!ldb->transaction_active) &&
(req->operation == LDB_REQ_ADD ||
req->operation == LDB_REQ_MODIFY ||
req->operation == LDB_REQ_DELETE ||
req->operation == LDB_REQ_RENAME)) {
- status = ldb_transaction_start(ldb);
- if (status != LDB_SUCCESS) {
- talloc_free(req);
- return status;
+ ret = ldb_transaction_start(ldb);
+ if (ret != LDB_SUCCESS) {
+ return ret;
}
started_transaction = 1;
}
/* call the first module in the chain */
- status = ldb->modules->ops->request(ldb->modules, req);
+ switch (req->operation) {
+ case LDB_ASYNC_SEARCH:
+ FIRST_OP(ldb, search);
+ ret = module->ops->search(module, req);
+ break;
+ case LDB_ASYNC_ADD:
+ FIRST_OP(ldb, add);
+ ret = module->ops->add(module, req);
+ break;
+ case LDB_ASYNC_MODIFY:
+ FIRST_OP(ldb, modify);
+ ret = module->ops->modify(module, req);
+ break;
+ case LDB_ASYNC_DELETE:
+ FIRST_OP(ldb, del);
+ ret = module->ops->del(module, req);
+ break;
+ case LDB_ASYNC_RENAME:
+ FIRST_OP(ldb, rename);
+ ret = module->ops->rename(module, req);
+ break;
+ default:
+ FIRST_OP(ldb, request);
+ ret = module->ops->request(module, req);
+ break;
+ }
if (started_transaction) {
- return ldb_op_finish(ldb, status);
+ return ldb_op_finish(ldb, ret);
}
- return status;
+ return ret;
}
/*
}
ret = ldb_request(ldb, req);
-
if (ret == LDB_SUCCESS) {
ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
}
/*
helper functions to call the next module in chain
*/
+
int ldb_next_request(struct ldb_module *module, struct ldb_request *request)
{
- FIND_OP(module, request);
- return module->ops->request(module, request);
+ switch (request->operation) {
+ case LDB_ASYNC_SEARCH:
+ FIND_OP(module, search);
+ return module->ops->search(module, request);
+ case LDB_ASYNC_ADD:
+ FIND_OP(module, add);
+ return module->ops->add(module, request);
+ case LDB_ASYNC_MODIFY:
+ FIND_OP(module, modify);
+ return module->ops->modify(module, request);
+ case LDB_ASYNC_DELETE:
+ FIND_OP(module, del);
+ return module->ops->del(module, request);
+ case LDB_ASYNC_RENAME:
+ FIND_OP(module, rename);
+ return module->ops->rename(module, request);
+ default:
+ FIND_OP(module, request);
+ return module->ops->request(module, request);
+ }
}
int ldb_next_init(struct ldb_module *module)
struct ldb_module_ops {
const char *name;
int (*init_context) (struct ldb_module *);
- int (*request)(struct ldb_module *, struct ldb_request *);
+ int (*search)(struct ldb_module *, struct ldb_request *); /* search */
+ int (*add)(struct ldb_module *, struct ldb_request *); /* add */
+ int (*modify)(struct ldb_module *, struct ldb_request *); /* modify */
+ int (*del)(struct ldb_module *, struct ldb_request *); /* delete */
+ int (*rename)(struct ldb_module *, struct ldb_request *); /* rename */
+ int (*request)(struct ldb_module *, struct ldb_request *); /* match any other operation */
int (*start_transaction)(struct ldb_module *);
int (*end_transaction)(struct ldb_module *);
int (*del_transaction)(struct ldb_module *);
/*
search for matching records using an asynchronous function
*/
-static int ildb_search_async(struct ldb_module *module, const struct ldb_dn *base,
- enum ldb_scope scope, struct ldb_parse_tree *tree,
- const char * const *attrs,
- struct ldb_control **control_req,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- int timeout,
- struct ldb_async_handle **handle)
+static int ildb_search_async(struct ldb_module *module, struct ldb_request *req)
{
struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
struct ldap_message *msg;
int n;
- *handle = NULL;
+ req->async.handle = NULL;
- if (!callback || !context) {
+ if (!req->async.callback || !req->async.context) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Async interface called with NULL callback function or NULL context"));
return LDB_ERR_OPERATIONS_ERROR;
}
- if (tree == NULL) {
+ if (req->op.search.tree == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Invalid expression parse tree"));
return LDB_ERR_OPERATIONS_ERROR;
}
msg->type = LDAP_TAG_SearchRequest;
- if (base == NULL) {
+ if (req->op.search.base == NULL) {
if (ildb->rootDSE != NULL) {
msg->r.SearchRequest.basedn =
talloc_strdup(msg, ldb_msg_find_string(ildb->rootDSE, "defaultNamingContext", ""));
msg->r.SearchRequest.basedn = talloc_strdup(msg, "");
}
} else {
- msg->r.SearchRequest.basedn = ldb_dn_linearize(msg, base);
+ msg->r.SearchRequest.basedn = ldb_dn_linearize(msg, req->op.search.base);
}
if (msg->r.SearchRequest.basedn == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Unable to determine baseDN"));
return LDB_ERR_OPERATIONS_ERROR;
}
- if (scope == LDB_SCOPE_DEFAULT) {
+ if (req->op.search.scope == LDB_SCOPE_DEFAULT) {
msg->r.SearchRequest.scope = LDB_SCOPE_SUBTREE;
} else {
- msg->r.SearchRequest.scope = scope;
+ msg->r.SearchRequest.scope = req->op.search.scope;
}
msg->r.SearchRequest.deref = LDAP_DEREFERENCE_NEVER;
msg->r.SearchRequest.timelimit = 0;
msg->r.SearchRequest.sizelimit = 0;
msg->r.SearchRequest.attributesonly = 0;
- msg->r.SearchRequest.tree = tree;
+ msg->r.SearchRequest.tree = req->op.search.tree;
- for (n = 0; attrs && attrs[n]; n++) /* noop */ ;
+ for (n = 0; req->op.search.attrs && req->op.search.attrs[n]; n++) /* noop */ ;
msg->r.SearchRequest.num_attributes = n;
- msg->r.SearchRequest.attributes = discard_const(attrs);
- msg->controls = control_req;
+ msg->r.SearchRequest.attributes = discard_const(req->op.search.attrs);
+ msg->controls = req->controls;
- return ildb_request_send(module, msg, context, callback, timeout, handle);
+ return ildb_request_send(module, msg, req->async.context, req->async.callback, req->async.timeout, &(req->async.handle));
}
static int ildb_search_sync_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
struct ldb_result **res)
{
struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
- struct ldb_async_handle *handle;
+ struct ldb_request *req;
int ret;
*res = talloc_zero(ildb, struct ldb_result);
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ildb_search_async(module, base, scope, tree, attrs, control_req,
- res, &ildb_search_sync_callback, ildb->ldap->timeout, &handle);
+ req = talloc_zero(ildb, struct ldb_request);
+ if (! req) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ req->operation = LDB_ASYNC_SEARCH;
+ req->op.search.base = base;
+ req->op.search.scope = scope;
+ req->op.search.tree = tree;
+ req->op.search.attrs = attrs;
+ req->controls = control_req;
+ req->async.context = (void *)res;
+ req->async.callback = ildb_search_sync_callback;
+ req->async.timeout = ildb->ldap->timeout;
+
+ ret = ildb_search_async(module, req);
if (ret == LDB_SUCCESS) {
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
- talloc_free(handle);
+ ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
+ talloc_free(req);
}
if (ret != LDB_SUCCESS) {
/*
add a record
*/
-static int ildb_add_async(struct ldb_module *module, const struct ldb_message *ldb_msg,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- int timeout,
- struct ldb_async_handle **handle)
+static int ildb_add_async(struct ldb_module *module, struct ldb_request *req)
{
struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
struct ldap_message *msg;
struct ldap_mod **mods;
int i,n;
- *handle = NULL;
+ req->async.handle = NULL;
/* ignore ltdb specials */
- if (ldb_dn_is_special(ldb_msg->dn)) {
+ if (ldb_dn_is_special(req->op.add.message->dn)) {
return LDB_SUCCESS;
}
msg->type = LDAP_TAG_AddRequest;
- msg->r.AddRequest.dn = ldb_dn_linearize(msg, ldb_msg->dn);
+ msg->r.AddRequest.dn = ldb_dn_linearize(msg, req->op.add.message->dn);
if (msg->r.AddRequest.dn == NULL) {
talloc_free(msg);
return LDB_ERR_INVALID_DN_SYNTAX;
}
- mods = ildb_msg_to_mods(msg, &n, ldb_msg, 0);
+ mods = ildb_msg_to_mods(msg, &n, req->op.add.message, 0);
if (mods == NULL) {
talloc_free(msg);
return LDB_ERR_OPERATIONS_ERROR;
msg->r.AddRequest.attributes[i] = mods[i]->attrib;
}
- return ildb_request_send(module, msg, context, callback, timeout, handle);
+ return ildb_request_send(module, msg, req->async.context, req->async.callback, req->async.timeout, &(req->async.handle));
}
static int ildb_add(struct ldb_module *module, const struct ldb_message *msg)
{
struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
- struct ldb_async_handle *handle;
+ struct ldb_request *req;
int ret;
- ret = ildb_add_async(module, msg,
- NULL, NULL, ildb->ldap->timeout, &handle);
+ req = talloc_zero(ildb, struct ldb_request);
+ if (! req) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ req->operation = LDB_ASYNC_ADD;
+ req->op.add.message = msg;
+ req->controls = NULL;
+ req->async.context = NULL;
+ req->async.callback = NULL;
+ req->async.timeout = ildb->ldap->timeout;
+
+ ret = ildb_add_async(module, req);
- if (ret != LDB_SUCCESS)
+ if (ret != LDB_SUCCESS) {
+ talloc_free(req);
return ret;
+ }
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
+ ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
- talloc_free(handle);
+ talloc_free(req);
return ret;
}
/*
modify a record
*/
-static int ildb_modify_async(struct ldb_module *module, const struct ldb_message *ldb_msg,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- int timeout,
- struct ldb_async_handle **handle)
+static int ildb_modify_async(struct ldb_module *module, struct ldb_request *req)
{
struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
struct ldap_message *msg;
struct ldap_mod **mods;
int i,n;
- *handle = NULL;
+ req->async.handle = NULL;
/* ignore ltdb specials */
- if (ldb_dn_is_special(ldb_msg->dn)) {
+ if (ldb_dn_is_special(req->op.mod.message->dn)) {
return LDB_SUCCESS;
}
msg->type = LDAP_TAG_ModifyRequest;
- msg->r.ModifyRequest.dn = ldb_dn_linearize(msg, ldb_msg->dn);
+ msg->r.ModifyRequest.dn = ldb_dn_linearize(msg, req->op.mod.message->dn);
if (msg->r.ModifyRequest.dn == NULL) {
talloc_free(msg);
return LDB_ERR_INVALID_DN_SYNTAX;
}
- mods = ildb_msg_to_mods(msg, &n, ldb_msg, 1);
+ mods = ildb_msg_to_mods(msg, &n, req->op.mod.message, 1);
if (mods == NULL) {
talloc_free(msg);
return LDB_ERR_OPERATIONS_ERROR;
msg->r.ModifyRequest.mods[i] = *mods[i];
}
- return ildb_request_send(module, msg, context, callback, timeout, handle);
+ return ildb_request_send(module, msg,
+ req->async.context,
+ req->async.callback,
+ req->async.timeout,
+ &(req->async.handle));
}
static int ildb_modify(struct ldb_module *module, const struct ldb_message *msg)
{
struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
- struct ldb_async_handle *handle;
+ struct ldb_request *req;
int ret;
- ret = ildb_modify_async(module, msg,
- NULL, NULL, ildb->ldap->timeout, &handle);
+ req = talloc_zero(ildb, struct ldb_request);
+ if (! req) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ req->operation = LDB_ASYNC_MODIFY;
+ req->op.mod.message = msg;
+ req->controls = NULL;
+ req->async.context = NULL;
+ req->async.callback = NULL;
+ req->async.timeout = ildb->ldap->timeout;
+
+ ret = ildb_modify_async(module, req);
- if (ret != LDB_SUCCESS)
+ if (ret != LDB_SUCCESS) {
+ talloc_free(req);
return ret;
+ }
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
+ ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
- talloc_free(handle);
+ talloc_free(req);
return ret;
}
/*
delete a record
*/
-static int ildb_delete_async(struct ldb_module *module, const struct ldb_dn *dn,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- int timeout,
- struct ldb_async_handle **handle)
+static int ildb_delete_async(struct ldb_module *module, struct ldb_request *req)
{
struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
struct ldap_message *msg;
- *handle = NULL;
+ req->async.handle = NULL;
/* ignore ltdb specials */
- if (ldb_dn_is_special(dn)) {
+ if (ldb_dn_is_special(req->op.del.dn)) {
return LDB_SUCCESS;
}
msg->type = LDAP_TAG_DelRequest;
- msg->r.DelRequest.dn = ldb_dn_linearize(msg, dn);
+ msg->r.DelRequest.dn = ldb_dn_linearize(msg, req->op.del.dn);
if (msg->r.DelRequest.dn == NULL) {
talloc_free(msg);
return LDB_ERR_INVALID_DN_SYNTAX;
}
- return ildb_request_send(module, msg, context, callback, timeout, handle);
+ return ildb_request_send(module, msg,
+ req->async.context,
+ req->async.callback,
+ req->async.timeout,
+ &(req->async.handle));
}
static int ildb_delete(struct ldb_module *module, const struct ldb_dn *dn)
{
struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
- struct ldb_async_handle *handle;
+ struct ldb_request *req;
int ret;
- ret = ildb_delete_async(module, dn,
- NULL, NULL, ildb->ldap->timeout, &handle);
+ req = talloc_zero(ildb, struct ldb_request);
+ if (! req) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
- if (ret != LDB_SUCCESS)
+ req->operation = LDB_ASYNC_DELETE;
+ req->op.del.dn = dn;
+ req->controls = NULL;
+ req->async.context = NULL;
+ req->async.callback = NULL;
+ req->async.timeout = ildb->ldap->timeout;
+
+ ret = ildb_delete_async(module, req);
+
+ if (ret != LDB_SUCCESS) {
+ talloc_free(req);
return ret;
+ }
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
+ ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
- talloc_free(handle);
+ talloc_free(req);
return ret;
}
/*
rename a record
*/
-static int ildb_rename_async(struct ldb_module *module,
- const struct ldb_dn *olddn, const struct ldb_dn *newdn,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- int timeout,
- struct ldb_async_handle **handle)
+static int ildb_rename_async(struct ldb_module *module, struct ldb_request *req)
{
struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
struct ldap_message *msg;
- *handle = NULL;
+ req->async.handle = NULL;
/* ignore ltdb specials */
- if (ldb_dn_is_special(olddn) || ldb_dn_is_special(newdn)) {
+ if (ldb_dn_is_special(req->op.rename.olddn) || ldb_dn_is_special(req->op.rename.newdn)) {
return LDB_SUCCESS;
}
}
msg->type = LDAP_TAG_ModifyDNRequest;
- msg->r.ModifyDNRequest.dn = ldb_dn_linearize(msg, olddn);
+ msg->r.ModifyDNRequest.dn = ldb_dn_linearize(msg, req->op.rename.olddn);
if (msg->r.ModifyDNRequest.dn == NULL) {
talloc_free(msg);
return LDB_ERR_INVALID_DN_SYNTAX;
msg->r.ModifyDNRequest.newrdn =
talloc_asprintf(msg, "%s=%s",
- newdn->components[0].name,
- ldb_dn_escape_value(msg, newdn->components[0].value));
+ req->op.rename.newdn->components[0].name,
+ ldb_dn_escape_value(msg, req->op.rename.newdn->components[0].value));
if (msg->r.ModifyDNRequest.newrdn == NULL) {
talloc_free(msg);
return LDB_ERR_OPERATIONS_ERROR;
msg->r.ModifyDNRequest.newsuperior =
ldb_dn_linearize(msg,
- ldb_dn_get_parent(msg, newdn));
+ ldb_dn_get_parent(msg, req->op.rename.newdn));
if (msg->r.ModifyDNRequest.newsuperior == NULL) {
talloc_free(msg);
return LDB_ERR_INVALID_DN_SYNTAX;
msg->r.ModifyDNRequest.deleteolddn = True;
- return ildb_request_send(module, msg, context, callback, timeout, handle);
+ return ildb_request_send(module, msg,
+ req->async.context,
+ req->async.callback,
+ req->async.timeout,
+ &(req->async.handle));
}
static int ildb_rename(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
{
struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
- struct ldb_async_handle *handle;
+ struct ldb_request *req;
int ret;
- ret = ildb_rename_async(module, olddn, newdn,
- NULL, NULL, ildb->ldap->timeout, &handle);
+ req = talloc_zero(ildb, struct ldb_request);
+ if (! req) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ req->operation = LDB_ASYNC_RENAME;
+ req->op.rename.olddn = olddn;
+ req->op.rename.newdn = newdn;
+ req->controls = NULL;
+ req->async.context = NULL;
+ req->async.callback = NULL;
+ req->async.timeout = ildb->ldap->timeout;
- if (ret != LDB_SUCCESS)
+ ret = ildb_rename_async(module, req);
+
+ if (ret != LDB_SUCCESS) {
+ talloc_free(req);
return ret;
+ }
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
+ ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
- talloc_free(handle);
+ talloc_free(req);
return ret;
}
req->op.rename.olddn,
req->op.rename.newdn);
- case LDB_ASYNC_SEARCH:
- return ildb_search_async(module,
- req->op.search.base,
- req->op.search.scope,
- req->op.search.tree,
- req->op.search.attrs,
- req->controls,
- req->async.context,
- req->async.callback,
- req->async.timeout,
- &req->async.handle);
-
- case LDB_ASYNC_ADD:
- return ildb_add_async(module,
- req->op.add.message,
- req->async.context,
- req->async.callback,
- req->async.timeout,
- &req->async.handle);
-
- case LDB_ASYNC_MODIFY:
- return ildb_modify_async(module,
- req->op.mod.message,
- req->async.context,
- req->async.callback,
- req->async.timeout,
- &req->async.handle);
-
- case LDB_ASYNC_DELETE:
- return ildb_delete_async(module,
- req->op.del.dn,
- req->async.context,
- req->async.callback,
- req->async.timeout,
- &req->async.handle);
-
- case LDB_ASYNC_RENAME:
- return ildb_rename_async(module,
- req->op.rename.olddn,
- req->op.rename.newdn,
- req->async.context,
- req->async.callback,
- req->async.timeout,
- &req->async.handle);
-
default:
return -1;
static const struct ldb_module_ops ildb_ops = {
.name = "ldap",
+ .search = ildb_search_async,
+ .add = ildb_add_async,
+ .modify = ildb_modify_async,
+ .del = ildb_delete_async,
+ .rename = ildb_rename_async,
.request = ildb_request,
.start_transaction = ildb_start_trans,
.end_transaction = ildb_end_trans,
/*
search for matching records
*/
-static int lldb_search_async(struct ldb_module *module, const struct ldb_dn *base,
- enum ldb_scope scope, struct ldb_parse_tree *tree,
- const char * const *attrs,
- struct ldb_control **control_req,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- int timeout,
- struct ldb_async_handle **handle)
+static int lldb_search_async(struct ldb_module *module, struct ldb_request *req)
{
struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
struct lldb_async_context *lldb_ac;
char *expression;
int ret;
- if (!callback || !context) {
+ if (!req->async.callback || !req->async.context) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Async interface called with NULL callback function or NULL context"));
return LDB_ERR_OPERATIONS_ERROR;
}
- if (tree == NULL) {
+ if (req->op.search.tree == NULL) {
ldb_set_errstring(module->ldb, talloc_asprintf(module, "Invalid expression parse tree"));
return LDB_ERR_OPERATIONS_ERROR;
}
- if (control_req != NULL) {
+ if (req->controls != NULL) {
ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Controls are not yet supported by ldb_ldap backend!\n");
}
- *handle = init_handle(lldb, module, context, callback, timeout);
- if (*handle == NULL) {
- talloc_free(*handle);
+ req->async.handle = init_handle(lldb, module, req->async.context, req->async.callback, req->async.timeout);
+ if (req->async.handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- lldb_ac = talloc_get_type((*handle)->private_data, struct lldb_async_context);
+ lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_async_context);
- search_base = ldb_dn_linearize(lldb_ac, base);
- if (base == NULL) {
+ search_base = ldb_dn_linearize(lldb_ac, req->op.search.base);
+ if (req->op.search.base == NULL) {
search_base = talloc_strdup(lldb_ac, "");
}
if (search_base == NULL) {
- talloc_free(*handle);
return LDB_ERR_OPERATIONS_ERROR;
}
- expression = ldb_filter_from_tree(lldb_ac, tree);
+ expression = ldb_filter_from_tree(lldb_ac, req->op.search.tree);
if (expression == NULL) {
- talloc_free(*handle);
return LDB_ERR_OPERATIONS_ERROR;
}
- switch (scope) {
+ switch (req->op.search.scope) {
case LDB_SCOPE_BASE:
ldap_scope = LDAP_SCOPE_BASE;
break;
break;
}
- tv.tv_sec = timeout;
+ tv.tv_sec = req->async.timeout;
tv.tv_usec = 0;
ret = ldap_search_ext(lldb->ldap, search_base, ldap_scope,
expression,
- discard_const_p(char *, attrs),
+ discard_const_p(char *, req->op.search.attrs),
0,
NULL,
NULL,
if (ret != LDAP_SUCCESS) {
ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(ret)));
- talloc_free(*handle);
- *handle = NULL;
}
return lldb_ldap_to_ldb(ret);
struct ldb_result **res)
{
struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
- struct ldb_async_handle *handle;
+ struct ldb_request *req;
int ret;
*res = talloc_zero(lldb, struct ldb_result);
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = lldb_search_async(module, base, scope, tree, attrs, control_req,
- res, &lldb_search_sync_callback, lldb->timeout, &handle);
+ req = talloc_zero(lldb, struct ldb_request);
+ if (! req) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ req->operation = LDB_ASYNC_SEARCH;
+ req->op.search.base = base;
+ req->op.search.scope = scope;
+ req->op.search.tree = tree;
+ req->op.search.attrs = attrs;
+ req->controls = control_req;
+ req->async.context = (void *)res;
+ req->async.callback = lldb_search_sync_callback;
+ req->async.timeout = lldb->timeout;
+
+ ret = lldb_search_async(module, req);
if (ret == LDB_SUCCESS) {
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
- talloc_free(handle);
+ ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
+ talloc_free(req);
}
if (ret != LDB_SUCCESS) {
/*
add a record
*/
-static int lldb_add_async(struct ldb_module *module, const struct ldb_message *msg,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- int timeout,
- struct ldb_async_handle **handle)
+static int lldb_add_async(struct ldb_module *module, struct ldb_request *req)
{
struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
struct lldb_async_context *lldb_ac;
int ret;
/* ltdb specials should not reach this point */
- if (ldb_dn_is_special(msg->dn)) {
+ if (ldb_dn_is_special(req->op.add.message->dn)) {
return LDB_ERR_INVALID_DN_SYNTAX;
}
- *handle = init_handle(lldb, module, context, callback, timeout);
- if (*handle == NULL) {
+ req->async.handle = init_handle(lldb, module, req->async.context, req->async.callback, req->async.timeout);
+ if (req->async.handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- lldb_ac = talloc_get_type((*handle)->private_data, struct lldb_async_context);
+ lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_async_context);
- mods = lldb_msg_to_mods(lldb_ac, msg, 0);
+ mods = lldb_msg_to_mods(lldb_ac, req->op.add.message, 0);
if (mods == NULL) {
- talloc_free(*handle);
return LDB_ERR_OPERATIONS_ERROR;
}
- dn = ldb_dn_linearize(lldb_ac, msg->dn);
+ dn = ldb_dn_linearize(lldb_ac, req->op.add.message->dn);
if (dn == NULL) {
- talloc_free(*handle);
return LDB_ERR_OPERATIONS_ERROR;
}
if (ret != LDAP_SUCCESS) {
ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(ret)));
- talloc_free(*handle);
}
return lldb_ldap_to_ldb(ret);
static int lldb_add(struct ldb_module *module, const struct ldb_message *msg)
{
struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
- struct ldb_async_handle *handle;
+ struct ldb_request *req;
int ret;
- /* ldap does not understand ltdb specials */
- if (ldb_dn_is_special(msg->dn)) {
- return LDB_SUCCESS;
+ req = talloc_zero(lldb, struct ldb_request);
+ if (! req) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
- ret = lldb_add_async(module, msg, NULL, NULL, lldb->timeout, &handle);
+ req->operation = LDB_ASYNC_ADD;
+ req->op.add.message = msg;
+ req->controls = NULL;
+ req->async.context = NULL;
+ req->async.callback = NULL;
+ req->async.timeout = lldb->timeout;
+
+ ret = lldb_add_async(module, req);
- if (ret != LDB_SUCCESS)
+ if (ret != LDB_SUCCESS) {
+ talloc_free(req);
return ret;
+ }
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
+ ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
- talloc_free(handle);
+ talloc_free(req);
return ret;
}
/*
modify a record
*/
-static int lldb_modify_async(struct ldb_module *module, const struct ldb_message *msg,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- int timeout,
- struct ldb_async_handle **handle)
+static int lldb_modify_async(struct ldb_module *module, struct ldb_request *req)
{
struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
struct lldb_async_context *lldb_ac;
int ret;
/* ltdb specials should not reach this point */
- if (ldb_dn_is_special(msg->dn)) {
+ if (ldb_dn_is_special(req->op.mod.message->dn)) {
return LDB_ERR_INVALID_DN_SYNTAX;
}
- *handle = init_handle(lldb, module, context, callback, timeout);
- if (*handle == NULL) {
+ req->async.handle = init_handle(lldb, module, req->async.context, req->async.callback, req->async.timeout);
+ if (req->async.handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- lldb_ac = talloc_get_type((*handle)->private_data, struct lldb_async_context);
+ lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_async_context);
- mods = lldb_msg_to_mods(lldb_ac, msg, 1);
+ mods = lldb_msg_to_mods(lldb_ac, req->op.mod.message, 1);
if (mods == NULL) {
- talloc_free(*handle);
return LDB_ERR_OPERATIONS_ERROR;
}
- dn = ldb_dn_linearize(lldb_ac, msg->dn);
+ dn = ldb_dn_linearize(lldb_ac, req->op.mod.message->dn);
if (dn == NULL) {
- talloc_free(*handle);
return LDB_ERR_OPERATIONS_ERROR;
}
if (ret != LDAP_SUCCESS) {
ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(ret)));
- talloc_free(*handle);
}
return lldb_ldap_to_ldb(ret);
static int lldb_modify(struct ldb_module *module, const struct ldb_message *msg)
{
struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
- struct ldb_async_handle *handle;
+ struct ldb_request *req;
int ret;
- /* ldap does not understand ltdb specials */
- if (ldb_dn_is_special(msg->dn)) {
- return LDB_SUCCESS;
+ req = talloc_zero(lldb, struct ldb_request);
+ if (! req) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
- ret = lldb_modify_async(module, msg, NULL, NULL, lldb->timeout, &handle);
+ req->operation = LDB_ASYNC_MODIFY;
+ req->op.mod.message = msg;
+ req->controls = NULL;
+ req->async.context = NULL;
+ req->async.callback = NULL;
+ req->async.timeout = lldb->timeout;
+
+ ret = lldb_modify_async(module, req);
- if (ret != LDB_SUCCESS)
+ if (ret != LDB_SUCCESS) {
+ talloc_free(req);
return ret;
+ }
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
+ ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
- talloc_free(handle);
+ talloc_free(req);
return ret;
}
/*
delete a record
*/
-static int lldb_delete_async(struct ldb_module *module, const struct ldb_dn *dn,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- int timeout,
- struct ldb_async_handle **handle)
+static int lldb_delete_async(struct ldb_module *module, struct ldb_request *req)
{
struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
struct lldb_async_context *lldb_ac;
int ret;
/* ltdb specials should not reach this point */
- if (ldb_dn_is_special(dn)) {
+ if (ldb_dn_is_special(req->op.del.dn)) {
return LDB_ERR_INVALID_DN_SYNTAX;
}
- *handle = init_handle(lldb, module, context, callback, timeout);
- if (*handle == NULL) {
+ req->async.handle = init_handle(lldb, module, req->async.context, req->async.callback, req->async.timeout);
+ if (req->async.handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- lldb_ac = talloc_get_type((*handle)->private_data, struct lldb_async_context);
+ lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_async_context);
- dnstr = ldb_dn_linearize(lldb_ac, dn);
+ dnstr = ldb_dn_linearize(lldb_ac, req->op.del.dn);
ret = ldap_delete_ext(lldb->ldap, dnstr,
NULL,
if (ret != LDAP_SUCCESS) {
ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(ret)));
- talloc_free(*handle);
}
return lldb_ldap_to_ldb(ret);
static int lldb_delete(struct ldb_module *module, const struct ldb_dn *dn)
{
struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
- struct ldb_async_handle *handle;
+ struct ldb_request *req;
int ret;
- /* ignore ltdb specials */
- if (ldb_dn_is_special(dn)) {
- return LDB_SUCCESS;
+ req = talloc_zero(lldb, struct ldb_request);
+ if (! req) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
- ret = lldb_delete_async(module, dn, NULL, NULL, lldb->timeout, &handle);
+ req->operation = LDB_ASYNC_DELETE;
+ req->op.del.dn = dn;
+ req->controls = NULL;
+ req->async.context = NULL;
+ req->async.callback = NULL;
+ req->async.timeout = lldb->timeout;
- if (ret != LDB_SUCCESS)
+ ret = lldb_delete_async(module, req);
+
+ if (ret != LDB_SUCCESS) {
+ talloc_free(req);
return ret;
+ }
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
+ ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
- talloc_free(handle);
+ talloc_free(req);
return ret;
}
/*
rename a record
*/
-static int lldb_rename_async(struct ldb_module *module,
- const struct ldb_dn *olddn, const struct ldb_dn *newdn,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- int timeout,
- struct ldb_async_handle **handle)
+static int lldb_rename_async(struct ldb_module *module, struct ldb_request *req)
{
struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
struct lldb_async_context *lldb_ac;
int ret;
/* ltdb specials should not reach this point */
- if (ldb_dn_is_special(olddn) || ldb_dn_is_special(newdn)) {
+ if (ldb_dn_is_special(req->op.rename.olddn) || ldb_dn_is_special(req->op.rename.newdn)) {
return LDB_ERR_INVALID_DN_SYNTAX;
}
- *handle = init_handle(lldb, module, context, callback, timeout);
- if (*handle == NULL) {
+ req->async.handle = init_handle(lldb, module, req->async.context, req->async.callback, req->async.timeout);
+ if (req->async.handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- lldb_ac = talloc_get_type((*handle)->private_data, struct lldb_async_context);
+ lldb_ac = talloc_get_type(req->async.handle->private_data, struct lldb_async_context);
- old_dn = ldb_dn_linearize(lldb_ac, olddn);
+ old_dn = ldb_dn_linearize(lldb_ac, req->op.rename.olddn);
if (old_dn == NULL) {
- talloc_free(*handle);
return LDB_ERR_OPERATIONS_ERROR;
}
newrdn = talloc_asprintf(lldb_ac, "%s=%s",
- newdn->components[0].name,
- ldb_dn_escape_value(lldb, newdn->components[0].value));
+ req->op.rename.newdn->components[0].name,
+ ldb_dn_escape_value(lldb, req->op.rename.newdn->components[0].value));
if (!newrdn) {
- talloc_free(*handle);
return LDB_ERR_OPERATIONS_ERROR;
}
- parentdn = ldb_dn_linearize(lldb_ac, ldb_dn_get_parent(lldb_ac, newdn));
+ parentdn = ldb_dn_linearize(lldb_ac, ldb_dn_get_parent(lldb_ac, req->op.rename.newdn));
if (!parentdn) {
- talloc_free(*handle);
return LDB_ERR_OPERATIONS_ERROR;
}
if (ret != LDAP_SUCCESS) {
ldb_set_errstring(module->ldb, talloc_strdup(module, ldap_err2string(ret)));
- talloc_free(*handle);
}
return lldb_ldap_to_ldb(ret);
static int lldb_rename(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
{
struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
- struct ldb_async_handle *handle;
+ struct ldb_request *req;
int ret;
- /* ignore ltdb specials */
- if (ldb_dn_is_special(olddn) || ldb_dn_is_special(newdn)) {
- return LDB_SUCCESS;
+ req = talloc_zero(lldb, struct ldb_request);
+ if (! req) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
- ret = lldb_rename_async(module, olddn, newdn, NULL, NULL, lldb->timeout, &handle);
+ req->operation = LDB_ASYNC_RENAME;
+ req->op.rename.olddn = olddn;
+ req->op.rename.newdn = newdn;
+ req->controls = NULL;
+ req->async.context = NULL;
+ req->async.callback = NULL;
+ req->async.timeout = lldb->timeout;
+
+ ret = lldb_rename_async(module, req);
- if (ret != LDB_SUCCESS)
+ if (ret != LDB_SUCCESS) {
+ talloc_free(req);
return ret;
+ }
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
+ ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
- talloc_free(handle);
+ talloc_free(req);
return ret;
}
req->op.rename.olddn,
req->op.rename.newdn);
- case LDB_ASYNC_SEARCH:
- return lldb_search_async(module,
- req->op.search.base,
- req->op.search.scope,
- req->op.search.tree,
- req->op.search.attrs,
- req->controls,
- req->async.context,
- req->async.callback,
- req->async.timeout,
- &req->async.handle);
-
- case LDB_ASYNC_ADD:
- return lldb_add_async(module,
- req->op.add.message,
- req->async.context,
- req->async.callback,
- req->async.timeout,
- &req->async.handle);
-
- case LDB_ASYNC_MODIFY:
- return lldb_modify_async(module,
- req->op.mod.message,
- req->async.context,
- req->async.callback,
- req->async.timeout,
- &req->async.handle);
-
- case LDB_ASYNC_DELETE:
- return lldb_delete_async(module,
- req->op.del.dn,
- req->async.context,
- req->async.callback,
- req->async.timeout,
- &req->async.handle);
-
- case LDB_ASYNC_RENAME:
- return lldb_rename_async(module,
- req->op.rename.olddn,
- req->op.rename.newdn,
- req->async.context,
- req->async.callback,
- req->async.timeout,
- &req->async.handle);
-
default:
return -1;
static const struct ldb_module_ops lldb_ops = {
.name = "ldap",
+ .search = lldb_search_async,
+ .add = lldb_add_async,
+ .modify = lldb_modify_async,
+ .del = lldb_delete_async,
+ .rename = lldb_rename_async,
.request = lldb_request,
.start_transaction = lldb_start_trans,
.end_transaction = lldb_end_trans,
return LDB_ERR_OPERATIONS_ERROR;
}
-int ltdb_search_async(struct ldb_module *module, const struct ldb_dn *base,
- enum ldb_scope scope, struct ldb_parse_tree *tree,
- const char * const *attrs,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- struct ldb_async_handle **handle)
+int ltdb_search_async(struct ldb_module *module, struct ldb_request *req)
{
struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
struct ltdb_async_context *ltdb_ac;
int ret;
- if ((base == NULL || base->comp_num == 0) &&
- (scope == LDB_SCOPE_BASE || scope == LDB_SCOPE_ONELEVEL))
+ if ((req->op.search.base == NULL || req->op.search.base->comp_num == 0) &&
+ (req->op.search.scope == LDB_SCOPE_BASE || req->op.search.scope == LDB_SCOPE_ONELEVEL))
return LDB_ERR_OPERATIONS_ERROR;
if (ltdb_lock_read(module) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
}
- if (tree == NULL) {
+ if (req->op.search.tree == NULL) {
ltdb_unlock_read(module);
return LDB_ERR_OPERATIONS_ERROR;
}
- *handle = init_ltdb_handle(ltdb, module, context, callback);
- if (*handle == NULL) {
+ req->async.handle = init_ltdb_handle(ltdb, module, req->async.context, req->async.callback);
+ if (req->async.handle == NULL) {
ltdb_unlock_read(module);
return LDB_ERR_OPERATIONS_ERROR;
}
- ltdb_ac = talloc_get_type((*handle)->private_data, struct ltdb_async_context);
+ ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_async_context);
- ltdb_ac->tree = tree;
- ltdb_ac->scope = scope;
- ltdb_ac->base = base;
- ltdb_ac->attrs = attrs;
+ ltdb_ac->tree = req->op.search.tree;
+ ltdb_ac->scope = req->op.search.scope;
+ ltdb_ac->base = req->op.search.base;
+ ltdb_ac->attrs = req->op.search.attrs;
- ret = ltdb_search_indexed(*handle);
+ ret = ltdb_search_indexed(req->async.handle);
if (ret == -1) {
- ret = ltdb_search_full(*handle);
+ ret = ltdb_search_full(req->async.handle);
}
if (ret != LDB_SUCCESS) {
ldb_set_errstring(module->ldb, talloc_strdup(module->ldb, "Indexed and full searches both failed!\n"));
- (*handle)->state = LDB_ASYNC_DONE;
- (*handle)->status = ret;
+ req->async.handle->state = LDB_ASYNC_DONE;
+ req->async.handle->status = ret;
}
ltdb_unlock_read(module);
enum ldb_scope scope, struct ldb_parse_tree *tree,
const char * const attrs[], struct ldb_result **res)
{
- struct ldb_async_handle *handle;
+ struct ldb_request *req;
int ret;
*res = talloc_zero(module, struct ldb_result);
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ltdb_search_async(module, base, scope, tree, attrs,
- res, <db_search_sync_callback,
- &handle);
+ req = talloc_zero(module, struct ldb_request);
+ if (! req) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ req->operation = LDB_ASYNC_SEARCH;
+ req->op.search.base = base;
+ req->op.search.scope = scope;
+ req->op.search.tree = tree;
+ req->op.search.attrs = attrs;
+ req->controls = NULL;
+ req->async.context = (void *)res;
+ req->async.callback = ltdb_search_sync_callback;
+
+ ret = ltdb_search_async(module, req);
if (ret == LDB_SUCCESS) {
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
- talloc_free(handle);
+ ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
+ talloc_free(req);
}
if (ret != LDB_SUCCESS) {
/*
add a record to the database
*/
-static int ltdb_add_async(struct ldb_module *module, const struct ldb_message *msg,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- struct ldb_async_handle **handle)
+static int ltdb_add_async(struct ldb_module *module, struct ldb_request *req)
{
struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
struct ltdb_async_context *ltdb_ac;
int tret, ret = LDB_SUCCESS;
- *handle = init_ltdb_handle(ltdb, module, context, callback);
- if (*handle == NULL) {
+ req->async.handle = init_ltdb_handle(ltdb, module, req->async.context, req->async.callback);
+ if (req->async.handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ltdb_ac = talloc_get_type((*handle)->private_data, struct ltdb_async_context);
+ ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_async_context);
- tret = ltdb_check_special_dn(module, msg);
+ tret = ltdb_check_special_dn(module, req->op.add.message);
if (tret != LDB_SUCCESS) {
- (*handle)->status = tret;
+ req->async.handle->status = tret;
goto done;
}
goto done;
}
- tret = ltdb_store(module, msg, TDB_INSERT);
+ tret = ltdb_store(module, req->op.add.message, TDB_INSERT);
if (tret != LDB_SUCCESS) {
- (*handle)->status = tret;
+ req->async.handle->status = tret;
goto done;
}
- ltdb_modified(module, msg->dn);
+ ltdb_modified(module, req->op.add.message->dn);
if (ltdb_ac->callback) {
ret = ltdb_ac->callback(module->ldb, ltdb_ac->context, NULL);
}
done:
- (*handle)->state = LDB_ASYNC_DONE;
+ req->async.handle->state = LDB_ASYNC_DONE;
return ret;
}
static int ltdb_add(struct ldb_module *module, const struct ldb_message *msg)
{
- struct ldb_async_handle *handle;
+ struct ldb_request *req;
int ret;
- ret = ltdb_add_async(module, msg, NULL, NULL, &handle);
+ req = talloc_zero(module, struct ldb_request);
+ if (! req) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ req->operation = LDB_ASYNC_ADD;
+ req->op.add.message = msg;
+ req->controls = NULL;
+ req->async.context = NULL;
+ req->async.callback = NULL;
- if (ret != LDB_SUCCESS)
+ ret = ltdb_add_async(module, req);
+
+ if (ret != LDB_SUCCESS) {
+ talloc_free(req);
return ret;
+ }
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
+ ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
- talloc_free(handle);
+ talloc_free(req);
return ret;
}
/*
delete a record from the database
*/
-static int ltdb_delete_async(struct ldb_module *module, const struct ldb_dn *dn,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- struct ldb_async_handle **handle)
+static int ltdb_delete_async(struct ldb_module *module, struct ldb_request *req)
{
struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
struct ltdb_async_context *ltdb_ac;
struct ldb_message *msg;
int tret, ret = LDB_SUCCESS;
- *handle = NULL;
+ req->async.handle = NULL;
if (ltdb_cache_load(module) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
}
- *handle = init_ltdb_handle(ltdb, module, context, callback);
- if (*handle == NULL) {
+ req->async.handle = init_ltdb_handle(ltdb, module, req->async.context, req->async.callback);
+ if (req->async.handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ltdb_ac = talloc_get_type((*handle)->private_data, struct ltdb_async_context);
+ ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_async_context);
msg = talloc(ltdb_ac, struct ldb_message);
if (msg == NULL) {
/* in case any attribute of the message was indexed, we need
to fetch the old record */
- tret = ltdb_search_dn1(module, dn, msg);
+ tret = ltdb_search_dn1(module, req->op.del.dn, msg);
if (tret != 1) {
/* not finding the old record is an error */
- (*handle)->status = LDB_ERR_NO_SUCH_OBJECT;
+ req->async.handle->status = LDB_ERR_NO_SUCH_OBJECT;
goto done;
}
- tret = ltdb_delete_noindex(module, dn);
+ tret = ltdb_delete_noindex(module, req->op.del.dn);
if (tret != LDB_SUCCESS) {
- (*handle)->status = LDB_ERR_NO_SUCH_OBJECT;
+ req->async.handle->status = LDB_ERR_NO_SUCH_OBJECT;
goto done;
}
/* remove any indexed attributes */
tret = ltdb_index_del(module, msg);
if (tret != LDB_SUCCESS) {
- (*handle)->status = LDB_ERR_NO_SUCH_OBJECT;
+ req->async.handle->status = LDB_ERR_NO_SUCH_OBJECT;
goto done;
}
- ltdb_modified(module, dn);
+ ltdb_modified(module, req->op.del.dn);
if (ltdb_ac->callback)
ret = ltdb_ac->callback(module->ldb, ltdb_ac->context, NULL);
done:
- (*handle)->state = LDB_ASYNC_DONE;
+ req->async.handle->state = LDB_ASYNC_DONE;
return ret;
}
static int ltdb_delete(struct ldb_module *module, const struct ldb_dn *dn)
{
- struct ldb_async_handle *handle;
+ struct ldb_request *req;
int ret;
- ret = ltdb_delete_async(module, dn, NULL, NULL, &handle);
+ req = talloc_zero(module, struct ldb_request);
+ if (! req) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ req->operation = LDB_ASYNC_DELETE;
+ req->op.del.dn = dn;
+ req->controls = NULL;
+ req->async.context = NULL;
+ req->async.callback = NULL;
+
+ ret = ltdb_delete_async(module, req);
- if (ret != LDB_SUCCESS)
+ if (ret != LDB_SUCCESS) {
+ talloc_free(req);
return ret;
+ }
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
+ ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
- talloc_free(handle);
+ talloc_free(req);
return ret;
}
/*
modify a record
*/
-static int ltdb_modify_async(struct ldb_module *module, const struct ldb_message *msg,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- struct ldb_async_handle **handle)
+static int ltdb_modify_async(struct ldb_module *module, struct ldb_request *req)
{
struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
struct ltdb_async_context *ltdb_ac;
int tret, ret = LDB_SUCCESS;
- *handle = NULL;
+ req->async.handle = NULL;
- *handle = init_ltdb_handle(ltdb, module, context, callback);
- if (*handle == NULL) {
+ req->async.handle = init_ltdb_handle(ltdb, module, req->async.context, req->async.callback);
+ if (req->async.handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ltdb_ac = talloc_get_type((*handle)->private_data, struct ltdb_async_context);
+ ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_async_context);
- tret = ltdb_check_special_dn(module, msg);
+ tret = ltdb_check_special_dn(module, req->op.mod.message);
if (tret != LDB_SUCCESS) {
- (*handle)->status = tret;
+ req->async.handle->status = tret;
goto done;
}
goto done;
}
- tret = ltdb_modify_internal(module, msg);
+ tret = ltdb_modify_internal(module, req->op.mod.message);
if (tret != LDB_SUCCESS) {
- (*handle)->status = tret;
+ req->async.handle->status = tret;
goto done;
}
- ltdb_modified(module, msg->dn);
+ ltdb_modified(module, req->op.mod.message->dn);
if (ltdb_ac->callback)
ret = ltdb_ac->callback(module->ldb, ltdb_ac->context, NULL);
done:
- (*handle)->state = LDB_ASYNC_DONE;
+ req->async.handle->state = LDB_ASYNC_DONE;
return ret;
}
static int ltdb_modify(struct ldb_module *module, const struct ldb_message *msg)
{
- struct ldb_async_handle *handle;
+ struct ldb_request *req;
int ret;
- ret = ltdb_modify_async(module, msg, NULL, NULL, &handle);
+ req = talloc_zero(module, struct ldb_request);
+ if (! req) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ req->operation = LDB_ASYNC_MODIFY;
+ req->op.mod.message = msg;
+ req->controls = NULL;
+ req->async.context = NULL;
+ req->async.callback = NULL;
+
+ ret = ltdb_modify_async(module, req);
- if (ret != LDB_SUCCESS)
+ if (ret != LDB_SUCCESS) {
+ talloc_free(req);
return ret;
+ }
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
+ ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
- talloc_free(handle);
+ talloc_free(req);
return ret;
}
/*
rename a record
*/
-static int ltdb_rename_async(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- struct ldb_async_handle **handle)
+static int ltdb_rename_async(struct ldb_module *module, struct ldb_request *req)
{
struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
struct ltdb_async_context *ltdb_ac;
struct ldb_message *msg;
int tret, ret = LDB_SUCCESS;
- *handle = NULL;
+ req->async.handle = NULL;
if (ltdb_cache_load(module) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
}
- *handle = init_ltdb_handle(ltdb, module, context, callback);
- if (*handle == NULL) {
+ req->async.handle = init_ltdb_handle(ltdb, module, req->async.context, req->async.callback);
+ if (req->async.handle == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ltdb_ac = talloc_get_type((*handle)->private_data, struct ltdb_async_context);
+ ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_async_context);
msg = talloc(ltdb_ac, struct ldb_message);
if (msg == NULL) {
/* in case any attribute of the message was indexed, we need
to fetch the old record */
- tret = ltdb_search_dn1(module, olddn, msg);
+ tret = ltdb_search_dn1(module, req->op.rename.olddn, msg);
if (tret != 1) {
/* not finding the old record is an error */
- (*handle)->status = LDB_ERR_NO_SUCH_OBJECT;
+ req->async.handle->status = LDB_ERR_NO_SUCH_OBJECT;
goto done;
}
- msg->dn = ldb_dn_copy(msg, newdn);
+ msg->dn = ldb_dn_copy(msg, req->op.rename.newdn);
if (!msg->dn) {
ret = LDB_ERR_OPERATIONS_ERROR;
goto done;
goto done;
}
- tret = ltdb_delete(module, olddn);
+ tret = ltdb_delete(module, req->op.rename.olddn);
if (tret != LDB_SUCCESS) {
- ltdb_delete(module, newdn);
+ ltdb_delete(module, req->op.rename.newdn);
ret = LDB_ERR_OPERATIONS_ERROR;
goto done;
}
ret = ltdb_ac->callback(module->ldb, ltdb_ac->context, NULL);
done:
- (*handle)->state = LDB_ASYNC_DONE;
+ req->async.handle->state = LDB_ASYNC_DONE;
return ret;
}
static int ltdb_rename(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
{
- struct ldb_async_handle *handle;
+ struct ldb_request *req;
int ret;
- ret = ltdb_rename_async(module, olddn, newdn, NULL, NULL, &handle);
+ req = talloc_zero(module, struct ldb_request);
+ if (! req) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
- if (ret != LDB_SUCCESS)
+ req->operation = LDB_ASYNC_RENAME;
+ req->op.rename.olddn = olddn;
+ req->op.rename.newdn = newdn;
+ req->controls = NULL;
+ req->async.context = NULL;
+ req->async.callback = NULL;
+
+ ret = ltdb_rename_async(module, req);
+
+ if (ret != LDB_SUCCESS) {
+ talloc_free(req);
return ret;
+ }
- ret = ldb_async_wait(handle, LDB_WAIT_ALL);
+ ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
- talloc_free(handle);
+ talloc_free(req);
return ret;
}
req->op.rename.olddn,
req->op.rename.newdn);
- case LDB_ASYNC_SEARCH:
- return ltdb_search_async(module,
- req->op.search.base,
- req->op.search.scope,
- req->op.search.tree,
- req->op.search.attrs,
- req->async.context,
- req->async.callback,
- &req->async.handle);
-
- case LDB_ASYNC_ADD:
- return ltdb_add_async(module,
- req->op.add.message,
- req->async.context,
- req->async.callback,
- &req->async.handle);
-
- case LDB_ASYNC_MODIFY:
- return ltdb_modify_async(module,
- req->op.mod.message,
- req->async.context,
- req->async.callback,
- &req->async.handle);
-
- case LDB_ASYNC_DELETE:
- return ltdb_delete_async(module,
- req->op.del.dn,
- req->async.context,
- req->async.callback,
- &req->async.handle);
-
- case LDB_ASYNC_RENAME:
- return ltdb_rename_async(module,
- req->op.rename.olddn,
- req->op.rename.newdn,
- req->async.context,
- req->async.callback,
- &req->async.handle);
-
default:
return LDB_ERR_OPERATIONS_ERROR;
static const struct ldb_module_ops ltdb_ops = {
.name = "tdb",
+ .search = ltdb_search_async,
+ .add = ltdb_add_async,
+ .modify = ltdb_modify_async,
+ .del = ltdb_delete_async,
+ .rename = ltdb_rename_async,
.request = ltdb_request,
.start_transaction = ltdb_start_trans,
.end_transaction = ltdb_end_trans,
unsigned int *count,
struct ldb_message ***res);
int ltdb_filter_attrs(struct ldb_message *msg, const char * const *attrs);
-int ltdb_search_async(struct ldb_module *module, const struct ldb_dn *base,
- enum ldb_scope scope, struct ldb_parse_tree *tree,
- const char * const *attrs,
- void *context,
- int (*callback)(struct ldb_context *, void *, struct ldb_async_result *),
- struct ldb_async_handle **handle);
+int ltdb_search_async(struct ldb_module *module, struct ldb_request *req);
int ltdb_search_bytree(struct ldb_module *module, const struct ldb_dn *base,
enum ldb_scope scope, struct ldb_parse_tree *tree,
const char * const attrs[], struct ldb_result **res);
}
/* search */
-static int asq_search(struct ldb_module *module, struct ldb_control *control, struct ldb_request *req)
+static int asq_search_sync(struct ldb_module *module, struct ldb_control *control, struct ldb_request *req)
{
struct ldb_asq_control *asq_ctrl;
struct ldb_request *base_req;
return LDB_ERR_OPERATIONS_ERROR;
}
-static int asq_search_async(struct ldb_module *module, struct ldb_control *control, struct ldb_request *req)
+static int asq_search(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_control *control;
struct ldb_asq_control *asq_ctrl;
struct asq_async_context *ac;
struct ldb_async_handle *h;
char **base_attrs;
int ret;
+ /* check if there's a paged request control */
+ control = get_control_from_list(req->controls, LDB_CONTROL_ASQ_OID);
+ if (control == NULL) {
+ /* not found go on */
+ return ldb_next_request(module, req);
+ }
+
req->async.handle = NULL;
if (!req->async.callback || !req->async.context) {
switch (req->operation) {
case LDB_REQ_SEARCH:
- return asq_search(module, control, req);
+ return asq_search_sync(module, control, req);
- case LDB_ASYNC_SEARCH:
- return asq_search_async(module, control, req);
-
default:
return LDB_ERR_PROTOCOL_ERROR;
static const struct ldb_module_ops asq_ops = {
.name = "asq",
+ .search = asq_search,
.request = asq,
.async_wait = asq_async_wait,
.init_context = asq_init
/*
hook add record ops
*/
-static int operational_add(struct ldb_module *module, struct ldb_request *req)
+static int operational_add_sync(struct ldb_module *module, struct ldb_request *req)
{
const struct ldb_message *msg = req->op.add.message;
time_t t = time(NULL);
/*
hook modify record ops
*/
-static int operational_modify(struct ldb_module *module, struct ldb_request *req)
+static int operational_modify_sync(struct ldb_module *module, struct ldb_request *req)
{
const struct ldb_message *msg = req->op.mod.message;
time_t t = time(NULL);
return LDB_ERR_OPERATIONS_ERROR;
}
-static int operational_search_async(struct ldb_module *module, struct ldb_request *req)
+static int operational_search(struct ldb_module *module, struct ldb_request *req)
{
struct operational_async_context *ac;
struct ldb_request *down_req;
/*
hook add record ops
*/
-static int operational_add_async(struct ldb_module *module, struct ldb_request *req)
+static int operational_add(struct ldb_module *module, struct ldb_request *req)
{
struct ldb_request *down_req;
struct ldb_message *msg;
/*
hook modify record ops
*/
-static int operational_modify_async(struct ldb_module *module, struct ldb_request *req)
+static int operational_modify(struct ldb_module *module, struct ldb_request *req)
{
struct ldb_request *down_req;
struct ldb_message *msg;
return operational_search_bytree(module, req);
case LDB_REQ_ADD:
- return operational_add(module, req);
+ return operational_add_sync(module, req);
case LDB_REQ_MODIFY:
- return operational_modify(module, req);
-
- case LDB_ASYNC_SEARCH:
- return operational_search_async(module, req);
-
- case LDB_ASYNC_ADD:
- return operational_add_async(module, req);
-
- case LDB_ASYNC_MODIFY:
- return operational_modify_async(module, req);
+ return operational_modify_sync(module, req);
default:
return ldb_next_request(module, req);
static const struct ldb_module_ops operational_ops = {
.name = "operational",
+ .search = operational_search,
+ .add = operational_add,
+ .modify = operational_modify,
.request = operational_request,
.init_context = operational_init
};
}
/* search */
-static int paged_search(struct ldb_module *module, struct ldb_control *control, struct ldb_request *req)
+static int paged_search_sync(struct ldb_module *module, struct ldb_control *control, struct ldb_request *req)
{
struct private_data *private_data = talloc_get_type(module->private_data, struct private_data);
struct results_store *current = NULL;
return LDB_ERR_OPERATIONS_ERROR;
}
-static int paged_search_async(struct ldb_module *module, struct ldb_control *control, struct ldb_request *req)
+static int paged_search(struct ldb_module *module, struct ldb_request *req)
{
- struct private_data *private_data = talloc_get_type(module->private_data, struct private_data);
+ struct ldb_control *control;
+ struct private_data *private_data;
struct ldb_paged_control *paged_ctrl;
struct ldb_control **saved_controls;
struct paged_async_context *ac;
struct ldb_async_handle *h;
int ret;
+ /* check if there's a paged request control */
+ control = get_control_from_list(req->controls, LDB_CONTROL_PAGED_RESULTS_OID);
+ if (control == NULL) {
+ /* not found go on */
+ return ldb_next_request(module, req);
+ }
+
+ private_data = talloc_get_type(module->private_data, struct private_data);
+
req->async.handle = NULL;
if (!req->async.callback || !req->async.context) {
}
-static int paged_async_results(struct ldb_async_handle *handle)
+static int paged_results(struct ldb_async_handle *handle)
{
struct paged_async_context *ac;
struct ldb_paged_control *paged;
if (ac->store->req->async.handle->state == LDB_ASYNC_DONE) {
/* if lower level is finished we do not need to call it anymore */
/* return all we have until size == 0 or we empty storage */
- ret = paged_async_results(handle);
+ ret = paged_results(handle);
/* we are done, if num_entries is zero free the storage
* as that mean we delivered the last batch */
}
}
- ret = paged_async_results(handle);
+ ret = paged_results(handle);
/* we are done, if num_entries is zero free the storage
* as that mean we delivered the last batch */
if (ac->store->num_entries >= ac->size ||
ac->store->req->async.handle->state == LDB_ASYNC_DONE) {
- ret = paged_async_results(handle);
+ ret = paged_results(handle);
/* we are done, if num_entries is zero free the storage
* as that mean we delivered the last batch */
switch (req->operation) {
case LDB_REQ_SEARCH:
- return paged_search(module, control, req);
-
- case LDB_ASYNC_SEARCH:
- return paged_search_async(module, control, req);
+ return paged_search_sync(module, control, req);
default:
return LDB_ERR_PROTOCOL_ERROR;
}
static const struct ldb_module_ops paged_ops = {
- .name = "paged_results",
+ .name = "paged_results",
+ .search = paged_search,
.request = paged_request,
.async_wait = paged_async_wait,
.init_context = paged_request_init
ac->step = RENAME_MODIFY;
/* do the mod call */
- return ldb_next_request(h->module, ac->mod_req);
+ return ldb_request(h->module->ldb, ac->mod_req);
}
static int rename_async_wait(struct ldb_async_handle *handle)
case LDB_REQ_ADD:
return rdn_name_add_sync(module, req);
- case LDB_ASYNC_ADD:
- return rdn_name_add(module, req);
-
- case LDB_ASYNC_RENAME:
- return rdn_name_rename(module, req);
-
default:
return ldb_next_request(module, req);
static const struct ldb_module_ops rdn_name_ops = {
.name = "rdn_name",
+ .add = rdn_name_add,
+ .rename = rdn_name_rename,
.request = rdn_name_request,
.async_wait = rdn_name_async_wait
};
static int skel_request(struct ldb_module *module, struct ldb_request *req)
{
- switch (req->operation) {
-
- case LDB_REQ_SEARCH:
- return skel_search(module, req);
-
- case LDB_REQ_ADD:
- return skel_add(module, req);
-
- case LDB_REQ_MODIFY:
- return skel_modify(module, req);
-
- case LDB_REQ_DELETE:
- return skel_delete(module, req);
-
- case LDB_REQ_RENAME:
- return skel_rename(module,
- req);
-
- default:
- return ldb_next_request(module, req);
-
- }
+ return ldb_next_request(module, req);
}
static int skel_init(struct ldb_module *ctx)
static const struct ldb_module_ops skel_ops = {
.name = "skel",
.init_context = skel_init,
+ .search = skel_search,
+ .add = skel_add,
+ .modify = skel_modify,
+ .del = skel_delete,
+ .rename = skel_rename,
.request = skel_request,
.start_transaction = skel_start_trans,
.end_transaction = skel_end_trans,
return LDB_ERR_OPERATIONS_ERROR;
}
-static int server_sort_search_async(struct ldb_module *module, struct ldb_control *control, struct ldb_request *req)
+static int server_sort_search_async(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_control *control;
struct ldb_server_sort_control **sort_ctrls;
struct ldb_control **saved_controls;
struct sort_async_context *ac;
struct ldb_async_handle *h;
int ret;
+ /* check if there's a paged request control */
+ control = get_control_from_list(req->controls, LDB_CONTROL_SERVER_SORT_OID);
+ if (control == NULL) {
+ /* not found go on */
+ return ldb_next_request(module, req);
+ }
+
req->async.handle = NULL;
if (!req->async.callback || !req->async.context) {
case LDB_REQ_SEARCH:
return server_sort_search(module, control, req);
- case LDB_ASYNC_SEARCH:
- return server_sort_search_async(module, control, req);
-
default:
return LDB_ERR_PROTOCOL_ERROR;
static const struct ldb_module_ops server_sort_ops = {
.name = "server_sort",
+ .search = server_sort_search_async,
.request = server_sort,
.async_wait = server_sort_async_wait,
.init_context = server_sort_init
#include "system/network.h"
#include "netif/netif.h"
-/* add_record: do things with the sambaPassword attribute */
-static int wins_ldb_verify(struct ldb_module *module, struct ldb_request *req, const struct ldb_message *msg)
+static int wins_ldb_verify(struct ldb_module *module, struct ldb_request *req)
{
struct winsdb_handle *h = talloc_get_type(ldb_get_opaque(module->ldb, "winsdb_handle"),
struct winsdb_handle);
+ const struct ldb_message *msg;
char *error = NULL;
+ switch (req->operation) {
+ case LDB_REQ_ADD:
+ case LDB_ASYNC_ADD:
+ msg = req->op.add.message;
+ break;
+
+ case LDB_REQ_MODIFY:
+ case LDB_ASYNC_MODIFY:
+ msg = req->op.mod.message;
+ break;
+
+ default:
+ return ldb_next_request(module, req);
+ }
+
/* do not manipulate our control entries */
if (ldb_dn_is_special(msg->dn)) {
return ldb_next_request(module, req);
static int wins_ldb_request(struct ldb_module *module, struct ldb_request *req)
{
- const struct ldb_message *msg;
-
switch (req->operation) {
case LDB_REQ_ADD:
- case LDB_ASYNC_ADD:
-
- msg = req->op.add.message;
- break;
-
case LDB_REQ_MODIFY:
- case LDB_ASYNC_MODIFY:
-
- msg = req->op.mod.message;
- break;
-
+ return wins_ldb_verify(module, req);
default:
return ldb_next_request(module, req);
}
-
- return wins_ldb_verify(module, req, msg);
}
static const struct ldb_module_ops wins_ldb_ops = {
.name = "wins_ldb",
+ .add = wins_ldb_verify,
+ .modify = wins_ldb_verify,
.request = wins_ldb_request,
.init_context = wins_ldb_init
};