summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb/common/ldb.c26
-rw-r--r--source4/lib/ldb/config.mk50
-rw-r--r--source4/lib/ldb/include/ldb.h5
-rw-r--r--source4/lib/ldb/ldb_ildap/ldb_ildap.c363
-rw-r--r--source4/lib/ldb/ldb_ldap/ldb_ldap.c296
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_search.c95
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.c313
-rw-r--r--source4/lib/ldb/ldb_tdb/ldb_tdb.h6
-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
13 files changed, 234 insertions, 1633 deletions
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 28b9728d0a..5fbaf54920 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -273,35 +273,16 @@ static int ldb_op_finish(struct ldb_context *ldb, int status)
/*
start an ldb request
- autostarts a transacion if none active and the operation is not a search
- does not work for ASYNC operations
NOTE: the request must be a talloc context.
returns LDB_ERR_* on errors.
*/
int ldb_request(struct ldb_context *ldb, struct ldb_request *req)
{
struct ldb_module *module;
- int ret, started_transaction=0;
+ int ret;
ldb_reset_err_string(ldb);
- if (req->operation == LDB_REQ_SEARCH) {
- req->op.search.res = NULL;
- }
-
- /* 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)) {
- ret = ldb_transaction_start(ldb);
- if (ret != LDB_SUCCESS) {
- return ret;
- }
- started_transaction = 1;
- }
-
/* call the first module in the chain */
switch (req->operation) {
case LDB_ASYNC_SEARCH:
@@ -330,10 +311,6 @@ int ldb_request(struct ldb_context *ldb, struct ldb_request *req)
break;
}
- if (started_transaction) {
- return ldb_op_finish(ldb, ret);
- }
-
return ret;
}
@@ -463,6 +440,7 @@ int ldb_search(struct ldb_context *ldb,
return ret;
}
+/* autostarts a transacion if none active */
static int ldb_autotransaction_request(struct ldb_context *ldb, struct ldb_request *req)
{
int ret, close_transaction;
diff --git a/source4/lib/ldb/config.mk b/source4/lib/ldb/config.mk
index 54fba24555..68dbdd10f0 100644
--- a/source4/lib/ldb/config.mk
+++ b/source4/lib/ldb/config.mk
@@ -38,15 +38,15 @@ OBJ_FILES = \
# End MODULE ldb_operational
################################################
-################################################
-# Start MODULE ldb_objectclass
-[MODULE::ldb_objectclass]
-INIT_FUNCTION = ldb_objectclass_init
-SUBSYSTEM = ldb
-OBJ_FILES = \
- modules/objectclass.o
-# End MODULE ldb_objectclass
-################################################
+# ################################################
+# # Start MODULE ldb_objectclass
+# [MODULE::ldb_objectclass]
+# INIT_FUNCTION = ldb_objectclass_init
+# SUBSYSTEM = ldb
+# OBJ_FILES = \
+# modules/objectclass.o
+# # End MODULE ldb_objectclass
+# ################################################
################################################
# Start MODULE ldb_rdn_name
@@ -58,15 +58,15 @@ OBJ_FILES = \
# End MODULE ldb_rdn_name
################################################
-################################################
-# Start MODULE ldb_schema
-[MODULE::ldb_schema]
-INIT_FUNCTION = ldb_schema_init
-SUBSYSTEM = ldb
-OBJ_FILES = \
- modules/schema.o
-# End MODULE ldb_schema
-################################################
+# ################################################
+# # Start MODULE ldb_schema
+# [MODULE::ldb_schema]
+# INIT_FUNCTION = ldb_schema_init
+# SUBSYSTEM = ldb
+# OBJ_FILES = \
+# modules/schema.o
+# # End MODULE ldb_schema
+# ################################################
################################################
# Start MODULE ldb_ildap
@@ -81,13 +81,13 @@ PUBLIC_DEPENDENCIES = \
# End MODULE ldb_ildap
################################################
-################################################
-# Start MODULE ldb_map
-[SUBSYSTEM::ldb_map]
-PUBLIC_DEPENDENCIES = ldb
-OBJ_FILES = modules/ldb_map.o
-# End MODULE ldb_map
-################################################
+# ################################################
+# # Start MODULE ldb_map
+# [SUBSYSTEM::ldb_map]
+# PUBLIC_DEPENDENCIES = ldb
+# OBJ_FILES = modules/ldb_map.o
+# # End MODULE ldb_map
+# ################################################
################################################
# Start MODULE ldb_skel
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index 8f21aec046..8e61ccd73c 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -562,11 +562,6 @@ struct ldb_control {
};
enum ldb_request_type {
- LDB_REQ_SEARCH,
- LDB_REQ_ADD,
- LDB_REQ_MODIFY,
- LDB_REQ_DELETE,
- LDB_REQ_RENAME,
LDB_ASYNC_SEARCH,
LDB_ASYNC_ADD,
LDB_ASYNC_MODIFY,
diff --git a/source4/lib/ldb/ldb_ildap/ldb_ildap.c b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
index 1454b565e0..3bb431e34f 100644
--- a/source4/lib/ldb/ldb_ildap/ldb_ildap.c
+++ b/source4/lib/ldb/ldb_ildap/ldb_ildap.c
@@ -148,7 +148,7 @@ static void ildb_request_timeout(struct event_context *ev, struct timed_event *t
return;
}
-static void ildb_async_callback(struct ldap_request *req)
+static void ildb_callback(struct ldap_request *req)
{
struct ldb_async_handle *handle = talloc_get_type(req->async.private_data, struct ldb_async_handle);
struct ildb_async_context *ac = talloc_get_type(handle->private_data, struct ildb_async_context);
@@ -365,7 +365,7 @@ static int ildb_request_send(struct ldb_module *module, struct ldap_message *msg
ildb_ac->context = context;
ildb_ac->callback = callback;
- req->async.fn = ildb_async_callback;
+ req->async.fn = ildb_callback;
req->async.private_data = (void *)h;
talloc_free(req->time_event);
@@ -385,7 +385,7 @@ static int ildb_request_send(struct ldb_module *module, struct ldap_message *msg
/*
search for matching records using an asynchronous function
*/
-static int ildb_search_async(struct ldb_module *module, struct ldb_request *req)
+static int ildb_search(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;
@@ -447,122 +447,10 @@ static int ildb_search_async(struct ldb_module *module, struct ldb_request *req)
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;
- int n;
-
- if (!context) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context in callback"));
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- res = *((struct ldb_result **)context);
-
- if (!res || !ares) {
- goto error;
- }
-
- if (ares->type == LDB_REPLY_ENTRY) {
- res->msgs = talloc_realloc(res, res->msgs, struct ldb_message *, res->count + 2);
- if (! res->msgs) {
- goto error;
- }
-
- res->msgs[res->count + 1] = NULL;
-
- res->msgs[res->count] = talloc_steal(res->msgs, ares->message);
- if (! res->msgs[res->count]) {
- goto error;
- }
-
- res->count++;
- }
-
- if (ares->type == LDB_REPLY_REFERRAL) {
- if (res->refs) {
- for (n = 0; res->refs[n]; n++) /*noop*/ ;
- } else {
- n = 0;
- }
-
- res->refs = talloc_realloc(res, res->refs, char *, n + 2);
- if (! res->refs) {
- goto error;
- }
-
- res->refs[n] = talloc_steal(res->refs, ares->referral);
- res->refs[n + 1] = NULL;
- }
-
- if (ares->controls) {
- res->controls = talloc_steal(res, ares->controls);
- if (! res->controls) {
- goto error;
- }
- }
-
- talloc_free(ares);
- return LDB_SUCCESS;
-
-error:
- talloc_free(ares);
- talloc_free(res);
- *((struct ldb_result **)context) = NULL;
- return LDB_ERR_OPERATIONS_ERROR;
-}
-
-/*
- search for matching records using a synchronous function
- */
-static int ildb_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_control **control_req,
- struct ldb_result **res)
-{
- struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
- struct ldb_request *req;
- int ret;
-
- *res = talloc_zero(ildb, struct ldb_result);
- if (! *res) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- 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(req->async.handle, LDB_WAIT_ALL);
- talloc_free(req);
- }
-
- if (ret != LDB_SUCCESS) {
- talloc_free(*res);
- }
-
- return ret;
-}
-
/*
add a record
*/
-static int ildb_add_async(struct ldb_module *module, struct ldb_request *req)
+static int ildb_add(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;
@@ -609,41 +497,10 @@ static int ildb_add_async(struct ldb_module *module, struct ldb_request *req)
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_request *req;
- int ret;
-
- 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) {
- talloc_free(req);
- return ret;
- }
-
- ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
-
- talloc_free(req);
- return ret;
-}
-
/*
modify a record
*/
-static int ildb_modify_async(struct ldb_module *module, struct ldb_request *req)
+static int ildb_modify(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;
@@ -694,41 +551,10 @@ static int ildb_modify_async(struct ldb_module *module, struct ldb_request *req)
&(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_request *req;
- int ret;
-
- 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) {
- talloc_free(req);
- return ret;
- }
-
- ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
-
- talloc_free(req);
- return ret;
-}
-
/*
delete a record
*/
-static int ildb_delete_async(struct ldb_module *module, struct ldb_request *req)
+static int ildb_delete(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;
@@ -760,41 +586,10 @@ static int ildb_delete_async(struct ldb_module *module, struct ldb_request *req)
&(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_request *req;
- int ret;
-
- req = talloc_zero(ildb, 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;
- 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(req->async.handle, LDB_WAIT_ALL);
-
- talloc_free(req);
- return ret;
-}
-
/*
rename a record
*/
-static int ildb_rename_async(struct ldb_module *module, struct ldb_request *req)
+static int ildb_rename(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;
@@ -844,90 +639,30 @@ static int ildb_rename_async(struct ldb_module *module, struct ldb_request *req)
&(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_request *req;
- int ret;
-
- 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;
-
- ret = ildb_rename_async(module, req);
-
- if (ret != LDB_SUCCESS) {
- talloc_free(req);
- return ret;
- }
-
- ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
-
- talloc_free(req);
- return ret;
-}
-
static int ildb_start_trans(struct ldb_module *module)
{
/* TODO implement a local locking mechanism here */
- return 0;
+ return LDB_SUCCESS;
}
static int ildb_end_trans(struct ldb_module *module)
{
/* TODO implement a local transaction mechanism here */
- return 0;
+ return LDB_SUCCESS;
}
static int ildb_del_trans(struct ldb_module *module)
{
/* TODO implement a local locking mechanism here */
- return 0;
+ return LDB_SUCCESS;
}
static int ildb_request(struct ldb_module *module, struct ldb_request *req)
{
- switch (req->operation) {
-
- case LDB_REQ_SEARCH:
- return ildb_search_bytree(module,
- req->op.search.base,
- req->op.search.scope,
- req->op.search.tree,
- req->op.search.attrs,
- req->controls,
- &req->op.search.res);
-
- case LDB_REQ_ADD:
- return ildb_add(module, req->op.add.message);
-
- case LDB_REQ_MODIFY:
- return ildb_modify(module, req->op.mod.message);
-
- case LDB_REQ_DELETE:
- return ildb_delete(module, req->op.del.dn);
-
- case LDB_REQ_RENAME:
- return ildb_rename(module,
- req->op.rename.olddn,
- req->op.rename.newdn);
-
- default:
- return -1;
-
- }
+ return LDB_ERR_OPERATIONS_ERROR;
}
static int ildb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_type type)
@@ -964,34 +699,80 @@ static int ildb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_
return LDB_SUCCESS;
}
+static int ildb_rootdse_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
+{
+ struct ildb_private *ildb;
+
+ if (!context || !ares) {
+ ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context or Result in callback"));
+ goto error;
+ }
+
+ ildb = talloc_get_type(context, struct ildb_private);
+
+ if (ildb->rootDSE != NULL) {
+ /* what ? more than one rootdse entry ?! */
+ goto error;
+ }
+
+ /* we are interested only in the single reply (rootdse) we receive here */
+ if (ares->type == LDB_REPLY_ENTRY) {
+ ildb->rootDSE = talloc_steal(ildb, ares->message);
+ }
+
+ talloc_free(ares);
+ return LDB_SUCCESS;
+
+error:
+ talloc_free(ares);
+ return LDB_ERR_OPERATIONS_ERROR;
+}
+
/*
fetch the rootDSE for later use
*/
static int ildb_init(struct ldb_module *module)
{
struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
- struct ldb_result *res = NULL;
- struct ldb_dn *empty_dn = ldb_dn_new(ildb);
+ struct ldb_request *req;
int ret;
- ret = ildb_search_bytree(module, empty_dn, LDB_SCOPE_BASE,
- ldb_parse_tree(empty_dn, "dn=dc=rootDSE"),
- NULL, NULL, &res);
- if (ret == LDB_SUCCESS && res->count == 1) {
- ildb->rootDSE = talloc_steal(ildb, res->msgs[0]);
+
+ req = talloc(ildb, struct ldb_request);
+ if (req == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
}
- if (ret == LDB_SUCCESS) talloc_free(res);
- talloc_free(empty_dn);
- return LDB_SUCCESS;
+ ildb->rootDSE = NULL;
+
+ req->operation = LDB_ASYNC_SEARCH;
+ req->op.search.base = ldb_dn_new(req);
+ req->op.search.scope = LDB_SCOPE_BASE;
+ req->op.search.tree = ldb_parse_tree(req, "dn=dc=rootDSE");
+ req->op.search.attrs = NULL;
+ req->controls = NULL;
+ req->async.context = ildb;
+ req->async.callback = ildb_rootdse_callback;
+ req->async.timeout = 60;
+
+ ret = ildb_search(module, req);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(req);
+ return ret;
+ }
+
+ ret = ildb_async_wait(req->async.handle, LDB_WAIT_ALL);
+
+ talloc_free(req);
+ return ret;
}
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,
+ .search = ildb_search,
+ .add = ildb_add,
+ .modify = ildb_modify,
+ .del = ildb_delete,
+ .rename = ildb_rename,
.request = ildb_request,
.start_transaction = ildb_start_trans,
.end_transaction = ildb_end_trans,
diff --git a/source4/lib/ldb/ldb_ldap/ldb_ldap.c b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
index f372e5fd04..5748c2ecd7 100644
--- a/source4/lib/ldb/ldb_ldap/ldb_ldap.c
+++ b/source4/lib/ldb/ldb_ldap/ldb_ldap.c
@@ -224,7 +224,7 @@ static int lldb_add_msg_attr(struct ldb_context *ldb,
/*
search for matching records
*/
-static int lldb_search_async(struct ldb_module *module, struct ldb_request *req)
+static int lldb_search(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;
@@ -300,124 +300,10 @@ static int lldb_search_async(struct ldb_module *module, struct ldb_request *req)
return lldb_ldap_to_ldb(ret);
}
-static int lldb_search_sync_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
-{
- struct ldb_result *res;
- int n;
-
- if (!context) {
- ldb_set_errstring(ldb, talloc_asprintf(ldb, "NULL Context in callback"));
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- res = *((struct ldb_result **)context);
-
- if (!res || !ares) {
- goto error;
- }
-
- if (ares->type == LDB_REPLY_ENTRY) {
- res->msgs = talloc_realloc(res, res->msgs, struct ldb_message *, res->count + 2);
- if (! res->msgs) {
- goto error;
- }
-
- res->msgs[res->count + 1] = NULL;
-
- res->msgs[res->count] = talloc_steal(res->msgs, ares->message);
- if (! res->msgs[res->count]) {
- goto error;
- }
-
- res->count++;
- }
-
- if (ares->type == LDB_REPLY_REFERRAL) {
- if (res->refs) {
- for (n = 0; res->refs[n]; n++) /*noop*/ ;
- } else {
- n = 0;
- }
-
- res->refs = talloc_realloc(res, res->refs, char *, n + 2);
- if (! res->refs) {
- goto error;
- }
-
- res->refs[n] = talloc_steal(res->refs, ares->referral);
- res->refs[n + 1] = NULL;
- }
-
- if (ares->type == LDB_REPLY_DONE) {
- if (ares->controls) {
- res->controls = talloc_steal(res, ares->controls);
- if (! res->controls) {
- goto error;
- }
- }
- }
-
- talloc_free(ares);
- return LDB_SUCCESS;
-
-error:
- talloc_free(ares);
- talloc_free(res);
- *((struct ldb_result **)context) = NULL;
- return LDB_ERR_OPERATIONS_ERROR;
-}
-
-/*
- search for matching records using a synchronous function
- */
-static int lldb_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_control **control_req,
- struct ldb_result **res)
-{
- struct lldb_private *lldb = talloc_get_type(module->private_data, struct lldb_private);
- struct ldb_request *req;
- int ret;
-
- *res = talloc_zero(lldb, struct ldb_result);
- if (! *res) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- 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(req->async.handle, LDB_WAIT_ALL);
- talloc_free(req);
- }
-
- if (ret != LDB_SUCCESS) {
- talloc_free(*res);
- }
-
- return ret;
-}
-
/*
add a record
*/
-static int lldb_add_async(struct ldb_module *module, struct ldb_request *req)
+static int lldb_add(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;
@@ -459,42 +345,10 @@ static int lldb_add_async(struct ldb_module *module, struct ldb_request *req)
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_request *req;
- int ret;
-
- req = talloc_zero(lldb, 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 = lldb->timeout;
-
- ret = lldb_add_async(module, req);
-
- if (ret != LDB_SUCCESS) {
- talloc_free(req);
- return ret;
- }
-
- ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
-
- talloc_free(req);
- return ret;
-}
-
-
/*
modify a record
*/
-static int lldb_modify_async(struct ldb_module *module, struct ldb_request *req)
+static int lldb_modify(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;
@@ -536,41 +390,10 @@ static int lldb_modify_async(struct ldb_module *module, struct ldb_request *req)
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_request *req;
- int ret;
-
- req = talloc_zero(lldb, 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 = lldb->timeout;
-
- ret = lldb_modify_async(module, req);
-
- if (ret != LDB_SUCCESS) {
- talloc_free(req);
- return ret;
- }
-
- ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
-
- talloc_free(req);
- return ret;
-}
-
/*
delete a record
*/
-static int lldb_delete_async(struct ldb_module *module, struct ldb_request *req)
+static int lldb_delete(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;
@@ -603,41 +426,10 @@ static int lldb_delete_async(struct ldb_module *module, struct ldb_request *req)
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_request *req;
- int ret;
-
- req = talloc_zero(lldb, 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;
- req->async.timeout = lldb->timeout;
-
- ret = lldb_delete_async(module, req);
-
- if (ret != LDB_SUCCESS) {
- talloc_free(req);
- return ret;
- }
-
- ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
-
- talloc_free(req);
- return ret;
-}
-
/*
rename a record
*/
-static int lldb_rename_async(struct ldb_module *module, struct ldb_request *req)
+static int lldb_rename(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;
@@ -686,38 +478,6 @@ static int lldb_rename_async(struct ldb_module *module, struct ldb_request *req)
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_request *req;
- int ret;
-
- req = talloc_zero(lldb, 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 = lldb->timeout;
-
- ret = lldb_rename_async(module, req);
-
- if (ret != LDB_SUCCESS) {
- talloc_free(req);
- return ret;
- }
-
- ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
-
- talloc_free(req);
- return ret;
-}
-
static int lldb_parse_result(struct ldb_async_handle *handle, LDAPMessage *result)
{
struct lldb_async_context *ac = talloc_get_type(handle->private_data, struct lldb_async_context);
@@ -951,63 +711,35 @@ static int lldb_start_trans(struct ldb_module *module)
{
/* TODO implement a local transaction mechanism here */
- return 0;
+ return LDB_SUCCESS;
}
static int lldb_end_trans(struct ldb_module *module)
{
/* TODO implement a local transaction mechanism here */
- return 0;
+ return LDB_SUCCESS;
}
static int lldb_del_trans(struct ldb_module *module)
{
/* TODO implement a local transaction mechanism here */
- return 0;
+ return LDB_SUCCESS;
}
static int lldb_request(struct ldb_module *module, struct ldb_request *req)
{
- switch (req->operation) {
-
- case LDB_REQ_SEARCH:
- return lldb_search_bytree(module,
- req->op.search.base,
- req->op.search.scope,
- req->op.search.tree,
- req->op.search.attrs,
- req->controls,
- &req->op.search.res);
-
- case LDB_REQ_ADD:
- return lldb_add(module, req->op.add.message);
-
- case LDB_REQ_MODIFY:
- return lldb_modify(module, req->op.mod.message);
-
- case LDB_REQ_DELETE:
- return lldb_delete(module, req->op.del.dn);
-
- case LDB_REQ_RENAME:
- return lldb_rename(module,
- req->op.rename.olddn,
- req->op.rename.newdn);
-
- default:
- return -1;
-
- }
+ return LDB_ERR_OPERATIONS_ERROR;
}
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,
+ .search = lldb_search,
+ .add = lldb_add,
+ .modify = lldb_modify,
+ .del = lldb_delete,
+ .rename = lldb_rename,
.request = lldb_request,
.start_transaction = lldb_start_trans,
.end_transaction = lldb_end_trans,
diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c
index 9b45697098..529049e36b 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_search.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_search.c
@@ -470,51 +470,11 @@ static int ltdb_search_full(struct ldb_async_handle *handle)
return LDB_SUCCESS;
}
-static int ltdb_search_sync_callback(struct ldb_context *ldb, void *context, struct ldb_async_result *ares)
-{
- struct ldb_result *res = NULL;
-
- if (!context) {
- ldb_set_errstring(ldb, talloc_strdup(ldb, "NULL Context in callback"));
- goto error;
- }
-
- res = *((struct ldb_result **)context);
-
- if (!res || !ares) {
- goto error;
- }
-
- if (ares->type == LDB_REPLY_ENTRY) {
- res->msgs = talloc_realloc(res, res->msgs, struct ldb_message *, res->count + 2);
- if (! res->msgs) {
- goto error;
- }
-
- res->msgs[res->count + 1] = NULL;
-
- res->msgs[res->count] = talloc_steal(res->msgs, ares->message);
- if (! res->msgs[res->count]) {
- goto error;
- }
-
- res->count++;
- } else {
- ldb_debug(ldb, LDB_DEBUG_ERROR, "unrecognized async reply in ltdb_search_sync_callback!\n");
- goto error;
- }
-
- talloc_free(ares);
- return LDB_SUCCESS;
-
-error:
- if (ares) talloc_free(ares);
- if (res) talloc_free(res);
- if (context) *((struct ldb_result **)context) = NULL;
- return LDB_ERR_OPERATIONS_ERROR;
-}
-
-int ltdb_search_async(struct ldb_module *module, struct ldb_request *req)
+/*
+ search the database with a LDAP-like expression.
+ choses a search method
+*/
+int ltdb_search(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;
@@ -566,48 +526,3 @@ int ltdb_search_async(struct ldb_module *module, struct ldb_request *req)
return LDB_SUCCESS;
}
-/*
- search the database with a LDAP-like expression.
- choses a search method
-*/
-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)
-{
- struct ldb_request *req;
- int ret;
-
- *res = talloc_zero(module, struct ldb_result);
- if (! *res) {
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- 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(req->async.handle, LDB_WAIT_ALL);
- talloc_free(req);
- }
-
- if (ret != LDB_SUCCESS) {
- talloc_free(*res);
- }
-
- return ret;
-}
-
-
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
index e5b0ca0668..5ea92aa1b1 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c
@@ -256,41 +256,58 @@ done:
}
+static int ltdb_add_internal(struct ldb_module *module, struct ldb_message *msg)
+{
+ int ret;
+
+ ret = ltdb_check_special_dn(module, msg);
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ if (ltdb_cache_load(module) != 0) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ ret = ltdb_store(module, msg, TDB_INSERT);
+
+ if (ret != LDB_SUCCESS) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ ltdb_modified(module, msg->dn);
+
+ return LDB_SUCCESS;
+}
+
/*
add a record to the database
*/
-static int ltdb_add_async(struct ldb_module *module, struct ldb_request *req)
+static int ltdb_add(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;
+ if (req->controls != NULL) {
+ ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Controls should not reach the ldb_tdb backend!\n");
+ if (check_critical_controls(req->controls)) {
+ return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
+ }
+ }
+
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(req->async.handle->private_data, struct ltdb_async_context);
- tret = ltdb_check_special_dn(module, req->op.add.message);
+ tret = ltdb_add_internal(module, req->op.add.message);
if (tret != LDB_SUCCESS) {
req->async.handle->status = tret;
goto done;
}
- if (ltdb_cache_load(module) != 0) {
- ret = LDB_ERR_OTHER;
- goto done;
- }
-
- tret = ltdb_store(module, req->op.add.message, TDB_INSERT);
-
- if (tret != LDB_SUCCESS) {
- req->async.handle->status = tret;
- goto done;
- }
-
- ltdb_modified(module, req->op.add.message->dn);
-
if (ltdb_ac->callback) {
ret = ltdb_ac->callback(module->ldb, ltdb_ac->context, NULL);
}
@@ -300,35 +317,6 @@ done:
return ret;
}
-static int ltdb_add(struct ldb_module *module, const struct ldb_message *msg)
-{
- struct ldb_request *req;
- int ret;
-
- 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;
-
- ret = ltdb_add_async(module, req);
-
- if (ret != LDB_SUCCESS) {
- talloc_free(req);
- return ret;
- }
-
- ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
-
- talloc_free(req);
- return ret;
-}
-
/*
delete a record from the database, not updating indexes (used for deleting
index records)
@@ -354,16 +342,59 @@ int ltdb_delete_noindex(struct ldb_module *module, const struct ldb_dn *dn)
return ret;
}
+static int ltdb_delete_internal(struct ldb_module *module, struct ldb_dn *dn)
+{
+ struct ldb_message *msg;
+ int ret;
+
+ msg = talloc(module, struct ldb_message);
+ if (msg == NULL) {
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+
+ /* in case any attribute of the message was indexed, we need
+ to fetch the old record */
+ ret = ltdb_search_dn1(module, dn, msg);
+ if (ret != 1) {
+ /* not finding the old record is an error */
+ talloc_free(msg);
+ return LDB_ERR_NO_SUCH_OBJECT;
+ }
+
+ ret = ltdb_delete_noindex(module, dn);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(msg);
+ return LDB_ERR_NO_SUCH_OBJECT;
+ }
+
+ /* remove any indexed attributes */
+ ret = ltdb_index_del(module, msg);
+ if (ret != LDB_SUCCESS) {
+ talloc_free(msg);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ ltdb_modified(module, dn);
+
+ talloc_free(msg);
+ return LDB_SUCCESS;
+}
+
/*
delete a record from the database
*/
-static int ltdb_delete_async(struct ldb_module *module, struct ldb_request *req)
+static int ltdb_delete(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;
+ if (req->controls != NULL) {
+ ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Controls should not reach the ldb_tdb backend!\n");
+ if (check_critical_controls(req->controls)) {
+ return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
+ }
+ }
+
req->async.handle = NULL;
if (ltdb_cache_load(module) != 0) {
@@ -376,34 +407,11 @@ static int ltdb_delete_async(struct ldb_module *module, struct ldb_request *req)
}
ltdb_ac = talloc_get_type(req->async.handle->private_data, struct ltdb_async_context);
- msg = talloc(ltdb_ac, struct ldb_message);
- if (msg == NULL) {
- ret = LDB_ERR_OPERATIONS_ERROR;
- goto done;
- }
-
- /* in case any attribute of the message was indexed, we need
- to fetch the old record */
- tret = ltdb_search_dn1(module, req->op.del.dn, msg);
- if (tret != 1) {
- /* not finding the old record is an error */
- req->async.handle->status = LDB_ERR_NO_SUCH_OBJECT;
- goto done;
- }
-
- tret = ltdb_delete_noindex(module, req->op.del.dn);
- if (tret != LDB_SUCCESS) {
- req->async.handle->status = LDB_ERR_NO_SUCH_OBJECT;
- goto done;
- }
-
- /* remove any indexed attributes */
- tret = ltdb_index_del(module, msg);
+ tret = ltdb_delete_internal(module, req->op.del.dn);
if (tret != LDB_SUCCESS) {
- req->async.handle->status = LDB_ERR_NO_SUCH_OBJECT;
+ req->async.handle->status = tret;
goto done;
}
- ltdb_modified(module, req->op.del.dn);
if (ltdb_ac->callback)
ret = ltdb_ac->callback(module->ldb, ltdb_ac->context, NULL);
@@ -413,36 +421,6 @@ done:
return ret;
}
-static int ltdb_delete(struct ldb_module *module, const struct ldb_dn *dn)
-{
- struct ldb_request *req;
- int ret;
-
- 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) {
- talloc_free(req);
- return ret;
- }
-
- ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
-
- talloc_free(req);
- return ret;
-}
-
-
/*
find an element by attribute name. At the moment this does a linear search, it should
be re-coded to use a binary search once all places that modify records guarantee
@@ -754,12 +732,19 @@ failed:
/*
modify a record
*/
-static int ltdb_modify_async(struct ldb_module *module, struct ldb_request *req)
+static int ltdb_modify(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;
+ if (req->controls != NULL) {
+ ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Controls should not reach the ldb_tdb backend!\n");
+ if (check_critical_controls(req->controls)) {
+ return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
+ }
+ }
+
req->async.handle = NULL;
req->async.handle = init_ltdb_handle(ltdb, module, req->async.context, req->async.callback);
@@ -796,45 +781,23 @@ done:
return ret;
}
-static int ltdb_modify(struct ldb_module *module, const struct ldb_message *msg)
-{
- struct ldb_request *req;
- int ret;
-
- 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) {
- talloc_free(req);
- return ret;
- }
-
- ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
-
- talloc_free(req);
- return ret;
-}
-
/*
rename a record
*/
-static int ltdb_rename_async(struct ldb_module *module, struct ldb_request *req)
+static int ltdb_rename(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;
+ if (req->controls != NULL) {
+ ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Controls should not reach the ldb_tdb backend!\n");
+ if (check_critical_controls(req->controls)) {
+ return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
+ }
+ }
+
req->async.handle = NULL;
if (ltdb_cache_load(module) != 0) {
@@ -868,15 +831,15 @@ static int ltdb_rename_async(struct ldb_module *module, struct ldb_request *req)
goto done;
}
- tret = ltdb_add(module, msg);
+ tret = ltdb_add_internal(module, msg);
if (tret != LDB_SUCCESS) {
ret = LDB_ERR_OPERATIONS_ERROR;
goto done;
}
- tret = ltdb_delete(module, req->op.rename.olddn);
+ tret = ltdb_delete_internal(module, req->op.rename.olddn);
if (tret != LDB_SUCCESS) {
- ltdb_delete(module, req->op.rename.newdn);
+ ltdb_delete_internal(module, req->op.rename.newdn);
ret = LDB_ERR_OPERATIONS_ERROR;
goto done;
}
@@ -889,36 +852,6 @@ done:
return ret;
}
-static int ltdb_rename(struct ldb_module *module, const struct ldb_dn *olddn, const struct ldb_dn *newdn)
-{
- struct ldb_request *req;
- int ret;
-
- req = talloc_zero(module, 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;
-
- ret = ltdb_rename_async(module, req);
-
- if (ret != LDB_SUCCESS) {
- talloc_free(req);
- return ret;
- }
-
- ret = ldb_async_wait(req->async.handle, LDB_WAIT_ALL);
-
- talloc_free(req);
- return ret;
-}
-
static int ltdb_start_trans(struct ldb_module *module)
{
struct ltdb_private *ltdb = module->private_data;
@@ -960,43 +893,15 @@ static int ltdb_async_wait(struct ldb_async_handle *handle, enum ldb_async_wait_
static int ltdb_request(struct ldb_module *module, struct ldb_request *req)
{
/* check for oustanding critical controls and return an error if found */
-
if (req->controls != NULL) {
ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Controls should not reach the ldb_tdb backend!\n");
- }
-
- if (check_critical_controls(req->controls)) {
- return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
+ if (check_critical_controls(req->controls)) {
+ return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
+ }
}
- switch (req->operation) {
-
- case LDB_REQ_SEARCH:
- return ltdb_search_bytree(module,
- req->op.search.base,
- req->op.search.scope,
- req->op.search.tree,
- req->op.search.attrs,
- &req->op.search.res);
-
- case LDB_REQ_ADD:
- return ltdb_add(module, req->op.add.message);
-
- case LDB_REQ_MODIFY:
- return ltdb_modify(module, req->op.mod.message);
-
- case LDB_REQ_DELETE:
- return ltdb_delete(module, req->op.del.dn);
-
- case LDB_REQ_RENAME:
- return ltdb_rename(module,
- req->op.rename.olddn,
- req->op.rename.newdn);
-
- default:
- return LDB_ERR_OPERATIONS_ERROR;
-
- }
+ /* search, add, modify, delete, rename are handled by their own, no other op supported */
+ return LDB_ERR_OPERATIONS_ERROR;
}
/*
@@ -1026,11 +931,11 @@ static uint64_t ltdb_sequence_number(struct ldb_context *ldb)
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,
+ .search = ltdb_search,
+ .add = ltdb_add,
+ .modify = ltdb_modify,
+ .del = ltdb_delete,
+ .rename = ltdb_rename,
.request = ltdb_request,
.start_transaction = ltdb_start_trans,
.end_transaction = ltdb_end_trans,
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.h b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
index ad9e5c10c6..0c44a80edd 100644
--- a/source4/lib/ldb/ldb_tdb/ldb_tdb.h
+++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.h
@@ -100,11 +100,7 @@ int ltdb_add_attr_results(struct ldb_module *module,
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, 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);
-
+int ltdb_search(struct ldb_module *module, struct ldb_request *req);
/* The following definitions come from lib/ldb/ldb_tdb/ldb_tdb.c */
struct ldb_async_handle *init_ltdb_handle(struct ltdb_private *ltdb, struct ldb_module *module,
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
};