summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/modules
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2006-05-29 23:46:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:08:43 -0500
commit0c7b82e5f6063de4114de21cf854ac67346e31f6 (patch)
treecc66c4f23e7029eae3be6edaf09d194d71016d47 /source4/lib/ldb/modules
parent787d67c2cd780656cb5e6c0884c485f287b72c49 (diff)
downloadsamba-0c7b82e5f6063de4114de21cf854ac67346e31f6.tar.gz
samba-0c7b82e5f6063de4114de21cf854ac67346e31f6.tar.bz2
samba-0c7b82e5f6063de4114de21cf854ac67346e31f6.zip
r15942: Remove the sync internal ldb calls altogether.
This means that some modules have been disabled as well as they have not been ported to the async interface One of them is the ugly objectclass module. I hope that the change in samldb module will make the MMC happy without the need of this crappy module, we need proper handling in a decent schema module. proxy and ldb_map have also been disabled ldb_sqlite3 need to be ported as well (currenlty just broken). (This used to be commit 51083de795bdcbf649de926e86969adc20239b6d)
Diffstat (limited to 'source4/lib/ldb/modules')
-rw-r--r--source4/lib/ldb/modules/asq.c169
-rw-r--r--source4/lib/ldb/modules/operational.c180
-rw-r--r--source4/lib/ldb/modules/paged_results.c152
-rw-r--r--source4/lib/ldb/modules/rdn_name.c93
-rw-r--r--source4/lib/ldb/modules/sort.c119
5 files changed, 6 insertions, 707 deletions
diff --git a/source4/lib/ldb/modules/asq.c b/source4/lib/ldb/modules/asq.c
index 884616abdd..005d1e41b0 100644
--- a/source4/lib/ldb/modules/asq.c
+++ b/source4/lib/ldb/modules/asq.c
@@ -41,152 +41,6 @@
#define ASQ_CTRL_UNWILLING_TO_PERFORM 53
#define ASQ_CTRL_AFFECTS_MULTIPLE_DSA 71
-static int build_response(struct ldb_result *res, int result)
-{
- struct ldb_asq_control *asq;
- int i;
-
- if (res->controls) {
- for (i = 0; res->controls[i]; i++);
- res->controls = talloc_realloc(res, res->controls, struct ldb_control *, i + 2);
- } else {
- i = 0;
- res->controls = talloc_array(res, struct ldb_control *, 2);
- }
- if (res->controls == NULL)
- return LDB_ERR_OPERATIONS_ERROR;
-
- res->controls[i] = talloc(res->controls, struct ldb_control);
- if (res->controls[i] == NULL)
- return LDB_ERR_OPERATIONS_ERROR;
-
- res->controls[i]->oid = LDB_CONTROL_ASQ_OID;
- res->controls[i]->critical = 0;
-
- asq = talloc_zero(res->controls[i], struct ldb_asq_control);
- if (asq == NULL)
- return LDB_ERR_OPERATIONS_ERROR;
-
- asq->result = result;
-
- res->controls[i]->data = asq;
-
- res->controls[i + 1] = NULL;
-
- return LDB_SUCCESS;
-}
-
-/* search */
-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;
- struct ldb_message_element *el;
- struct ldb_result *res;
- char **base_attrs;
- int i, c, ret;
-
- /* pre-allocate a clean result structure */
- req->op.search.res = res = talloc_zero(req, struct ldb_result);
- if (res == NULL)
- return LDB_ERR_OPERATIONS_ERROR;
-
- /* check the search is well formed */
- if (req->op.search.scope != LDB_SCOPE_BASE) {
- return build_response(res, ASQ_CTRL_UNWILLING_TO_PERFORM);
- }
-
- asq_ctrl = talloc_get_type(control->data, struct ldb_asq_control);
- if (!asq_ctrl) {
- return LDB_ERR_PROTOCOL_ERROR;
- }
-
- /* get the object to retrieve the DNs to search */
- base_req = talloc_zero(req, struct ldb_request);
- if (base_req == NULL)
- return LDB_ERR_OPERATIONS_ERROR;
- base_req->operation = LDB_REQ_SEARCH;
- base_req->op.search.base = req->op.search.base;
- base_req->op.search.scope = LDB_SCOPE_BASE;
- base_req->op.search.tree = req->op.search.tree;
- base_attrs = talloc_array(base_req, char *, 2);
- if (base_attrs == NULL)
- return LDB_ERR_OPERATIONS_ERROR;
- base_attrs[0] = talloc_strdup(base_attrs, asq_ctrl->source_attribute);
- if (base_attrs[0] == NULL)
- return LDB_ERR_OPERATIONS_ERROR;
- base_attrs[1] = NULL;
- base_req->op.search.attrs = (const char * const *)base_attrs;
-
- ret = ldb_request(module->ldb, base_req);
-
- if (ret != LDB_SUCCESS) {
- talloc_free(base_req);
- return ret;
- }
-
- if (base_req->op.search.res->count == 0) {
- talloc_free(base_req);
- return build_response(res, ASQ_CTRL_SUCCESS);
- }
-
- /* look up the DNs */
- el = ldb_msg_find_element(base_req->op.search.res->msgs[0],
- asq_ctrl->source_attribute);
- /* no values found */
- if (el == NULL) {
- talloc_free(base_req);
- return build_response(res, ASQ_CTRL_SUCCESS);
- }
-
- for (i = 0, c = 0; i < el->num_values; i++) {
- struct ldb_request *exp_req;
-
- exp_req = talloc_zero(req, struct ldb_request);
- if (exp_req == NULL)
- return LDB_ERR_OPERATIONS_ERROR;
- exp_req->operation = LDB_REQ_SEARCH;
- exp_req->op.search.base = ldb_dn_explode(exp_req, (const char *)el->values[i].data);
- if (exp_req->op.search.base == NULL) {
- return build_response(res, ASQ_CTRL_INVALID_ATTRIBUTE_SYNTAX);
- }
- exp_req->op.search.scope = LDB_SCOPE_BASE;
- exp_req->op.search.tree = req->op.search.tree;
- exp_req->op.search.attrs = req->op.search.attrs;
-
- ret = ldb_request(module->ldb, exp_req);
-
- if (ret != LDB_SUCCESS)
- return ret;
-
- if (exp_req->op.search.res && exp_req->op.search.res->count != 0) {
- if (res->msgs == NULL) {
- res->msgs = talloc_array(res,
- struct ldb_message *, 2);
- } else {
- res->msgs = talloc_realloc(res, res->msgs,
- struct ldb_message *, c + 2);
- }
- if (res->msgs == NULL)
- return LDB_ERR_OPERATIONS_ERROR;
-
- res->msgs[c] = talloc_steal(res->msgs, exp_req->op.search.res->msgs[0]);
- c++;
- }
-
- if (res->msgs) {
- res->msgs[c] = NULL;
- res->count = c;
- }
-
- talloc_free(exp_req);
- }
-
- talloc_free(base_req);
-
- return build_response(res, ASQ_CTRL_SUCCESS);
-}
-
struct asq_async_context {
enum {ASQ_SEARCH_BASE, ASQ_SEARCH_MULTI} step;
@@ -580,28 +434,6 @@ static int asq_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_t
}
}
-static int asq(struct ldb_module *module, struct ldb_request *req)
-{
- struct ldb_control *control;
-
- /* 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);
- }
-
- switch (req->operation) {
-
- case LDB_REQ_SEARCH:
- return asq_search_sync(module, control, req);
-
- default:
- return LDB_ERR_PROTOCOL_ERROR;
-
- }
-}
-
static int asq_init(struct ldb_module *module)
{
struct ldb_request request;
@@ -624,7 +456,6 @@ static int asq_init(struct ldb_module *module)
static const struct ldb_module_ops asq_ops = {
.name = "asq",
.search = asq_search,
- .request = asq,
.async_wait = asq_async_wait,
.init_context = asq_init
};
diff --git a/source4/lib/ldb/modules/operational.c b/source4/lib/ldb/modules/operational.c
index 084105fd85..4b1daba30f 100644
--- a/source4/lib/ldb/modules/operational.c
+++ b/source4/lib/ldb/modules/operational.c
@@ -170,76 +170,6 @@ failed:
}
/*
- hook search operations
-*/
-static int operational_search_bytree(struct ldb_module *module, struct ldb_request *req)
-{
- int i, r, a;
- int ret;
- const char * const *attrs = req->op.search.attrs;
- const char **search_attrs = NULL;
-
- req->op.search.res = NULL;
-
- /* replace any attributes in the parse tree that are
- searchable, but are stored using a different name in the
- backend */
- for (i=0;i<ARRAY_SIZE(parse_tree_sub);i++) {
- ldb_parse_tree_attr_replace(req->op.search.tree,
- parse_tree_sub[i].attr,
- parse_tree_sub[i].replace);
- }
-
- /* in the list of attributes we are looking for, rename any
- attributes to the alias for any hidden attributes that can
- be fetched directly using non-hidden names */
- for (a=0;attrs && attrs[a];a++) {
- for (i=0;i<ARRAY_SIZE(search_sub);i++) {
- if (ldb_attr_cmp(attrs[a], search_sub[i].attr) == 0 &&
- search_sub[i].replace) {
- if (!search_attrs) {
- search_attrs = ldb_attr_list_copy(req, attrs);
- if (search_attrs == NULL) {
- goto failed;
- }
- }
- search_attrs[a] = search_sub[i].replace;
- }
- }
- }
-
- /* use new set of attrs if any */
- if (search_attrs) req->op.search.attrs = search_attrs;
- /* perform the search */
- ret = ldb_next_request(module, req);
- /* set back saved attrs if needed */
- if (search_attrs) req->op.search.attrs = attrs;
-
- /* check operation result */
- if (ret != LDB_SUCCESS) {
- return ret;
- }
-
- /* for each record returned post-process to add any derived
- attributes that have been asked for */
- for (r = 0; r < req->op.search.res->count; r++) {
- if (operational_search_post_process(module, req->op.search.res->msgs[r], attrs) != 0) {
- goto failed;
- }
- }
-
- /* all done */
- talloc_free(search_attrs);
- return ret;
-
-failed:
- talloc_free(search_attrs);
- talloc_free(req->op.search.res);
- ldb_oom(module->ldb);
- return LDB_ERR_OTHER;
-}
-
-/*
add a time element to a record
*/
static int add_time_element(struct ldb_message *msg, const char *attr, time_t t)
@@ -293,95 +223,6 @@ static int add_uint64_element(struct ldb_message *msg, const char *attr, uint64_
/*
- hook add record ops
-*/
-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);
- struct ldb_message *msg2;
- int ret;
-
- if (ldb_dn_is_special(msg->dn)) {
- return ldb_next_request(module, req);
- }
-
- /* we have to copy the message as the caller might have it as a const */
- msg2 = ldb_msg_copy_shallow(module, msg);
- if (msg2 == NULL) {
- return -1;
- }
- if (add_time_element(msg2, "whenCreated", t) != 0 ||
- add_time_element(msg2, "whenChanged", t) != 0) {
- talloc_free(msg2);
- return -1;
- }
-
- /* see if the backend can give us the USN */
- if (module->ldb->sequence_number != NULL) {
- uint64_t seq_num = module->ldb->sequence_number(module->ldb);
- if (add_uint64_element(msg2, "uSNCreated", seq_num) != 0 ||
- add_uint64_element(msg2, "uSNChanged", seq_num) != 0) {
- talloc_free(msg2);
- return -1;
- }
- }
-
- /* use the new structure for the call chain below this point */
- req->op.add.message = msg2;
- /* go on with the call chain */
- ret = ldb_next_request(module, req);
- /* put back saved message */
- req->op.add.message = msg;
- /* free temproary compy */
- talloc_free(msg2);
- return ret;
-}
-
-/*
- hook modify record ops
-*/
-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);
- struct ldb_message *msg2;
- int ret;
-
- if (ldb_dn_is_special(msg->dn)) {
- return ldb_next_request(module, req);
- }
-
- /* we have to copy the message as the caller might have it as a const */
- msg2 = ldb_msg_copy_shallow(module, msg);
- if (msg2 == NULL) {
- return -1;
- }
- if (add_time_element(msg2, "whenChanged", t) != 0) {
- talloc_free(msg2);
- return -1;
- }
-
- /* update the records USN if possible */
- if (module->ldb->sequence_number != NULL &&
- add_uint64_element(msg2, "uSNChanged",
- module->ldb->sequence_number(module->ldb)) != 0) {
- talloc_free(msg2);
- return -1;
- }
-
- /* use the new structure for the call chain below this point */
- req->op.mod.message = msg2;
- /* go on with the call chain */
- ret = ldb_next_request(module, req);
- /* put back saved message */
- req->op.mod.message = msg;
- /* free temproary compy */
- talloc_free(msg2);
- return ret;
-}
-
-/*
hook search operations
*/
@@ -607,26 +448,6 @@ static int operational_modify(struct ldb_module *module, struct ldb_request *req
return ret;
}
-
-static int operational_request(struct ldb_module *module, struct ldb_request *req)
-{
- switch (req->operation) {
-
- case LDB_REQ_SEARCH:
- return operational_search_bytree(module, req);
-
- case LDB_REQ_ADD:
- return operational_add_sync(module, req);
-
- case LDB_REQ_MODIFY:
- return operational_modify_sync(module, req);
-
- default:
- return ldb_next_request(module, req);
-
- }
-}
-
static int operational_init(struct ldb_module *ctx)
{
/* setup some standard attribute handlers */
@@ -643,7 +464,6 @@ static const struct ldb_module_ops operational_ops = {
.search = operational_search,
.add = operational_add,
.modify = operational_modify,
- .request = operational_request,
.init_context = operational_init
};
diff --git a/source4/lib/ldb/modules/paged_results.c b/source4/lib/ldb/modules/paged_results.c
index 71b99184a1..6d864375c6 100644
--- a/source4/lib/ldb/modules/paged_results.c
+++ b/source4/lib/ldb/modules/paged_results.c
@@ -122,135 +122,6 @@ static struct results_store *new_store(struct private_data *priv)
return new;
}
-/* search */
-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;
- struct ldb_result *paged_result;
- struct ldb_control **saved_controls;
- struct ldb_paged_control *paged_ctrl;
- struct ldb_paged_control *paged_ret;
- int i, ret;
-
- paged_ctrl = talloc_get_type(control->data, struct ldb_paged_control);
- if (!paged_ctrl) {
- return LDB_ERR_PROTOCOL_ERROR;
- }
-
- /* check if it is a continuation search the store */
- if (paged_ctrl->cookie_len != 0) {
- for (current = private_data->store; current; current = current->next) {
- if (strcmp(current->cookie, paged_ctrl->cookie) == 0) {
- current->timestamp = time(NULL);
- break;
- }
- }
- if (current == NULL) {
- return LDB_ERR_UNWILLING_TO_PERFORM;
- }
- }
-
- /* is this a brand new paged request ? */
- if (current == NULL) {
-
- /* save controls list and remove this one from the list */
- if (!save_controls(control, req, &saved_controls)) {
- return LDB_ERR_OTHER;
- }
-
- /* perform the search */
- ret = ldb_next_request(module, req);
-
- /* restore original controls list */
- if (req->controls) talloc_free(req->controls);
- req->controls = saved_controls;
-
- if (ret != LDB_SUCCESS) {
- return ret;
- }
-
- /* create a new entry in the cache */
- current = new_store(private_data);
- if (!current) {
- return LDB_ERR_OTHER;
- }
-
- /* steal the search result */
- current->result = talloc_steal(current, req->op.search.res);
- req->op.search.res = NULL;
- }
-
- /* create a container for the next batch of results */
- paged_result = talloc(current, struct ldb_result);
- if (!paged_result) {
- return LDB_ERR_OTHER;
- }
- paged_result->count = 0;
- paged_result->msgs = NULL;
- paged_result->controls = NULL;
-
- /* check if it is an abandon */
- if (paged_ctrl->size == 0) {
- req->op.search.res = talloc_steal(private_data, paged_result);
- talloc_free(current);
- return LDB_SUCCESS;
- }
-
- /* return a batch of results */
-
- paged_result->controls = talloc_array(paged_result, struct ldb_control *, 2);
- if (!paged_result->controls) {
- talloc_free(paged_result);
- return LDB_ERR_OTHER;
- }
-
- paged_result->controls[0] = talloc(paged_result->controls, struct ldb_control);
- if (!paged_result->controls[0]) {
- talloc_free(paged_result);
- return LDB_ERR_OTHER;
- }
- paged_result->controls[0]->oid = talloc_strdup(paged_result->controls[0], LDB_CONTROL_PAGED_RESULTS_OID);
- paged_result->controls[0]->critical = 0;
- paged_result->controls[1] = NULL;
-
- paged_ret = talloc(paged_result->controls[0], struct ldb_paged_control);
- if (!paged_ret) {
- talloc_free(paged_result);
- return LDB_ERR_OTHER;
- }
- paged_result->controls[0]->data = paged_ret;
-
- if (paged_ctrl->size >= current->result->count) {
- paged_ret->size = 0;
- paged_ret->cookie = NULL;
- paged_ret->cookie_len = 0;
- paged_result->count = current->result->count;
- current->result->count = 0;
- } else {
- paged_ret->size = current->result->count;
- paged_ret->cookie = talloc_strdup(paged_ret, current->cookie);
- paged_ret->cookie_len = strlen(paged_ret->cookie) + 1;
- paged_result->count = paged_ctrl->size;
- current->result->count -= paged_ctrl->size;
- }
-
- paged_result->msgs = talloc_array(paged_result, struct ldb_message *, paged_result->count + 1);
- if (!paged_result->msgs) {
- talloc_free(paged_result);
- return LDB_ERR_OTHER;
- }
- for (i = 0; i < paged_result->count; i++) {
- paged_result->msgs[i] = talloc_steal(paged_result->msgs, current->result->msgs[current->num_sent + i]);
- }
- current->num_sent += paged_result->count;
- paged_result->msgs[paged_result->count] = NULL;
-
- req->op.search.res = paged_result;
-
- return LDB_SUCCESS;
-}
-
struct paged_async_context {
struct ldb_module *module;
void *up_context;
@@ -654,28 +525,6 @@ static int paged_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait
return ret;
}
-static int paged_request(struct ldb_module *module, struct ldb_request *req)
-{
- struct ldb_control *control;
-
- /* 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);
- }
-
- switch (req->operation) {
-
- case LDB_REQ_SEARCH:
- return paged_search_sync(module, control, req);
-
- default:
- return LDB_ERR_PROTOCOL_ERROR;
-
- }
-}
-
static int paged_request_init(struct ldb_module *module)
{
struct private_data *data;
@@ -714,7 +563,6 @@ static int paged_request_init(struct ldb_module *module)
static const struct ldb_module_ops paged_ops = {
.name = "paged_results",
.search = paged_search,
- .request = paged_request,
.async_wait = paged_async_wait,
.init_context = paged_request_init
};
diff --git a/source4/lib/ldb/modules/rdn_name.c b/source4/lib/ldb/modules/rdn_name.c
index 2004002e38..059e7843cd 100644
--- a/source4/lib/ldb/modules/rdn_name.c
+++ b/source4/lib/ldb/modules/rdn_name.c
@@ -53,85 +53,6 @@ static struct ldb_message_element *rdn_name_find_attribute(const struct ldb_mess
return NULL;
}
-static int rdn_name_add_sync(struct ldb_module *module, struct ldb_request *req)
-{
- const struct ldb_message *msg = req->op.add.message;
- struct ldb_message *msg2;
- struct ldb_message_element *attribute;
- struct ldb_dn_component *rdn;
- int i, ret;
-
- ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_add_record\n");
-
- /* do not manipulate our control entries */
- if (ldb_dn_is_special(msg->dn)) {
- return ldb_next_request(module, req);
- }
-
- msg2 = talloc(module, struct ldb_message);
- if (!msg2) {
- return -1;
- }
-
- msg2->dn = msg->dn;
- msg2->num_elements = msg->num_elements;
- msg2->private_data = msg->private_data;
- msg2->elements = talloc_array(msg2, struct ldb_message_element, msg2->num_elements);
- for (i = 0; i < msg2->num_elements; i++) {
- msg2->elements[i] = msg->elements[i];
- }
-
- rdn = ldb_dn_get_rdn(msg2, msg2->dn);
- if (!rdn) {
- talloc_free(msg2);
- return -1;
- }
-
- /* Perhaps someone above us tried to set this? */
- if ((attribute = rdn_name_find_attribute(msg, "name")) != NULL ) {
- attribute->num_values = 0;
- }
-
- if (ldb_msg_add_value(msg2, "name", &rdn->value) != 0) {
- talloc_free(msg2);
- return -1;
- }
-
- attribute = rdn_name_find_attribute(msg2, rdn->name);
-
- if (!attribute) {
- if (ldb_msg_add_value(msg2, rdn->name, &rdn->value) != 0) {
- talloc_free(msg2);
- return -1;
- }
- } else {
- const struct ldb_attrib_handler *handler
- = ldb_attrib_handler(module->ldb, rdn->name);
- for (i=0; i < attribute->num_values; i++) {
- if (handler->comparison_fn(module->ldb, msg2, &rdn->value, &attribute->values[i]) == 0) {
- /* overwrite so it matches in case */
- attribute->values[i] = rdn->value;
- break;
- }
- }
- if (i == attribute->num_values) {
- ldb_debug_set(module->ldb, LDB_DEBUG_FATAL,
- "RDN mismatch on %s: %s",
- ldb_dn_linearize(msg2, msg2->dn), rdn->name);
- talloc_free(msg2);
- return -1;
- }
- }
-
- req->op.add.message = msg2;
- ret = ldb_next_request(module, req);
- req->op.add.message = msg;
-
- talloc_free(msg2);
-
- return ret;
-}
-
static int rdn_name_add(struct ldb_module *module, struct ldb_request *req)
{
struct ldb_request *down_req;
@@ -402,24 +323,10 @@ static int rdn_name_async_wait(struct ldb_async_handle *handle, enum ldb_async_w
}
}
-static int rdn_name_request(struct ldb_module *module, struct ldb_request *req)
-{
- switch (req->operation) {
-
- case LDB_REQ_ADD:
- return rdn_name_add_sync(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
};
diff --git a/source4/lib/ldb/modules/sort.c b/source4/lib/ldb/modules/sort.c
index 6905417e95..2f9d7dfc96 100644
--- a/source4/lib/ldb/modules/sort.c
+++ b/source4/lib/ldb/modules/sort.c
@@ -196,91 +196,7 @@ static int sort_compare_async(struct ldb_message **msg1, struct ldb_message **ms
return ac->h->comparison_fn(ac->module->ldb, ac, &el1->values[0], &el2->values[0]);
}
-/* search */
-static int server_sort_search(struct ldb_module *module, struct ldb_control *control, struct ldb_request *req)
-{
- struct ldb_result *sort_result = NULL;
- struct ldb_control **saved_controls;
- struct ldb_server_sort_control **sort_ctrls;
- int ret, result = 0;
- int do_sort = 1;
-
- sort_ctrls = talloc_get_type(control->data, struct ldb_server_sort_control *);
- if (!sort_ctrls) {
- return LDB_ERR_PROTOCOL_ERROR;
- }
-
- /* FIXME: we do not support more than one attribute for sorting right now */
- /* FIXME: we need to check if the attribute type exist or return an error */
- if (sort_ctrls[1] != NULL)
- do_sort = 0;
-
- if (!do_sort && control->critical) {
- sort_result = talloc_zero(req, struct ldb_result);
- if (!sort_result)
- return LDB_ERR_OPERATIONS_ERROR;
-
- req->op.search.res = sort_result;
-
- /* 53 = unwilling to perform */
- if ((ret = build_response(sort_result, &sort_result->controls, 53, "sort control is not complete yet")) != LDB_SUCCESS) {
- return ret;
- }
-
- return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
- }
-
- /* save it locally and remove it from the list */
- if (!save_controls(control, req, &saved_controls)) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- ret = ldb_next_request(module, req);
-
- if (req->controls) talloc_free(req->controls);
- req->controls = saved_controls;
-
- if (ret != LDB_SUCCESS) {
- return ret;
- }
-
- sort_result = req->op.search.res;
-
- /* SORT HERE */
- if (do_sort) {
- struct opaque *data;
-
- data = talloc(module, struct opaque);
- if (!data)
- return LDB_ERR_OPERATIONS_ERROR;
-
- data->attribute = sort_ctrls[0]->attributeName;
- data->reverse = sort_ctrls[0]->reverse;
- data->ldb = module->ldb;
- data->h = ldb_attrib_handler(data->ldb, data->attribute);
- data->result = 0;
-
- ldb_qsort(sort_result->msgs,
- sort_result->count,
- sizeof(struct ldb_message *),
- data,
- (ldb_qsort_cmp_fn_t)sort_compare);
-
- result = data->result;
-
- talloc_free(data);
- } else {
- result = 53;
- }
-
- if ((ret = build_response(sort_result, &sort_result->controls, result, "sort control is not complete yet")) != LDB_SUCCESS) {
- return ret;
- }
-
- return LDB_SUCCESS;
-}
-
-static int server_sort_search_async_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+static int server_sort_search_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
{
struct sort_async_context *ac = NULL;
@@ -340,7 +256,7 @@ error:
return LDB_ERR_OPERATIONS_ERROR;
}
-static int server_sort_search_async(struct ldb_module *module, struct ldb_request *req)
+static int server_sort_search(struct ldb_module *module, struct ldb_request *req)
{
struct ldb_control *control;
struct ldb_server_sort_control **sort_ctrls;
@@ -425,7 +341,7 @@ static int server_sort_search_async(struct ldb_module *module, struct ldb_reques
}
ac->req->async.context = ac;
- ac->req->async.callback = server_sort_search_async_callback;
+ ac->req->async.callback = server_sort_search_callback;
ac->req->async.timeout = req->async.timeout;
req->async.handle = h;
@@ -433,7 +349,7 @@ static int server_sort_search_async(struct ldb_module *module, struct ldb_reques
return ldb_next_request(module, ac->req);
}
-static int server_sort_async_results(struct ldb_async_handle *handle)
+static int server_sort_results(struct ldb_async_handle *handle)
{
struct sort_async_context *ac;
struct ldb_async_result *ares;
@@ -527,34 +443,12 @@ static int server_sort_async_wait(struct ldb_async_handle *handle, enum ldb_asyn
}
if (handle->state == LDB_ASYNC_DONE) {
- ret = server_sort_async_results(handle);
+ ret = server_sort_results(handle);
}
return ret;
}
-static int server_sort(struct ldb_module *module, struct ldb_request *req)
-{
- struct ldb_control *control;
-
- /* 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);
- }
-
- switch (req->operation) {
-
- case LDB_REQ_SEARCH:
- return server_sort_search(module, control, req);
-
- default:
- return LDB_ERR_PROTOCOL_ERROR;
-
- }
-}
-
static int server_sort_init(struct ldb_module *module)
{
struct ldb_request *req;
@@ -582,8 +476,7 @@ static int server_sort_init(struct ldb_module *module)
static const struct ldb_module_ops server_sort_ops = {
.name = "server_sort",
- .search = server_sort_search_async,
- .request = server_sort,
+ .search = server_sort_search,
.async_wait = server_sort_async_wait,
.init_context = server_sort_init
};