* Author: Simo Sorce
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
struct opaque {
struct ldb_context *ldb;
{
struct sort_context *ac = talloc_get_type(opaque, struct sort_context);
struct ldb_message_element *el1, *el2;
+ struct ldb_context *ldb;
+
+ ldb = ldb_module_get_ctx(ac->module);
if (!ac || ac->sort_result != 0) {
/* an error occurred previously,
}
if (ac->reverse)
- return ac->a->syntax->comparison_fn(ac->module->ldb, ac, &el2->values[0], &el1->values[0]);
+ return ac->a->syntax->comparison_fn(ldb, ac, &el2->values[0], &el1->values[0]);
- return ac->a->syntax->comparison_fn(ac->module->ldb, ac, &el1->values[0], &el2->values[0]);
+ return ac->a->syntax->comparison_fn(ldb, ac, &el1->values[0], &el2->values[0]);
}
static int server_sort_results(struct sort_context *ac)
{
+ struct ldb_context *ldb;
struct ldb_reply *ares;
int i, ret;
- ac->a = ldb_schema_attribute_by_name(ac->module->ldb, ac->attributeName);
+ ldb = ldb_module_get_ctx(ac->module);
+
+ ac->a = ldb_schema_attribute_by_name(ldb, ac->attributeName);
ac->sort_result = 0;
ldb_qsort(ac->msgs, ac->num_msgs,
static int server_sort_search_callback(struct ldb_request *req, struct ldb_reply *ares)
{
struct sort_context *ac;
+ struct ldb_context *ldb;
int ret;
ac = talloc_get_type(req->context, struct sort_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
ac->msgs = talloc_realloc(ac, ac->msgs, struct ldb_message *, ac->num_msgs + 2);
if (! ac->msgs) {
talloc_free(ares);
- ldb_oom(ac->module->ldb);
+ ldb_oom(ldb);
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
ac->referrals = talloc_realloc(ac, ac->referrals, char *, ac->num_refs + 2);
if (! ac->referrals) {
talloc_free(ares);
- ldb_oom(ac->module->ldb);
+ ldb_oom(ldb);
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
struct ldb_control **controls;
struct ldb_request *down_req;
struct sort_context *ac;
+ struct ldb_context *ldb;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
/* check if there's a paged request control */
control = ldb_request_get_control(req, LDB_CONTROL_SERVER_SORT_OID);
if (control == NULL) {
ac = talloc_zero(req, struct sort_context);
if (ac == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
ac->orderingRule = sort_ctrls[0]->orderingRule;
ac->reverse = sort_ctrls[0]->reverse;
- ret = ldb_build_search_req_ex(&down_req, module->ldb, ac,
+ ret = ldb_build_search_req_ex(&down_req, ldb, ac,
req->op.search.base,
req->op.search.scope,
req->op.search.tree,
static int server_sort_init(struct ldb_module *module)
{
+ struct ldb_context *ldb;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
ret = ldb_mod_register_control(module, LDB_CONTROL_SERVER_SORT_OID);
if (ret != LDB_SUCCESS) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING,
+ ldb_debug(ldb, LDB_DEBUG_WARNING,
"server_sort:"
"Unable to register control with rootdse!\n");
}