Separate again the public from the private headers.
Add a new header specific for modules.
Also add service function for modules as now ldb_context and ldb_module are
opaque structures for them.
*/
#include "includes.h"
+#include "lib/events/events.h"
#include "dsdb/samdb/samdb.h"
#include "auth/auth.h"
#include "smbd/service.h"
-#include "lib/events/events.h"
#include "lib/messaging/irpc.h"
#include "dsdb/repl/drepl_service.h"
#include "lib/ldb/include/ldb_errors.h"
*/
#include "includes.h"
-#include "ldb_includes.h"
+#include "ldb_module.h"
#include "dsdb/samdb/samdb.h"
/**
TALLOC_CTX *mem_ctx, enum ldb_parse_op op,
struct ldb_parse_tree *first_arm, struct ldb_parse_tree *second_arm)
{
+ struct ldb_context *ldb;
struct ldb_parse_tree *list;
+ ldb = ldb_module_get_ctx(module);
+
list = talloc(mem_ctx, struct ldb_parse_tree);
if (list == NULL){
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return NULL;
}
list->operation = op;
list->u.list.num_elements = 2;
list->u.list.elements = talloc_array(list, struct ldb_parse_tree *, 2);
if (!list->u.list.elements) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return NULL;
}
list->u.list.elements[0] = talloc_steal(list, first_arm);
TALLOC_CTX *mem_ctx, enum ldb_parse_op op,
const char *attr, const DATA_BLOB *match)
{
+ struct ldb_context *ldb;
struct ldb_parse_tree *match_tree;
+ ldb = ldb_module_get_ctx(module);
+
match_tree = talloc(mem_ctx, struct ldb_parse_tree);
/* Depending on what type of match was selected, fill in the right part of the union */
match_tree->u.substring.chunks = talloc_array(match_tree, struct ldb_val *, 2);
if (match_tree->u.substring.chunks == NULL){
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return NULL;
}
match_tree->u.substring.chunks[0] = match;
struct ldb_module *module = ac->module;
struct ldb_parse_tree *match_tree;
struct dsdb_attribute *cur;
- const struct dsdb_schema *schema = dsdb_get_schema(module->ldb);
+ const struct dsdb_schema *schema;
+ struct ldb_context *ldb;
uint8_t *p;
enum ldb_parse_op op;
+ ldb = ldb_module_get_ctx(module);
+
+ schema = dsdb_get_schema(ldb);
if (!schema) {
- ldb_asprintf_errstring(module->ldb, "no schema with which to construct anr filter");
+ ldb_asprintf_errstring(ldb, "no schema with which to construct anr filter");
return LDB_ERR_OPERATIONS_ERROR;
}
DATA_BLOB *match2 = talloc(mem_ctx, DATA_BLOB);
*match2 = data_blob_const(match->data+1, match->length - 1);
if (match2 == NULL){
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
match = match2;
/* Inject an 'or' with the current tree */
tree = make_parse_list(module, mem_ctx, LDB_OP_OR, tree, match_tree);
if (tree == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
} else {
DATA_BLOB *first_match = talloc(tree, DATA_BLOB);
DATA_BLOB *second_match = talloc(tree, DATA_BLOB);
if (!first_match || !second_match) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
*first_match = data_blob_const(match->data, p-match->data);
first_split_filter = make_parse_list(module, ac, LDB_OP_AND, match_tree_1, match_tree_2);
if (first_split_filter == NULL){
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
second_split_filter = make_parse_list(module, ac, LDB_OP_AND, match_tree_1, match_tree_2);
if (second_split_filter == NULL){
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
split_filters = make_parse_list(module, mem_ctx, LDB_OP_OR,
first_split_filter, second_split_filter);
if (split_filters == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
/* search */
static int anr_search(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct ldb_parse_tree *anr_tree;
struct ldb_request *down_req;
struct anr_context *ac;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
ac = talloc(req, struct anr_context);
if (!ac) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
}
ret = ldb_build_search_req_ex(&down_req,
- module->ldb, ac,
+ ldb, ac,
req->op.search.base,
req->op.search.scope,
anr_tree,
# Start MODULE ldb_objectguid
[MODULE::ldb_objectguid]
SUBSYSTEM = LIBLDB
-PRIVATE_DEPENDENCIES = LIBTALLOC LIBEVENTS LIBNDR
+PRIVATE_DEPENDENCIES = SAMDB LIBTALLOC LIBEVENTS LIBNDR
INIT_FUNCTION = LDB_MODULE(objectguid)
# End MODULE ldb_objectguid
################################################
*/
#include "includes.h"
-#include "ldb/include/ldb_includes.h"
+#include "ldb_module.h"
#include "librpc/gen_ndr/ndr_misc.h"
#include "dsdb/samdb/samdb.h"
#include "dsdb/common/flags.h"
static int it_callback(struct ldb_request *req, struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct it_context *ac;
ac = talloc_get_type(req->context, struct it_context);
-
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
}
if (ares->type != LDB_REPLY_DONE) {
- ldb_set_errstring(req->handle->ldb, "Invalid reply type!");
+ ldb_set_errstring(ldb, "Invalid reply type!");
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
/* add_record: add instancetype attribute */
static int instancetype_add(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct ldb_request *down_req;
struct ldb_message *msg;
struct it_context *ac;
int ret;
const struct ldb_control *partition_ctrl;
const struct dsdb_control_current_partition *partition;
-
- ldb_debug(module->ldb, LDB_DEBUG_TRACE, "instancetype_add_record\n");
+ ldb = ldb_module_get_ctx(module);
+
+ ldb_debug(ldb, LDB_DEBUG_TRACE, "instancetype_add_record\n");
/* do not manipulate our control entries */
if (ldb_dn_is_special(req->op.add.message->dn)) {
partition_ctrl = ldb_request_get_control(req, DSDB_CONTROL_CURRENT_PARTITION_OID);
if (!partition_ctrl) {
- ldb_debug_set(module->ldb, LDB_DEBUG_FATAL,
+ ldb_debug_set(ldb, LDB_DEBUG_FATAL,
"instancetype_add: no current partition control found");
return LDB_ERR_CONSTRAINT_VIOLATION;
}
/* we have to copy the message as the caller might have it as a const */
msg = ldb_msg_copy_shallow(ac, req->op.add.message);
if (msg == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
instance_type = INSTANCE_TYPE_WRITE;
if (ldb_dn_compare(partition->dn, msg->dn) == 0) {
instance_type |= INSTANCE_TYPE_IS_NC_HEAD;
- if (ldb_dn_compare(msg->dn, samdb_base_dn(module->ldb)) != 0) {
+ if (ldb_dn_compare(msg->dn, samdb_base_dn(ldb)) != 0) {
instance_type |= INSTANCE_TYPE_NC_ABOVE;
}
}
ret = ldb_msg_add_fmt(msg, "instanceType", "%u", instance_type);
if (ret != LDB_SUCCESS) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ldb_build_add_req(&down_req, module->ldb, ac,
+ ret = ldb_build_add_req(&down_req, ldb, ac,
msg,
req->controls,
ac, it_callback,
*/
#include "includes.h"
-#include "ldb/include/ldb_includes.h"
+#include "ldb_module.h"
#include "librpc/gen_ndr/ndr_misc.h"
#include "param/param.h"
/* add_record: add objectGUID attribute */
static int objectguid_add(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct ldb_request *down_req;
struct ldb_message_element *attribute;
struct ldb_message *msg;
time_t t = time(NULL);
struct og_context *ac;
- ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n");
+ ldb = ldb_module_get_ctx(module);
+
+ ldb_debug(ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n");
/* do not manipulate our control entries */
if (ldb_dn_is_special(req->op.add.message->dn)) {
guid = GUID_random();
ndr_err = ndr_push_struct_blob(&v, msg,
- lp_iconv_convenience(ldb_get_opaque(module->ldb, "loadparm")),
+ lp_iconv_convenience(ldb_get_opaque(ldb, "loadparm")),
&guid,
(ndr_push_flags_fn_t)ndr_push_GUID);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
/* Get a sequence number from the backend */
/* FIXME: ldb_sequence_number is a semi-async call,
* make sure this function is split and a callback is used */
- ret = ldb_sequence_number(module->ldb, LDB_SEQ_NEXT, &seq_num);
+ ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num);
if (ret == LDB_SUCCESS) {
if (add_uint64_element(msg, "uSNCreated", seq_num) != 0 ||
add_uint64_element(msg, "uSNChanged", seq_num) != 0) {
}
}
- ret = ldb_build_add_req(&down_req, module->ldb, ac,
+ ret = ldb_build_add_req(&down_req, ldb, ac,
msg,
req->controls,
ac, og_op_callback,
/* modify_record: update timestamps */
static int objectguid_modify(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct ldb_request *down_req;
struct ldb_message *msg;
int ret;
uint64_t seq_num;
struct og_context *ac;
- ldb_debug(module->ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n");
+ ldb = ldb_module_get_ctx(module);
+
+ ldb_debug(ldb, LDB_DEBUG_TRACE, "objectguid_add_record\n");
/* do not manipulate our control entries */
if (ldb_dn_is_special(req->op.add.message->dn)) {
}
/* Get a sequence number from the backend */
- ret = ldb_sequence_number(module->ldb, LDB_SEQ_NEXT, &seq_num);
+ ret = ldb_sequence_number(ldb, LDB_SEQ_NEXT, &seq_num);
if (ret == LDB_SUCCESS) {
if (add_uint64_element(msg, "uSNChanged", seq_num) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
}
}
- ret = ldb_build_mod_req(&down_req, module->ldb, ac,
+ ret = ldb_build_mod_req(&down_req, ldb, ac,
msg,
req->controls,
ac, og_op_callback,
*/
#include "includes.h"
-#include "ldb/include/ldb_includes.h"
+#include "ldb_private.h"
#include "dsdb/samdb/samdb.h"
struct partition_private_data {
* Author: Andrew Bartlett
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
struct rr_context {
struct ldb_module *module;
ac = talloc_zero(req, struct rr_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
+ ldb_set_errstring(ldb_module_get_ctx(module), "Out of Memory");
return NULL;
}
static int rr_search_callback(struct ldb_request *req, struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct rr_context *ac;
int i, j;
ac = talloc_get_type(req->context, struct rr_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
(size_t)(p - ac->req->op.search.attrs[i]));
if (!new_attr) {
- ldb_oom(ac->module->ldb);
+ ldb_oom(ldb);
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
} else {
end_str = talloc_asprintf(el, "%u", end);
if (!end_str) {
- ldb_oom(ac->module->ldb);
+ ldb_oom(ldb);
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
orig_num_values = el->num_values;
if ((start + end < start) || (start + end < end)) {
- ldb_asprintf_errstring(ac->module->ldb,
+ ldb_asprintf_errstring(ldb,
"range request error: start or end would overflow!");
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_UNWILLING_TO_PERFORM);
el->values = talloc_array(el, struct ldb_val, (end - start) + 1);
if (!el->values) {
- ldb_oom(ac->module->ldb);
+ ldb_oom(ldb);
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
}
el->name = talloc_asprintf(el, "%s;range=%u-%s", el->name, start, end_str);
if (!el->name) {
- ldb_oom(ac->module->ldb);
+ ldb_oom(ldb);
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
/* search */
static int rr_search(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
int i;
unsigned int start, end;
const char **new_attrs = NULL;
struct rr_context *ac;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
/* Strip the range request from the attribute */
for (i = 0; req->op.search.attrs && req->op.search.attrs[i]; i++) {
char *p;
end = (unsigned int)-1;
if (sscanf(p, ";range=%u-*", &start) != 1) {
if (sscanf(p, ";range=%u-%u", &start, &end) != 2) {
- ldb_asprintf_errstring(module->ldb,
+ ldb_asprintf_errstring(ldb,
"range request error: "
"range request malformed");
return LDB_ERR_UNWILLING_TO_PERFORM;
}
}
if (start > end) {
- ldb_asprintf_errstring(module->ldb, "range request error: start must not be greater than end");
+ ldb_asprintf_errstring(ldb, "range request error: start must not be greater than end");
return LDB_ERR_UNWILLING_TO_PERFORM;
}
(size_t)(p - new_attrs[i]));
if (!new_attrs[i]) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
}
return LDB_ERR_OPERATIONS_ERROR;
}
- 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,
* Author: Andrew Bartlett
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
struct subtree_delete_context {
struct ldb_module *module;
static struct subtree_delete_context *subdel_ctx_init(struct ldb_module *module,
struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct subtree_delete_context *ac;
+ ldb = ldb_module_get_ctx(module);
+
ac = talloc_zero(req, struct subtree_delete_context);
if (ac == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return NULL;
}
static int subtree_delete_search_callback(struct ldb_request *req,
struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct subtree_delete_context *ac;
int ret;
ac = talloc_get_type(req->context, struct subtree_delete_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
if (ac->num_children > 0) {
talloc_free(ares);
- ldb_asprintf_errstring(ac->module->ldb,
+ ldb_asprintf_errstring(ldb,
"Cannot delete %s, not a leaf node "
"(has %d children)\n",
ldb_dn_get_linearized(ac->req->op.del.dn),
static int subtree_delete(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
static const char * const attrs[2] = { "distinguishedName", NULL };
struct ldb_request *search_req;
struct subtree_delete_context *ac;
return ldb_next_request(module, req);
}
+ ldb = ldb_module_get_ctx(module);
+
/* This gets complex: We need to:
- Do a search for all entires under this entry
- Wait for these results to appear
/* we do not really need to find all descendents,
* if there is even one single direct child, that's
* enough to bail out */
- ret = ldb_build_search_req(&search_req, module->ldb, ac,
+ ret = ldb_build_search_req(&search_req, ldb, ac,
req->op.del.dn, LDB_SCOPE_ONELEVEL,
"(objectClass=*)", attrs,
req->controls,
* Author: Andrew Bartlett
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
struct subren_msg_store {
struct subren_msg_store *next;
static struct subtree_rename_context *subren_ctx_init(struct ldb_module *module,
struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct subtree_rename_context *ac;
+ ldb = ldb_module_get_ctx(module);
+
ac = talloc_zero(req, struct subtree_rename_context);
if (ac == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return NULL;
}
static int subtree_rename_callback(struct ldb_request *req,
struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct subtree_rename_context *ac;
int ret;
ac = talloc_get_type(req->context, struct subtree_rename_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
}
if (ares->type != LDB_REPLY_DONE) {
- ldb_set_errstring(ac->module->ldb, "Invalid reply type!\n");
+ ldb_set_errstring(ldb, "Invalid reply type!\n");
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
static int subtree_rename_next_request(struct subtree_rename_context *ac)
{
+ struct ldb_context *ldb;
struct ldb_request *req;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
if (ac->current == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ldb_build_rename_req(&req, ac->module->ldb, ac->current,
+ ret = ldb_build_rename_req(&req, ldb, ac->current,
ac->current->olddn,
ac->current->newdn,
ac->req->controls,
/* rename */
static int subtree_rename(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
static const char *attrs[2] = { "distinguishedName", NULL };
struct ldb_request *search_req;
struct subtree_rename_context *ac;
return ldb_next_request(module, req);
}
+ ldb = ldb_module_get_ctx(module);
+
/* This gets complex: We need to:
- Do a search for all entires under this entry
- Wait for these results to appear
ac->current->newdn = req->op.rename.newdn;
ac->list = ac->current;
- ret = ldb_build_search_req(&search_req, module->ldb, ac,
+ ret = ldb_build_search_req(&search_req, ldb, ac,
req->op.rename.olddn,
LDB_SCOPE_SUBTREE,
"(objectClass=*)",
*/
#include "includes.h"
-#include "ldb/include/ldb_includes.h"
+#include "ldb_module.h"
#include "auth/credentials/credentials.h"
#include "auth/credentials/credentials_krb5.h"
#include "system/kerberos.h"
ac = talloc_zero(req, struct update_kt_ctx);
if (ac == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb_module_get_ctx(module));
return NULL;
}
* of async issues). -SSS
*/
static int add_modified(struct ldb_module *module, struct ldb_dn *dn, bool delete) {
- struct update_kt_private *data = talloc_get_type(module->private_data, struct update_kt_private);
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
+ struct update_kt_private *data = talloc_get_type(ldb_module_get_private(module), struct update_kt_private);
struct dn_list *item;
char *filter;
struct ldb_result *res;
filter = talloc_asprintf(data, "(&(dn=%s)(&(objectClass=kerberosSecret)(privateKeytab=*)))",
ldb_dn_get_linearized(dn));
if (!filter) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ldb_search(module->ldb, data, &res,
+ ret = ldb_search(ldb, data, &res,
dn, LDB_SCOPE_BASE, attrs, "%s", filter);
if (ret != LDB_SUCCESS) {
talloc_free(filter);
item = talloc(data->changed_dns? (void *)data->changed_dns: (void *)data, struct dn_list);
if (!item) {
talloc_free(filter);
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
if (!item->creds) {
DEBUG(1, ("cli_credentials_init failed!"));
talloc_free(filter);
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- cli_credentials_set_conf(item->creds, ldb_get_opaque(module->ldb, "loadparm"));
- status = cli_credentials_set_secrets(item->creds, ldb_get_event_context(module->ldb), ldb_get_opaque(module->ldb, "loadparm"), module->ldb, NULL, filter);
+ cli_credentials_set_conf(item->creds, ldb_get_opaque(ldb, "loadparm"));
+ status = cli_credentials_set_secrets(item->creds, ldb_get_event_context(ldb), ldb_get_opaque(ldb, "loadparm"), ldb, NULL, filter);
talloc_free(filter);
if (NT_STATUS_IS_OK(status)) {
if (delete) {
static int update_kt_op_callback(struct ldb_request *req,
struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct update_kt_ctx *ac;
int ret;
ac = talloc_get_type(req->context, struct update_kt_ctx);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
}
if (ares->type != LDB_REPLY_DONE) {
- ldb_set_errstring(ac->module->ldb, "Invalid request type!\n");
+ ldb_set_errstring(ldb, "Invalid request type!\n");
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
static int ukt_del_op(struct update_kt_ctx *ac)
{
+ struct ldb_context *ldb;
struct ldb_request *down_req;
int ret;
- ret = ldb_build_del_req(&down_req, ac->module->ldb, ac,
+ ldb = ldb_module_get_ctx(ac->module);
+
+ ret = ldb_build_del_req(&down_req, ldb, ac,
ac->dn,
ac->req->controls,
ac, update_kt_op_callback,
static int ukt_search_modified(struct update_kt_ctx *ac)
{
+ struct ldb_context *ldb;
static const char * const attrs[] = { "distinguishedName", NULL };
struct ldb_request *search_req;
int ret;
- ret = ldb_build_search_req(&search_req, ac->module->ldb, ac,
+ ldb = ldb_module_get_ctx(ac->module);
+
+ ret = ldb_build_search_req(&search_req, ldb, ac,
ac->dn, LDB_SCOPE_BASE,
"(&(objectClass=kerberosSecret)"
"(privateKeytab=*))", attrs,
/* add */
static int update_kt_add(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct update_kt_ctx *ac;
struct ldb_request *down_req;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
ac = update_kt_ctx_init(module, req);
if (ac == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
ac->dn = req->op.add.message->dn;
- ret = ldb_build_add_req(&down_req, module->ldb, ac,
+ ret = ldb_build_add_req(&down_req, ldb, ac,
req->op.add.message,
req->controls,
ac, update_kt_op_callback,
/* modify */
static int update_kt_modify(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct update_kt_ctx *ac;
struct ldb_request *down_req;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
ac = update_kt_ctx_init(module, req);
if (ac == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
ac->dn = req->op.mod.message->dn;
- ret = ldb_build_mod_req(&down_req, module->ldb, ac,
+ ret = ldb_build_mod_req(&down_req, ldb, ac,
req->op.mod.message,
req->controls,
ac, update_kt_op_callback,
/* rename */
static int update_kt_rename(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct update_kt_ctx *ac;
struct ldb_request *down_req;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
ac = update_kt_ctx_init(module, req);
if (ac == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
ac->dn = req->op.rename.newdn;
- ret = ldb_build_rename_req(&down_req, module->ldb, ac,
+ ret = ldb_build_rename_req(&down_req, ldb, ac,
req->op.rename.olddn,
req->op.rename.newdn,
req->controls,
/* end a transaction */
static int update_kt_end_trans(struct ldb_module *module)
{
- struct update_kt_private *data = talloc_get_type(module->private_data, struct update_kt_private);
+ struct ldb_context *ldb;
+ struct update_kt_private *data = talloc_get_type(ldb_module_get_private(module), struct update_kt_private);
struct dn_list *p;
+ ldb = ldb_module_get_ctx(module);
+
for (p=data->changed_dns; p; p = p->next) {
int kret;
- kret = cli_credentials_update_keytab(p->creds, ldb_get_event_context(module->ldb), ldb_get_opaque(module->ldb, "loadparm"));
+ kret = cli_credentials_update_keytab(p->creds, ldb_get_event_context(ldb), ldb_get_opaque(ldb, "loadparm"));
if (kret != 0) {
talloc_free(data->changed_dns);
data->changed_dns = NULL;
- ldb_asprintf_errstring(module->ldb, "Failed to update keytab: %s", error_message(kret));
+ ldb_asprintf_errstring(ldb, "Failed to update keytab: %s", error_message(kret));
return LDB_ERR_OPERATIONS_ERROR;
}
}
/* end a transaction */
static int update_kt_del_trans(struct ldb_module *module)
{
- struct update_kt_private *data = talloc_get_type(module->private_data, struct update_kt_private);
+ struct update_kt_private *data = talloc_get_type(ldb_module_get_private(module), struct update_kt_private);
talloc_free(data->changed_dns);
data->changed_dns = NULL;
static int update_kt_init(struct ldb_module *module)
{
+ struct ldb_context *ldb;
struct update_kt_private *data;
+ ldb = ldb_module_get_ctx(module);
+
data = talloc(module, struct update_kt_private);
if (data == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- module->private_data = data;
data->changed_dns = NULL;
+ ldb_module_set_private(module, data);
+
return ldb_next_init(module);
}
*/
#include "includes.h"
-#include "lib/ldb/include/ldb_includes.h"
+#include "ldb_private.h"
#include "dsdb/samdb/samdb.h"
#include "librpc/gen_ndr/ndr_security.h"
#include "librpc/gen_ndr/ndr_misc.h"
see rfc2252
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
#include "system/locale.h"
#include "ldb_handlers.h"
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
/*
initialise a ldb context
ldb->create_perms = perms;
}
+unsigned int ldb_get_create_perms(struct ldb_context *ldb)
+{
+ return ldb->create_perms;
+}
+
void ldb_set_event_context(struct ldb_context *ldb, struct tevent_context *ev)
{
ldb->ev_ctx = ev;
return ldb->ev_ctx;
}
+void ldb_request_set_state(struct ldb_request *req, int state)
+{
+ req->handle->state = state;
+}
+
+int ldb_request_get_status(struct ldb_request *req)
+{
+ return req->handle->status;
+}
+
/*
start an ldb request
NOTE: the request must be a talloc context.
message matching logic generic
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
/*
add a attribute to the ldb_schema
* Author: Simo Sorce
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
/* check if a control with the specified "oid" exist and return it */
/* returns NULL if not found */
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
/*
this allows the user to choose their own debug function
* Author: Simo Sorce
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
#include <ctype.h>
#define LDB_DN_NULL_FAILED(x) if (!(x)) goto failed
see RFC2849 for the LDIF format definition
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
#include "system/locale.h"
/*
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
/*
check if the scope matches in a search result
* Author: Simo Sorce
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
#if (_SAMBA_BUILD_ >= 4)
#include "includes.h"
} while (0)
+struct ldb_module *ldb_module_new(TALLOC_CTX *memctx,
+ struct ldb_context *ldb,
+ const char *module_name,
+ const struct ldb_module_ops *ops)
+{
+ struct ldb_module *module;
+
+ module = talloc(memctx, struct ldb_module);
+ if (!module) {
+ ldb_oom(ldb);
+ return NULL;
+ }
+ talloc_set_name_const(module, module_name);
+ module->ldb = ldb;
+ module->prev = module->next = NULL;
+ module->ops = ops;
+
+ return module;
+}
+
+struct ldb_context *ldb_module_get_ctx(struct ldb_module *module)
+{
+ return module->ldb;
+}
+
+void *ldb_module_get_private(struct ldb_module *module)
+{
+ return module->private_data;
+}
+
+void ldb_module_set_private(struct ldb_module *module, void *private_data)
+{
+ module->private_data = private_data;
+}
+
/*
helper functions to call the next module in chain
*/
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
/*
create a new ldb_message in a given memory context (NULL for top level)
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
#include "system/locale.h"
/*
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
#include "system/locale.h"
* Simo Sorce <idra@samba.org> 2005
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
/* Byte-wise swap two items of size SIZE. */
#define SWAP(a, b, size) \
*/
-#include "ldb_includes.h"
#include "ldb.h"
-#include "ldb_errors.h"
/*
ldb_ldif_write takes a function pointer to a custom output
*/
-#include "ldb_includes.h"
#include "ldb.h"
-#include "ldb_errors.h"
/*
ldb_ldif_write takes a function pointer to a custom output
/* To use these macros you must have a structure containing a next and
prev pointer */
+#ifndef _DLINKLIST_H
+#define _DLINKLIST_H
/* hook into the front of the list */
#define DLIST_ADD(list, p) \
} \
} \
} while (0)
+
+#endif /* _DLINKLIST_H */
#define _LDB_H_ 1
/*! \endcond */
+#include "ldb_includes.h"
+
/*
major restrictions as compared to normal LDAP:
- - no async calls.
- each record must have a unique key field
- the key must be representable as a NULL terminated C string and may not
contain a comma or braces
major restrictions as compared to tdb:
- - no explicit locking calls
- UPDATE: we have transactions now, better than locking --SSS.
+ - no explicit locking calls, but we have transactions when using ldb_tdb
*/
#include "system/time.h"
#include <talloc.h>
#include <tevent.h>
-#include "ldb.h"
#include "ldb_errors.h"
-#include "ldb_private.h"
#include "dlinklist.h"
#endif /*_LDB_PRIVATE_INCLUDES_H_*/
--- /dev/null
+/*
+ ldb database library
+
+ Copyright (C) Simo Sorce 2008
+
+ ** NOTE! The following LGPL license applies to the ldb
+ ** library. This does NOT imply that all of Samba is released
+ ** under the LGPL
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ * Name: ldb
+ *
+ * Component: ldb module header
+ *
+ * Description: defines ldb modules structures and helpers
+ *
+ */
+
+#ifndef _LDB_MODULE_H_
+#define _LDB_MODULE_H_
+
+#include "ldb.h"
+
+struct ldb_context;
+struct ldb_module;
+
+/*
+ these function pointers define the operations that a ldb module can intercept
+*/
+struct ldb_module_ops {
+ const char *name;
+ int (*init_context) (struct ldb_module *);
+ int (*search)(struct ldb_module *, struct ldb_request *); /* search */
+ int (*add)(struct ldb_module *, struct ldb_request *); /* add */
+ int (*modify)(struct ldb_module *, struct ldb_request *); /* modify */
+ int (*del)(struct ldb_module *, struct ldb_request *); /* delete */
+ int (*rename)(struct ldb_module *, struct ldb_request *); /* rename */
+ int (*request)(struct ldb_module *, struct ldb_request *); /* match any other operation */
+ int (*extended)(struct ldb_module *, struct ldb_request *); /* extended operations */
+ int (*start_transaction)(struct ldb_module *);
+ int (*end_transaction)(struct ldb_module *);
+ int (*del_transaction)(struct ldb_module *);
+ int (*sequence_number)(struct ldb_module *, struct ldb_request *);
+ void *private_data;
+};
+
+
+/* The following definitions come from lib/ldb/common/ldb_debug.c */
+void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
+void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level,
+ const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
+
+#define ldb_oom(ldb) ldb_debug_set(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__)
+
+/* The following definitions come from lib/ldb/common/ldb.c */
+
+void ldb_request_set_state(struct ldb_request *req, int state);
+int ldb_request_get_status(struct ldb_request *req);
+
+unsigned int ldb_get_create_perms(struct ldb_context *ldb);
+
+const struct ldb_schema_syntax *ldb_standard_syntax_by_name(struct ldb_context *ldb,
+ const char *syntax);
+
+/* The following definitions come from lib/ldb/common/ldb_attributes.c */
+
+int ldb_schema_attribute_add_with_syntax(struct ldb_context *ldb,
+ const char *name,
+ unsigned flags,
+ const struct ldb_schema_syntax *syntax);
+int ldb_schema_attribute_add(struct ldb_context *ldb,
+ const char *name,
+ unsigned flags,
+ const char *syntax);
+void ldb_schema_attribute_remove(struct ldb_context *ldb, const char *name);
+
+/* The following definitions come from lib/ldb/common/ldb_controls.c */
+struct ldb_control *get_control_from_list(struct ldb_control **controls, const char *oid);
+int save_controls(struct ldb_control *exclude, struct ldb_request *req, struct ldb_control ***saver);
+int check_critical_controls(struct ldb_control **controls);
+
+/* The following definitions come from lib/ldb/common/ldb_ldif.c */
+int ldb_should_b64_encode(const struct ldb_val *val);
+
+/* The following definitions come from lib/ldb/common/ldb_match.c */
+int ldb_match_msg(struct ldb_context *ldb,
+ const struct ldb_message *msg,
+ const struct ldb_parse_tree *tree,
+ struct ldb_dn *base,
+ enum ldb_scope scope);
+
+/* The following definitions come from lib/ldb/common/ldb_modules.c */
+
+struct ldb_module *ldb_module_new(TALLOC_CTX *memctx,
+ struct ldb_context *ldb,
+ const char *module_name,
+ const struct ldb_module_ops *ops);
+
+struct ldb_context *ldb_module_get_ctx(struct ldb_module *module);
+void *ldb_module_get_private(struct ldb_module *module);
+void ldb_module_set_private(struct ldb_module *module, void *private_data);
+
+int ldb_next_request(struct ldb_module *module, struct ldb_request *request);
+int ldb_next_start_trans(struct ldb_module *module);
+int ldb_next_end_trans(struct ldb_module *module);
+int ldb_next_del_trans(struct ldb_module *module);
+int ldb_next_init(struct ldb_module *module);
+
+void ldb_set_errstring(struct ldb_context *ldb, const char *err_string);
+void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
+void ldb_reset_err_string(struct ldb_context *ldb);
+
+const char *ldb_default_modules_dir(void);
+
+int ldb_register_module(const struct ldb_module_ops *);
+
+typedef int (*ldb_connect_fn)(struct ldb_context *ldb, const char *url,
+ unsigned int flags, const char *options[],
+ struct ldb_module **module);
+
+struct ldb_backend_ops {
+ const char *name;
+ ldb_connect_fn connect_fn;
+};
+
+const char *ldb_default_modules_dir(void);
+
+int ldb_register_backend(const char *url_prefix, ldb_connect_fn);
+
+struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb);
+
+int ldb_module_send_entry(struct ldb_request *req,
+ struct ldb_message *msg,
+ struct ldb_control **ctrls);
+
+int ldb_module_send_referral(struct ldb_request *req,
+ char *ref);
+
+int ldb_module_done(struct ldb_request *req,
+ struct ldb_control **ctrls,
+ struct ldb_extended *response,
+ int error);
+
+int ldb_mod_register_control(struct ldb_module *module, const char *oid);
+
+#endif
#ifndef _LDB_PRIVATE_H_
#define _LDB_PRIVATE_H_ 1
+#include "ldb.h"
+#include "ldb_module.h"
+
struct ldb_context;
struct ldb_module_ops;
const struct ldb_module_ops *ops;
};
-/*
- these function pointers define the operations that a ldb module can intercept
-*/
-struct ldb_module_ops {
- const char *name;
- int (*init_context) (struct ldb_module *);
- int (*search)(struct ldb_module *, struct ldb_request *); /* search */
- int (*add)(struct ldb_module *, struct ldb_request *); /* add */
- int (*modify)(struct ldb_module *, struct ldb_request *); /* modify */
- int (*del)(struct ldb_module *, struct ldb_request *); /* delete */
- int (*rename)(struct ldb_module *, struct ldb_request *); /* rename */
- int (*request)(struct ldb_module *, struct ldb_request *); /* match any other operation */
- int (*extended)(struct ldb_module *, struct ldb_request *); /* extended operations */
- int (*start_transaction)(struct ldb_module *);
- int (*end_transaction)(struct ldb_module *);
- int (*del_transaction)(struct ldb_module *);
- int (*sequence_number)(struct ldb_module *, struct ldb_request *);
- void *private_data;
-};
-
/*
schema related information needed for matching rules
*/
#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
#endif
-/*
- simplify out of memory handling
-*/
-#define ldb_oom(ldb) ldb_debug_set(ldb, LDB_DEBUG_FATAL, "ldb out of memory at %s:%d\n", __FILE__, __LINE__)
-
/* The following definitions come from lib/ldb/common/ldb.c */
int ldb_connect_backend(struct ldb_context *ldb, const char *url, const char *options[],
struct ldb_module **backend_module);
void ldb_set_default_dns(struct ldb_context *ldb);
-/* The following definitions come from lib/ldb/common/ldb_debug.c */
-void ldb_debug(struct ldb_context *ldb, enum ldb_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
-void ldb_debug_set(struct ldb_context *ldb, enum ldb_debug_level level,
- const char *fmt, ...) PRINTF_ATTRIBUTE(3, 4);
-
-/* The following definitions come from lib/ldb/common/ldb_ldif.c */
-int ldb_should_b64_encode(const struct ldb_val *val);
extern const struct ldb_module_ops ldb_objectclass_module_ops;
extern const struct ldb_module_ops ldb_operational_module_ops;
extern const struct ldb_backend_ops ldb_ldapi_backend_ops;
extern const struct ldb_backend_ops ldb_ldaps_backend_ops;
-int ldb_match_msg(struct ldb_context *ldb,
- const struct ldb_message *msg,
- const struct ldb_parse_tree *tree,
- struct ldb_dn *base,
- enum ldb_scope scope);
-
-const struct ldb_schema_syntax *ldb_standard_syntax_by_name(struct ldb_context *ldb,
- const char *syntax);
-
-/* The following definitions come from lib/ldb/common/ldb_attributes.c */
-
-int ldb_schema_attribute_add_with_syntax(struct ldb_context *ldb,
- const char *name,
- unsigned flags,
- const struct ldb_schema_syntax *syntax);
-int ldb_schema_attribute_add(struct ldb_context *ldb,
- const char *name,
- unsigned flags,
- const char *syntax);
-void ldb_schema_attribute_remove(struct ldb_context *ldb, const char *name);
int ldb_setup_wellknown_attributes(struct ldb_context *ldb);
const char **ldb_subclass_list(struct ldb_context *ldb, const char *classname);
int ldb_comparison_binary(struct ldb_context *ldb, void *mem_ctx,
const struct ldb_val *v1, const struct ldb_val *v2);
-/* The following definitions come from lib/ldb/common/ldb_controls.c */
-struct ldb_control *get_control_from_list(struct ldb_control **controls, const char *oid);
-int save_controls(struct ldb_control *exclude, struct ldb_request *req, struct ldb_control ***saver);
-int check_critical_controls(struct ldb_control **controls);
-
/* The following definitions come from lib/ldb/common/ldb_utf8.c */
char *ldb_casefold_default(void *context, void *mem_ctx, const char *s, size_t n);
#define LDB_SEQ_TIMESTAMP_SEQUENCE 0x02
-/* MODULES specific headers -- SSS */
-
/* The following definitions come from lib/ldb/common/ldb_modules.c */
const char **ldb_modules_list_from_string(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char *string);
int ldb_load_modules_list(struct ldb_context *ldb, const char **module_list, struct ldb_module *backend, struct ldb_module **out);
int ldb_load_modules(struct ldb_context *ldb, const char *options[]);
int ldb_init_module_chain(struct ldb_context *ldb, struct ldb_module *module);
-int ldb_next_request(struct ldb_module *module, struct ldb_request *request);
-int ldb_next_start_trans(struct ldb_module *module);
-int ldb_next_end_trans(struct ldb_module *module);
-int ldb_next_del_trans(struct ldb_module *module);
-int ldb_next_init(struct ldb_module *module);
-
-void ldb_set_errstring(struct ldb_context *ldb, const char *err_string);
-void ldb_asprintf_errstring(struct ldb_context *ldb, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
-void ldb_reset_err_string(struct ldb_context *ldb);
-
-const char *ldb_default_modules_dir(void);
-
-int ldb_register_module(const struct ldb_module_ops *);
-
-typedef int (*ldb_connect_fn)(struct ldb_context *ldb, const char *url,
- unsigned int flags, const char *options[],
- struct ldb_module **module);
-
-struct ldb_backend_ops {
- const char *name;
- ldb_connect_fn connect_fn;
-};
-
-const char *ldb_default_modules_dir(void);
-
-int ldb_register_backend(const char *url_prefix, ldb_connect_fn);
-
-struct ldb_handle *ldb_handle_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb);
-
-int ldb_module_send_entry(struct ldb_request *req,
- struct ldb_message *msg,
- struct ldb_control **ctrls);
-
-int ldb_module_send_referral(struct ldb_request *req,
- char *ref);
-
-int ldb_module_done(struct ldb_request *req,
- struct ldb_control **ctrls,
- struct ldb_extended *response,
- int error);
-
-int ldb_mod_register_control(struct ldb_module *module, const char *oid);
-
struct ldb_val ldb_binary_decode(void *mem_ctx, const char *str);
#include "includes.h"
-#include "ldb_includes.h"
+#include "ldb_module.h"
#include "tevent.h"
#include "libcli/ldap/ldap.h"
static void ildb_request_done(struct ildb_context *ctx,
struct ldb_control **ctrls, int error)
{
+ struct ldb_context *ldb;
struct ldb_reply *ares;
+ ldb = ldb_module_get_ctx(ctx->module);
+
ctx->done = true;
if (ctx->req == NULL) {
ares = talloc_zero(ctx->req, struct ldb_reply);
if (!ares) {
- ldb_oom(ctx->req->handle->ldb);
+ ldb_oom(ldb);
ctx->req->callback(ctx->req, NULL);
return;
}
*/
static int ildb_map_error(struct ldb_module *module, NTSTATUS status)
{
- struct ildb_private *ildb = talloc_get_type(module->private_data, struct ildb_private);
+ struct ildb_private *ildb;
+ struct ldb_context *ldb;
+
+ ildb = talloc_get_type(ldb_module_get_private(module), struct ildb_private);
+ ldb = ldb_module_get_ctx(module);
TALLOC_CTX *mem_ctx = talloc_new(ildb);
if (NT_STATUS_IS_OK(status)) {
return LDB_SUCCESS;
}
if (!mem_ctx) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- ldb_set_errstring(module->ldb,
+ ldb_set_errstring(ldb,
ldap_errstr(ildb->ldap, mem_ctx, status));
talloc_free(mem_ctx);
if (NT_STATUS_IS_LDAP(status)) {
static void ildb_callback(struct ldap_request *req)
{
+ struct ldb_context *ldb;
struct ildb_context *ac;
NTSTATUS status;
struct ldap_SearchResEntry *search;
int i;
ac = talloc_get_type(req->async.private_data, struct ildb_context);
+ ldb = ldb_module_get_ctx(ac->module);
callback_failed = false;
request_done = false;
controls = NULL;
controls = talloc_steal(ac, msg->controls);
if (msg->r.SearchResultDone.resultcode) {
if (msg->r.SearchResultDone.errormessage) {
- ldb_set_errstring(ac->module->ldb, msg->r.SearchResultDone.errormessage);
+ ldb_set_errstring(ldb, msg->r.SearchResultDone.errormessage);
}
}
search = &(msg->r.SearchResultEntry);
- ldbmsg->dn = ldb_dn_new(ldbmsg, ac->module->ldb, search->dn);
+ ldbmsg->dn = ldb_dn_new(ldbmsg, ldb, search->dn);
if ( ! ldb_dn_validate(ldbmsg->dn)) {
ret = LDB_ERR_OPERATIONS_ERROR;
break;
static int ildb_request_send(struct ildb_context *ac, struct ldap_message *msg)
{
+ struct ldb_context *ldb;
struct ldap_request *req;
if (!ac) {
return LDB_ERR_OPERATIONS_ERROR;
}
+ ldb = ldb_module_get_ctx(ac->module);
+
req = ldap_request_send(ac->ildb->ldap, msg);
if (req == NULL) {
- ldb_set_errstring(ac->module->ldb, "async send request failed");
+ ldb_set_errstring(ldb, "async send request failed");
return LDB_ERR_OPERATIONS_ERROR;
}
ac->ireq = talloc_steal(ac, req);
if (!ac->ireq->conn) {
- ldb_set_errstring(ac->module->ldb, "connection to remote LDAP server dropped?");
+ ldb_set_errstring(ldb, "connection to remote LDAP server dropped?");
return LDB_ERR_OPERATIONS_ERROR;
}
*/
static int ildb_search(struct ildb_context *ac)
{
+ struct ldb_context *ldb;
struct ldb_request *req = ac->req;
struct ldap_message *msg;
int n;
+ ldb = ldb_module_get_ctx(ac->module);
+
if (!req->callback || !req->context) {
- ldb_set_errstring(ac->module->ldb, "Async interface called with NULL callback function or NULL context");
+ ldb_set_errstring(ldb, "Async interface called with NULL callback function or NULL context");
return LDB_ERR_OPERATIONS_ERROR;
}
if (req->op.search.tree == NULL) {
- ldb_set_errstring(ac->module->ldb, "Invalid expression parse tree");
+ ldb_set_errstring(ldb, "Invalid expression parse tree");
return LDB_ERR_OPERATIONS_ERROR;
}
msg = new_ldap_message(req);
if (msg == NULL) {
- ldb_set_errstring(ac->module->ldb, "Out of Memory");
+ ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
msg->r.SearchRequest.basedn = ldb_dn_get_extended_linearized(msg, req->op.search.base, 0);
}
if (msg->r.SearchRequest.basedn == NULL) {
- ldb_set_errstring(ac->module->ldb, "Unable to determine baseDN");
+ ldb_set_errstring(ldb, "Unable to determine baseDN");
talloc_free(msg);
return LDB_ERR_OPERATIONS_ERROR;
}
static int ildb_handle_request(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct ildb_private *ildb;
struct ildb_context *ac;
struct tevent_timer *te;
int ret;
- ildb = talloc_get_type(module->private_data, struct ildb_private);
+ ildb = talloc_get_type(ldb_module_get_private(module), struct ildb_private);
+ ldb = ldb_module_get_ctx(module);
if (req->starttime == 0 || req->timeout == 0) {
- ldb_set_errstring(module->ldb, "Invalid timeout settings");
+ ldb_set_errstring(ldb, "Invalid timeout settings");
return LDB_ERR_TIME_LIMIT_EXCEEDED;
}
ac = talloc_zero(req, struct ildb_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
+ ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
NTSTATUS status;
struct cli_credentials *creds;
- module = talloc(ldb, struct ldb_module);
- if (!module) {
- ldb_oom(ldb);
- return -1;
- }
- talloc_set_name_const(module, "ldb_ildap backend");
- module->ldb = ldb;
- module->prev = module->next = NULL;
- module->ops = &ildb_ops;
+ module = ldb_module_new(ldb, ldb, "ldb_ildap backend", &ildb_ops);
+ if (!module) return -1;
ildb = talloc(module, struct ildb_private);
if (!ildb) {
ldb_oom(ldb);
goto failed;
}
- module->private_data = ildb;
+ ldb_module_set_private(module, ildb);
ildb->event_ctx = ldb_get_event_context(ldb);
* author: Simo Sorce
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
#define LDAP_DEPRECATED 1
#include <ldap.h>
*/
static int lldb_search(struct lldb_context *lldb_ac)
{
+ struct ldb_context *ldb;
struct lldb_private *lldb = lldb_ac->lldb;
struct ldb_module *module = lldb_ac->module;
struct ldb_request *req = lldb_ac->req;
char *expression;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
if (!req->callback || !req->context) {
- ldb_set_errstring(module->ldb, "Async interface called with NULL callback function or NULL context");
+ ldb_set_errstring(ldb, "Async interface called with NULL callback function or NULL context");
return LDB_ERR_OPERATIONS_ERROR;
}
if (req->op.search.tree == NULL) {
- ldb_set_errstring(module->ldb, "Invalid expression parse tree");
+ ldb_set_errstring(ldb, "Invalid expression parse tree");
return LDB_ERR_OPERATIONS_ERROR;
}
if (req->controls != NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "Controls are not yet supported by ldb_ldap backend!\n");
+ ldb_debug(ldb, LDB_DEBUG_WARNING, "Controls are not yet supported by ldb_ldap backend!\n");
}
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
search_base = ldb_dn_alloc_linearized(lldb_ac, req->op.search.base);
if (req->op.search.base == NULL) {
&lldb_ac->msgid);
if (ret != LDAP_SUCCESS) {
- ldb_set_errstring(module->ldb, ldap_err2string(ret));
+ ldb_set_errstring(ldb, ldap_err2string(ret));
}
return lldb_ldap_to_ldb(ret);
*/
static int lldb_add(struct lldb_context *lldb_ac)
{
+ struct ldb_context *ldb;
struct lldb_private *lldb = lldb_ac->lldb;
struct ldb_module *module = lldb_ac->module;
struct ldb_request *req = lldb_ac->req;
char *dn;
int ret;
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_module_get_ctx(module);
+
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
mods = lldb_msg_to_mods(lldb_ac, req->op.add.message, 0);
if (mods == NULL) {
&lldb_ac->msgid);
if (ret != LDAP_SUCCESS) {
- ldb_set_errstring(module->ldb, ldap_err2string(ret));
+ ldb_set_errstring(ldb, ldap_err2string(ret));
}
return lldb_ldap_to_ldb(ret);
*/
static int lldb_modify(struct lldb_context *lldb_ac)
{
+ struct ldb_context *ldb;
struct lldb_private *lldb = lldb_ac->lldb;
struct ldb_module *module = lldb_ac->module;
struct ldb_request *req = lldb_ac->req;
char *dn;
int ret;
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_module_get_ctx(module);
+
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
mods = lldb_msg_to_mods(lldb_ac, req->op.mod.message, 1);
if (mods == NULL) {
&lldb_ac->msgid);
if (ret != LDAP_SUCCESS) {
- ldb_set_errstring(module->ldb, ldap_err2string(ret));
+ ldb_set_errstring(ldb, ldap_err2string(ret));
}
return lldb_ldap_to_ldb(ret);
*/
static int lldb_delete(struct lldb_context *lldb_ac)
{
+ struct ldb_context *ldb;
struct lldb_private *lldb = lldb_ac->lldb;
struct ldb_module *module = lldb_ac->module;
struct ldb_request *req = lldb_ac->req;
char *dnstr;
int ret;
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_module_get_ctx(module);
+
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
dnstr = ldb_dn_alloc_linearized(lldb_ac, req->op.del.dn);
&lldb_ac->msgid);
if (ret != LDAP_SUCCESS) {
- ldb_set_errstring(module->ldb, ldap_err2string(ret));
+ ldb_set_errstring(ldb, ldap_err2string(ret));
}
return lldb_ldap_to_ldb(ret);
*/
static int lldb_rename(struct lldb_context *lldb_ac)
{
+ struct ldb_context *ldb;
struct lldb_private *lldb = lldb_ac->lldb;
struct ldb_module *module = lldb_ac->module;
struct ldb_request *req = lldb_ac->req;
char *parentdn;
int ret;
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_module_get_ctx(module);
+
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
old_dn = ldb_dn_alloc_linearized(lldb_ac, req->op.rename.olddn);
if (old_dn == NULL) {
&lldb_ac->msgid);
if (ret != LDAP_SUCCESS) {
- ldb_set_errstring(module->ldb, ldap_err2string(ret));
+ ldb_set_errstring(ldb, ldap_err2string(ret));
}
return lldb_ldap_to_ldb(ret);
return LDB_SUCCESS;
}
-void lldb_request_done(struct ldb_request *req,
+void lldb_request_done(struct lldb_context *ac,
struct ldb_control **ctrls, int error)
{
+ struct ldb_request *req;
struct ldb_reply *ares;
+ req = ac->req;
+
ares = talloc_zero(req, struct ldb_reply);
if (!ares) {
- ldb_oom(req->handle->ldb);
+ ldb_oom(ldb_module_get_ctx(ac->module));
req->callback(req, NULL);
return;
}
*/
static bool lldb_parse_result(struct lldb_context *ac, LDAPMessage *result)
{
+ struct ldb_context *ldb;
struct lldb_private *lldb = ac->lldb;
LDAPControl **serverctrlsp = NULL;
char **referralsp = NULL;
int ret;
int i;
+ ldb = ldb_module_get_ctx(ac->module);
+
type = ldap_msgtype(result);
callback_failed = false;
request_done = false;
ret = LDB_ERR_OPERATIONS_ERROR;
break;
}
- ldbmsg->dn = ldb_dn_new(ldbmsg, ac->module->ldb, dn);
+ ldbmsg->dn = ldb_dn_new(ldbmsg, ldb, dn);
if ( ! ldb_dn_validate(ldbmsg->dn)) {
talloc_free(ldbmsg);
ret = LDB_ERR_OPERATIONS_ERROR;
bval = ldap_get_values_len(lldb->ldap, msg, attr);
if (bval) {
- lldb_add_msg_attr(ac->module->ldb, ldbmsg, attr, bval);
+ lldb_add_msg_attr(ldb, ldbmsg, attr, bval);
ldap_value_free_len(bval);
}
}
}
if (request_done) {
- lldb_request_done(ac->req, ac->controls, ret);
+ lldb_request_done(ac, ac->controls, ret);
lret = true;
goto free_and_return;
}
if (matcheddnp) ldap_memfree(matcheddnp);
if (errmsgp && *errmsgp) {
- ldb_set_errstring(ac->module->ldb, errmsgp);
+ ldb_set_errstring(ldb, errmsgp);
}
if (errmsgp) {
ldap_memfree(errmsgp);
struct lldb_context *ac;
ac = talloc_get_type(private_data, struct lldb_context);
- lldb_request_done(ac->req, NULL, LDB_ERR_TIME_LIMIT_EXCEEDED);
+ lldb_request_done(ac, NULL, LDB_ERR_TIME_LIMIT_EXCEEDED);
}
static void lldb_callback(struct tevent_context *ev,
ac = talloc_get_type(private_data, struct lldb_context);
if (!ac->msgid) {
- lldb_request_done(ac->req, NULL, LDB_ERR_OPERATIONS_ERROR);
+ lldb_request_done(ac, NULL, LDB_ERR_OPERATIONS_ERROR);
return;
}
goto respin;
}
if (lret == -1) {
- lldb_request_done(ac->req, NULL, LDB_ERR_OPERATIONS_ERROR);
+ lldb_request_done(ac, NULL, LDB_ERR_OPERATIONS_ERROR);
return;
}
respin:
tv.tv_sec = 0;
tv.tv_usec = 100;
- lte = event_add_timed(ev, ac, tv, lldb_callback, ac);
+ lte = tevent_add_timer(ev, ac, tv, lldb_callback, ac);
if (NULL == lte) {
- lldb_request_done(ac->req, NULL, LDB_ERR_OPERATIONS_ERROR);
+ lldb_request_done(ac, NULL, LDB_ERR_OPERATIONS_ERROR);
}
}
struct lldb_context *ac;
ac = talloc_get_type(private_data, struct lldb_context);
- lldb_request_done(ac->req, NULL, LDB_SUCCESS);
+ lldb_request_done(ac, NULL, LDB_SUCCESS);
}
static int lldb_handle_request(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct lldb_private *lldb;
struct lldb_context *ac;
struct tevent_context *ev;
struct timeval tv;
int ret;
- lldb = talloc_get_type(module->private_data, struct lldb_private);
+ lldb = talloc_get_type(ldb_module_get_private(module), struct lldb_private);
+ ldb = ldb_module_get_ctx(module);
if (req->starttime == 0 || req->timeout == 0) {
- ldb_set_errstring(module->ldb, "Invalid timeout settings");
+ ldb_set_errstring(ldb, "Invalid timeout settings");
return LDB_ERR_TIME_LIMIT_EXCEEDED;
}
- ev = ldb_get_event_context(module->ldb);
+ ev = ldb_get_event_context(ldb);
if (NULL == ev) {
return LDB_ERR_OPERATIONS_ERROR;
}
- ac = talloc_zero(module->ldb, struct lldb_context);
+ ac = talloc_zero(ldb, struct lldb_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
+ ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
if (lldb_dn_is_special(req)) {
tv.tv_sec = 0;
tv.tv_usec = 0;
- te = event_add_timed(ev, ac, tv,
+ te = tevent_add_timer(ev, ac, tv,
lldb_auto_done_callback, ac);
if (NULL == te) {
return LDB_ERR_OPERATIONS_ERROR;
}
if (ret != LDB_SUCCESS) {
- lldb_request_done(req, NULL, ret);
+ lldb_request_done(ac, NULL, ret);
return ret;
}
tv.tv_sec = 0;
tv.tv_usec = 0;
- te = event_add_timed(ev, ac, tv, lldb_callback, ac);
+ te = tevent_add_timer(ev, ac, tv, lldb_callback, ac);
if (NULL == te) {
return LDB_ERR_OPERATIONS_ERROR;
}
tv.tv_sec = req->starttime + req->timeout;
tv.tv_usec = 0;
- te = event_add_timed(ev, ac, tv, lldb_timeout, ac);
+ te = tevent_add_timer(ev, ac, tv, lldb_timeout, ac);
if (NULL == te) {
return LDB_ERR_OPERATIONS_ERROR;
}
int version = 3;
int ret;
- module = talloc(ldb, struct ldb_module);
- if (module == NULL) {
- ldb_oom(ldb);
- talloc_free(lldb);
- return -1;
- }
- talloc_set_name_const(module, "ldb_ldap backend");
- module->ldb = ldb;
- module->prev = module->next = NULL;
- module->ops = &lldb_ops;
+ module = ldb_module_new(ldb, ldb, "ldb_ldap backend", &lldb_ops);
+ if (!module) return -1;
- lldb = talloc(module, struct lldb_private);
+ lldb = talloc_zero(module, struct lldb_private);
if (!lldb) {
ldb_oom(ldb);
goto failed;
}
- module->private_data = lldb;
- lldb->ldap = NULL;
+ ldb_module_set_private(module, lldb);
ret = ldap_initialize(&lldb->ldap, url);
if (ret != LDAP_SUCCESS) {
* Author: Jelmer Vernooij, Martin Kuehl
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
#include "ldb_map.h"
#include "ldb_map_private.h"
/* Extract mappings from private data. */
const struct ldb_map_context *map_get_context(struct ldb_module *module)
{
- const struct map_private *data = talloc_get_type(module->private_data, struct map_private);
+ const struct map_private *data = talloc_get_type(ldb_module_get_private(module), struct map_private);
return data->context;
}
struct map_context *map_init_context(struct ldb_module *module,
struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct map_context *ac;
+ ldb = ldb_module_get_ctx(module);
+
ac = talloc_zero(req, struct map_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
+ ldb_set_errstring(ldb, "Out of Memory");
return NULL;
}
int ldb_next_remote_request(struct ldb_module *module, struct ldb_request *request)
{
const struct ldb_map_context *data = map_get_context(module);
+ struct ldb_context *ldb;
struct ldb_message *msg;
+ ldb = ldb_module_get_ctx(module);
+
switch (request->operation) {
case LDB_SEARCH:
if (request->op.search.base) {
break;
default:
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"Invalid remote request!\n");
return LDB_ERR_OPERATIONS_ERROR;
}
struct ldb_dn *ldb_dn_map_local(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn)
{
const struct ldb_map_context *data = map_get_context(module);
+ struct ldb_context *ldb;
struct ldb_dn *newdn;
const struct ldb_map_attribute *map;
enum ldb_map_attr_type map_type;
return NULL;
}
+ ldb = ldb_module_get_ctx(module);
+
newdn = ldb_dn_copy(mem_ctx, dn);
if (newdn == NULL) {
map_oom(module);
switch (map_type) {
case MAP_IGNORE:
case MAP_GENERATE:
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"MAP_IGNORE/MAP_GENERATE attribute '%s' "
"used in DN!\n", ldb_dn_get_component_name(dn, i));
goto failed;
case MAP_CONVERT:
if (map->u.convert.convert_local == NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"'convert_local' not set for attribute '%s' "
"used in DN!\n", ldb_dn_get_component_name(dn, i));
goto failed;
struct ldb_dn *ldb_dn_map_remote(struct ldb_module *module, void *mem_ctx, struct ldb_dn *dn)
{
const struct ldb_map_context *data = map_get_context(module);
+ struct ldb_context *ldb;
struct ldb_dn *newdn;
const struct ldb_map_attribute *map;
enum ldb_map_attr_type map_type;
return NULL;
}
+ ldb = ldb_module_get_ctx(module);
+
newdn = ldb_dn_copy(mem_ctx, dn);
if (newdn == NULL) {
map_oom(module);
switch (map_type) {
case MAP_IGNORE:
case MAP_GENERATE:
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"MAP_IGNORE/MAP_GENERATE attribute '%s' "
"used in DN!\n", ldb_dn_get_component_name(dn, i));
goto failed;
case MAP_CONVERT:
if (map->u.convert.convert_remote == NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"'convert_remote' not set for attribute '%s' "
"used in DN!\n", ldb_dn_get_component_name(dn, i));
goto failed;
/* Map a DN contained in an ldb value into the remote partition. */
static struct ldb_val ldb_dn_convert_local(struct ldb_module *module, void *mem_ctx, const struct ldb_val *val)
{
+ struct ldb_context *ldb;
struct ldb_dn *dn, *newdn;
struct ldb_val newval;
- dn = ldb_dn_from_ldb_val(mem_ctx, module->ldb, val);
+ ldb = ldb_module_get_ctx(module);
+
+ dn = ldb_dn_from_ldb_val(mem_ctx, ldb, val);
if (! ldb_dn_validate(dn)) {
newval.length = 0;
newval.data = NULL;
/* Map a DN contained in an ldb value into the local partition. */
static struct ldb_val ldb_dn_convert_remote(struct ldb_module *module, void *mem_ctx, const struct ldb_val *val)
{
+ struct ldb_context *ldb;
struct ldb_dn *dn, *newdn;
struct ldb_val newval;
- dn = ldb_dn_from_ldb_val(mem_ctx, module->ldb, val);
+ ldb = ldb_module_get_ctx(module);
+
+ dn = ldb_dn_from_ldb_val(mem_ctx, ldb, val);
if (! ldb_dn_validate(dn)) {
newval.length = 0;
newval.data = NULL;
static void map_objectclass_generate_remote(struct ldb_module *module, const char *local_attr, const struct ldb_message *old, struct ldb_message *remote, struct ldb_message *local)
{
const struct ldb_map_context *data = map_get_context(module);
+ struct ldb_context *ldb;
struct ldb_message_element *el, *oc;
struct ldb_val val;
bool found_extensibleObject = false;
int i;
+ ldb = ldb_module_get_ctx(module);
+
/* Find old local objectClass */
oc = ldb_msg_find_element(old, "objectClass");
if (oc == NULL) {
/* Prepare new element */
el = talloc_zero(remote, struct ldb_message_element);
if (el == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return; /* TODO: fail? */
}
el->values = talloc_array(el, struct ldb_val, el->num_values);
if (el->values == NULL) {
talloc_free(el);
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return; /* TODO: fail? */
}
static struct ldb_message_element *map_objectclass_generate_local(struct ldb_module *module, void *mem_ctx, const char *local_attr, const struct ldb_message *remote)
{
const struct ldb_map_context *data = map_get_context(module);
+ struct ldb_context *ldb;
struct ldb_message_element *el, *oc;
struct ldb_val val;
int i;
+ ldb = ldb_module_get_ctx(module);
+
/* Find old remote objectClass */
oc = ldb_msg_find_element(remote, "objectClass");
if (oc == NULL) {
/* Prepare new element */
el = talloc_zero(mem_ctx, struct ldb_message_element);
if (el == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return NULL;
}
el->values = talloc_array(el, struct ldb_val, el->num_values);
if (el->values == NULL) {
talloc_free(el);
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return NULL;
}
el->values = talloc_realloc(el, el->values, struct ldb_val, el->num_values);
if (el->values == NULL) {
talloc_free(el);
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return NULL;
}
}
struct ldb_request *map_search_base_req(struct map_context *ac, struct ldb_dn *dn, const char * const *attrs, const struct ldb_parse_tree *tree, void *context, ldb_map_callback_t callback)
{
const struct ldb_parse_tree *search_tree;
+ struct ldb_context *ldb;
struct ldb_request *req;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
if (tree) {
search_tree = tree;
} else {
}
}
- ret = ldb_build_search_req_ex(&req, ac->module->ldb, ac,
+ ret = ldb_build_search_req_ex(&req, ldb, ac,
dn, LDB_SCOPE_BASE,
search_tree, attrs,
NULL,
void *context,
ldb_map_callback_t callback)
{
+ struct ldb_context *ldb;
struct ldb_request *req;
struct ldb_message *msg;
const char *dn;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
/* Prepare message */
msg = ldb_msg_new(ac);
if (msg == NULL) {
}
/* Prepare request */
- ret = ldb_build_mod_req(&req, ac->module->ldb,
+ ret = ldb_build_mod_req(&req, ldb,
ac, msg, NULL,
context, callback,
ac->req);
static int map_init_dns(struct ldb_module *module, struct ldb_map_context *data, const char *name)
{
static const char * const attrs[] = { MAP_DN_FROM, MAP_DN_TO, NULL };
+ struct ldb_context *ldb;
struct ldb_dn *dn;
struct ldb_message *msg;
struct ldb_result *res;
return LDB_SUCCESS;
}
- dn = ldb_dn_new_fmt(data, module->ldb, "%s=%s", MAP_DN_NAME, name);
+ ldb = ldb_module_get_ctx(module);
+
+ dn = ldb_dn_new_fmt(data, ldb, "%s=%s", MAP_DN_NAME, name);
if ( ! ldb_dn_validate(dn)) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"Failed to construct '%s' DN!\n", MAP_DN_NAME);
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ldb_search(module->ldb, data, &res, dn, LDB_SCOPE_BASE, attrs, NULL);
+ ret = ldb_search(ldb, data, &res, dn, LDB_SCOPE_BASE, attrs, NULL);
talloc_free(dn);
if (ret != LDB_SUCCESS) {
return ret;
}
if (res->count == 0) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"No results for '%s=%s'!\n", MAP_DN_NAME, name);
talloc_free(res);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
if (res->count > 1) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"Too many results for '%s=%s'!\n", MAP_DN_NAME, name);
talloc_free(res);
return LDB_ERR_CONSTRAINT_VIOLATION;
}
msg = res->msgs[0];
- data->local_base_dn = ldb_msg_find_attr_as_dn(module->ldb, data, msg, MAP_DN_FROM);
- data->remote_base_dn = ldb_msg_find_attr_as_dn(module->ldb, data, msg, MAP_DN_TO);
+ data->local_base_dn = ldb_msg_find_attr_as_dn(ldb, data, msg, MAP_DN_FROM);
+ data->remote_base_dn = ldb_msg_find_attr_as_dn(ldb, data, msg, MAP_DN_TO);
talloc_free(res);
return LDB_SUCCESS;
return LDB_ERR_OPERATIONS_ERROR;
}
- module->private_data = data;
+ ldb_module_set_private(module, data);
data->context = talloc_zero(data, struct ldb_map_context);
if (!data->context) {
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
#include "ldb_map.h"
#include "ldb_map_private.h"
const struct ldb_map_context *data = map_get_context(module);
const struct ldb_map_attribute *map = map_attr_find_local(data, attr_name);
struct ldb_message_element *el=NULL;
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
/* Unknown attribute: ignore */
if (map == NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: "
"Not mapping attribute '%s': no mapping found\n",
old->name);
goto local;
case MAP_CONVERT:
if (map->u.convert.convert_local == NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: "
"Not mapping attribute '%s': "
"'convert_local' not set\n",
map->local_name);
case MAP_GENERATE:
if (map->u.generate.generate_remote == NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: "
"Not mapping attribute '%s': "
"'generate_remote' not set\n",
map->local_name);
static int ldb_msg_partition(struct ldb_module *module, struct ldb_message *local, struct ldb_message *remote, const struct ldb_message *msg)
{
/* const char * const names[]; */
+ struct ldb_context *ldb;
int i, ret;
+ ldb = ldb_module_get_ctx(module);
+
for (i = 0; i < msg->num_elements; i++) {
/* Skip 'IS_MAPPED' */
if (ldb_attr_cmp(msg->elements[i].name, IS_MAPPED) == 0) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: "
"Skipping attribute '%s'\n",
msg->elements[i].name);
continue;
/* Store the DN of a single search result in context. */
static int map_search_self_callback(struct ldb_request *req, struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct map_context *ac;
int ret;
ac = talloc_get_type(req->context, struct map_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
case LDB_REPLY_ENTRY:
/* We have already found a remote DN */
if (ac->local_dn) {
- ldb_set_errstring(ac->module->ldb,
+ ldb_set_errstring(ldb,
"Too many results!");
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
static int map_op_local_callback(struct ldb_request *req,
struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct map_context *ac;
int ret;
ac = talloc_get_type(req->context, struct map_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
}
if (ares->type != LDB_REPLY_DONE) {
- ldb_set_errstring(req->handle->ldb, "Invalid reply type!");
+ ldb_set_errstring(ldb, "Invalid reply type!");
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
static int map_op_remote_callback(struct ldb_request *req,
struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct map_context *ac;
ac = talloc_get_type(req->context, struct map_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
}
if (ares->type != LDB_REPLY_DONE) {
- ldb_set_errstring(req->handle->ldb, "Invalid reply type!");
+ ldb_set_errstring(ldb, "Invalid reply type!");
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
int map_add(struct ldb_module *module, struct ldb_request *req)
{
const struct ldb_message *msg = req->op.add.message;
+ struct ldb_context *ldb;
struct map_context *ac;
struct ldb_message *remote_msg;
const char *dn;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
/* Do not manipulate our control entries */
if (ldb_dn_is_special(msg->dn)) {
return ldb_next_request(module, req);
ldb_msg_partition(module, ac->local_msg, remote_msg, msg);
/* Prepare the remote operation */
- ret = ldb_build_add_req(&ac->remote_req, module->ldb,
+ ret = ldb_build_add_req(&ac->remote_req, ldb,
ac, remote_msg,
req->controls,
ac, map_op_remote_callback,
static int map_add_do_local(struct map_context *ac)
{
struct ldb_request *local_req;
+ struct ldb_context *ldb;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
/* Prepare the local operation */
- ret = ldb_build_add_req(&local_req, ac->module->ldb, ac,
+ ret = ldb_build_add_req(&local_req, ldb, ac,
ac->local_msg,
ac->req->controls,
ac,
const struct ldb_message *msg = req->op.mod.message;
struct ldb_request *search_req;
struct ldb_message *remote_msg;
+ struct ldb_context *ldb;
struct map_context *ac;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
/* Do not manipulate our control entries */
if (ldb_dn_is_special(msg->dn)) {
return ldb_next_request(module, req);
ldb_msg_partition(module, ac->local_msg, remote_msg, msg);
/* Prepare the remote operation */
- ret = ldb_build_mod_req(&ac->remote_req, module->ldb,
+ ret = ldb_build_mod_req(&ac->remote_req, ldb,
ac, remote_msg,
req->controls,
ac, map_op_remote_callback,
static int map_modify_do_local(struct map_context *ac)
{
struct ldb_request *local_req;
+ struct ldb_context *ldb;
char *dn;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
if (ac->local_dn == NULL) {
/* No local record present, add it instead */
/* Add local 'IS_MAPPED' */
}
/* Prepare the local operation */
- ret = ldb_build_add_req(&local_req, ac->module->ldb, ac,
+ ret = ldb_build_add_req(&local_req, ldb, ac,
ac->local_msg,
ac->req->controls,
ac,
}
} else {
/* Prepare the local operation */
- ret = ldb_build_mod_req(&local_req, ac->module->ldb, ac,
+ ret = ldb_build_mod_req(&local_req, ldb, ac,
ac->local_msg,
ac->req->controls,
ac,
int map_delete(struct ldb_module *module, struct ldb_request *req)
{
struct ldb_request *search_req;
+ struct ldb_context *ldb;
struct map_context *ac;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
/* Do not manipulate our control entries */
if (ldb_dn_is_special(req->op.del.dn)) {
return ldb_next_request(module, req);
}
/* Prepare the remote operation */
- ret = ldb_build_del_req(&ac->remote_req, module->ldb, ac,
+ ret = ldb_build_del_req(&ac->remote_req, ldb, ac,
ldb_dn_map_local(module, ac, req->op.del.dn),
req->controls,
ac,
static int map_delete_do_local(struct map_context *ac)
{
struct ldb_request *local_req;
+ struct ldb_context *ldb;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
/* No local record, continue remotely */
if (ac->local_dn == NULL) {
/* Do the remote request. */
}
/* Prepare the local operation */
- ret = ldb_build_del_req(&local_req, ac->module->ldb, ac,
+ ret = ldb_build_del_req(&local_req, ldb, ac,
ac->req->op.del.dn,
ac->req->controls,
ac,
int map_rename(struct ldb_module *module, struct ldb_request *req)
{
struct ldb_request *search_req;
+ struct ldb_context *ldb;
struct map_context *ac;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
/* Do not manipulate our control entries */
if (ldb_dn_is_special(req->op.rename.olddn)) {
return ldb_next_request(module, req);
}
/* Prepare the remote operation */
- ret = ldb_build_rename_req(&ac->remote_req, module->ldb, ac,
+ ret = ldb_build_rename_req(&ac->remote_req, ldb, ac,
ldb_dn_map_local(module, ac, req->op.rename.olddn),
ldb_dn_map_local(module, ac, req->op.rename.newdn),
req->controls,
static int map_rename_do_local(struct map_context *ac)
{
struct ldb_request *local_req;
+ struct ldb_context *ldb;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
/* No local record, continue remotely */
if (ac->local_dn == NULL) {
/* Do the remote request. */
}
/* Prepare the local operation */
- ret = ldb_build_rename_req(&local_req, ac->module->ldb, ac,
+ ret = ldb_build_rename_req(&local_req, ldb, ac,
ac->req->op.rename.olddn,
ac->req->op.rename.newdn,
ac->req->controls,
static int map_rename_local_callback(struct ldb_request *req,
struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct map_context *ac;
int ret;
ac = talloc_get_type(req->context, struct map_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
}
if (ares->type != LDB_REPLY_DONE) {
- ldb_set_errstring(req->handle->ldb, "Invalid reply type!");
+ ldb_set_errstring(ldb, "Invalid reply type!");
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
#include "ldb_map.h"
#include "ldb_map_private.h"
const struct ldb_map_attribute *map;
struct ldb_message_element *old, *el=NULL;
const char *remote_name = NULL;
+ struct ldb_context *ldb;
+
+ ldb = ldb_module_get_ctx(module);
/* We handle wildcards in ldb_msg_el_merge_wildcard */
if (ldb_attr_cmp(attr_name, "*") == 0) {
case MAP_CONVERT:
if (map->u.convert.convert_remote == NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"Skipping attribute '%s': "
"'convert_remote' not set\n",
attr_name);
case MAP_GENERATE:
if (map->u.generate.generate_local == NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "ldb_map: "
"Skipping attribute '%s': "
"'generate_local' not set\n",
attr_name);
{
const struct ldb_map_context *data = map_get_context(module);
const struct ldb_map_attribute *map;
+ struct ldb_context *ldb;
+
+ ldb = ldb_module_get_ctx(module);
if (tree == NULL) {
return 0;
}
if (map->type == MAP_GENERATE) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_WARNING, "ldb_map: "
"Skipping attribute '%s': "
"'convert_operator' not set\n",
tree->u.equality.attr);
{
struct ldb_message_element *el;
const char * const *attrs;
+ struct ldb_context *ldb;
int i;
+ ldb = ldb_module_get_ctx(ac->module);
+
/* Merged result doesn't match original query, skip */
- if (!ldb_match_msg(ac->module->ldb, ares->message,
+ if (!ldb_match_msg(ldb, ares->message,
ac->req->op.search.tree,
ac->req->op.search.base,
ac->req->op.search.scope)) {
- ldb_debug(ac->module->ldb, LDB_DEBUG_TRACE, "ldb_map: "
+ ldb_debug(ldb, LDB_DEBUG_TRACE, "ldb_map: "
"Skipping record '%s': "
"doesn't match original search\n",
ldb_dn_get_linearized(ares->message->dn));
struct ldb_parse_tree *remote_tree;
struct ldb_parse_tree *local_tree;
struct ldb_request *remote_req;
+ struct ldb_context *ldb;
struct map_context *ac;
int ret;
const char *wildcard[] = { "*", NULL };
const char * const *attrs;
- if (!module->private_data) /* if we're not yet initialized, go to the next module */
+ ldb = ldb_module_get_ctx(module);
+
+ /* if we're not yet initialized, go to the next module */
+ if (!ldb_module_get_private(module))
return ldb_next_request(module, req);
/* Do not manipulate our control entries */
ac->local_tree = local_tree;
/* Prepare the remote operation */
- ret = ldb_build_search_req_ex(&remote_req, module->ldb, ac,
+ ret = ldb_build_search_req_ex(&remote_req, ldb, ac,
req->op.search.base,
req->op.search.scope,
remote_tree,
/* Merge the remote and local parts of a search result. */
int map_local_merge_callback(struct ldb_request *req, struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct map_context *ac;
int ret;
ac = talloc_get_type(req->context, struct map_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
return ldb_module_done(ac->req, NULL, NULL,
/* We have already found a local record */
if (ac->r_current->local) {
talloc_free(ares);
- ldb_set_errstring(ac->module->ldb, "ldb_map: Too many results!");
+ ldb_set_errstring(ldb, "ldb_map: Too many results!");
return ldb_module_done(ac->req, NULL, NULL,
LDB_ERR_OPERATIONS_ERROR);
}
/* A handy macro to report Out of Memory conditions */
-#define map_oom(module) ldb_set_errstring(module->ldb, talloc_asprintf(module, "Out of Memory"));
+#define map_oom(module) ldb_set_errstring(ldb_module_get_ctx(module), talloc_asprintf(module, "Out of Memory"));
/* The type of search callback functions */
typedef int (*ldb_map_callback_t)(struct ldb_request *, struct ldb_reply *);
* Author: Derrell Lipman (based on Andrew Tridgell's LDAP backend)
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
#include <sqlite3.h>
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
-
#include "ldb_tdb.h"
#define LTDB_FLAG_CASE_INSENSITIVE (1<<0)
*/
static void ltdb_attributes_unload(struct ldb_module *module)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ struct ldb_context *ldb;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
struct ldb_message *msg;
int i;
+ ldb = ldb_module_get_ctx(module);
+
if (ltdb->cache->attributes == NULL) {
/* no previously loaded attributes */
return;
msg = ltdb->cache->attributes;
for (i=0;i<msg->num_elements;i++) {
- ldb_schema_attribute_remove(module->ldb, msg->elements[i].name);
+ ldb_schema_attribute_remove(ldb, msg->elements[i].name);
}
talloc_free(ltdb->cache->attributes);
*/
static int ltdb_attributes_load(struct ldb_module *module)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ struct ldb_context *ldb;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
struct ldb_message *msg = ltdb->cache->attributes;
struct ldb_dn *dn;
int i, r;
- dn = ldb_dn_new(module, module->ldb, LTDB_ATTRIBUTES);
+ ldb = ldb_module_get_ctx(module);
+
+ dn = ldb_dn_new(module, ldb, LTDB_ATTRIBUTES);
if (dn == NULL) goto failed;
r = ltdb_search_dn1(module, dn, msg);
const struct ldb_schema_syntax *s;
if (ltdb_attributes_flags(&msg->elements[i], &flags) != 0) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "Invalid @ATTRIBUTES element for '%s'\n", msg->elements[i].name);
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid @ATTRIBUTES element for '%s'\n", msg->elements[i].name);
goto failed;
}
switch (flags & ~LTDB_FLAG_HIDDEN) {
syntax = LDB_SYNTAX_INTEGER;
break;
default:
- ldb_debug(module->ldb, LDB_DEBUG_ERROR,
+ ldb_debug(ldb, LDB_DEBUG_ERROR,
"Invalid flag combination 0x%x for '%s' in @ATTRIBUTES\n",
flags, msg->elements[i].name);
goto failed;
}
- s = ldb_standard_syntax_by_name(module->ldb, syntax);
+ s = ldb_standard_syntax_by_name(ldb, syntax);
if (s == NULL) {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR,
+ ldb_debug(ldb, LDB_DEBUG_ERROR,
"Invalid attribute syntax '%s' for '%s' in @ATTRIBUTES\n",
syntax, msg->elements[i].name);
goto failed;
}
flags |= LDB_ATTR_FLAG_ALLOCATED;
- if (ldb_schema_attribute_add_with_syntax(module->ldb, msg->elements[i].name, flags, s) != 0) {
+ if (ldb_schema_attribute_add_with_syntax(ldb, msg->elements[i].name, flags, s) != 0) {
goto failed;
}
}
*/
static int ltdb_baseinfo_init(struct ldb_module *module)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ struct ldb_context *ldb;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
struct ldb_message *msg;
struct ldb_message_element el;
struct ldb_val val;
out. */
const char *initial_sequence_number = "1";
+ ldb = ldb_module_get_ctx(module);
+
ltdb->sequence_number = atof(initial_sequence_number);
msg = talloc(ltdb, struct ldb_message);
msg->num_elements = 1;
msg->elements = ⪙
- msg->dn = ldb_dn_new(msg, module->ldb, LTDB_BASEINFO);
+ msg->dn = ldb_dn_new(msg, ldb, LTDB_BASEINFO);
if (!msg->dn) {
goto failed;
}
*/
static void ltdb_cache_free(struct ldb_module *module)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
ltdb->sequence_number = 0;
talloc_free(ltdb->cache);
*/
int ltdb_cache_load(struct ldb_module *module)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ struct ldb_context *ldb;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
struct ldb_dn *baseinfo_dn = NULL, *options_dn = NULL;
struct ldb_dn *indexlist_dn = NULL;
uint64_t seq;
struct ldb_message *baseinfo = NULL, *options = NULL;
int r;
+ ldb = ldb_module_get_ctx(module);
+
/* a very fast check to avoid extra database reads */
if (ltdb->cache != NULL &&
tdb_get_seqnum(ltdb->tdb) == ltdb->tdb_seqnum) {
baseinfo = talloc(ltdb->cache, struct ldb_message);
if (baseinfo == NULL) goto failed;
- baseinfo_dn = ldb_dn_new(module, module->ldb, LTDB_BASEINFO);
+ baseinfo_dn = ldb_dn_new(module, ldb, LTDB_BASEINFO);
if (baseinfo_dn == NULL) goto failed;
r= ltdb_search_dn1(module, baseinfo_dn, baseinfo);
options = talloc(ltdb->cache, struct ldb_message);
if (options == NULL) goto failed;
- options_dn = ldb_dn_new(options, module->ldb, LTDB_OPTIONS);
+ options_dn = ldb_dn_new(options, ldb, LTDB_OPTIONS);
if (options_dn == NULL) goto failed;
r= ltdb_search_dn1(module, options_dn, options);
goto failed;
}
- indexlist_dn = ldb_dn_new(module, module->ldb, LTDB_INDEXLIST);
+ indexlist_dn = ldb_dn_new(module, ldb, LTDB_INDEXLIST);
if (indexlist_dn == NULL) goto failed;
r = ltdb_search_dn1(module, indexlist_dn, ltdb->cache->indexlist);
*/
int ltdb_increase_sequence_number(struct ldb_module *module)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ struct ldb_context *ldb;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
struct ldb_message *msg;
struct ldb_message_element el[2];
struct ldb_val val;
char *s = NULL;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
msg = talloc(ltdb, struct ldb_message);
if (msg == NULL) {
errno = ENOMEM;
msg->num_elements = ARRAY_SIZE(el);
msg->elements = el;
- msg->dn = ldb_dn_new(msg, module->ldb, LTDB_BASEINFO);
+ msg->dn = ldb_dn_new(msg, ldb, LTDB_BASEINFO);
if (msg->dn == NULL) {
talloc_free(msg);
errno = ENOMEM;
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
-
#include "ldb_tdb.h"
/*
*/
static int ltdb_idxptr_add(struct ldb_module *module, const struct ldb_message *msg)
{
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
ltdb->idxptr->dn_list = talloc_realloc(ltdb->idxptr, ltdb->idxptr->dn_list,
const char *, ltdb->idxptr->num_dns+1);
if (ltdb->idxptr->dn_list == NULL) {
struct ldb_index_pointer *ptr, *tmp;
int i;
struct ldb_val *val2;
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
ptr = NULL;
/* enable the idxptr mode when transactions start */
int ltdb_index_transaction_start(struct ldb_module *module)
{
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
ltdb->idxptr = talloc_zero(module, struct ltdb_idxptr);
return LDB_SUCCESS;
}
*/
static int ltdb_idxptr_fix_dn(struct ldb_module *module, const char *strdn)
{
+ struct ldb_context *ldb;
struct ldb_dn *dn;
struct ldb_message *msg = ldb_msg_new(module);
int ret;
- dn = ldb_dn_new(msg, module->ldb, strdn);
+ ldb = ldb_module_get_ctx(module);
+
+ dn = ldb_dn_new(msg, ldb, strdn);
if (ltdb_search_dn1_index(module, dn, msg) == LDB_SUCCESS) {
ret = ltdb_store(module, msg, TDB_REPLACE);
}
int ltdb_index_transaction_commit(struct ldb_module *module)
{
int i;
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
/* fix all the DNs that we have modified */
if (ltdb->idxptr) {
/* cleanup the idxptr mode when transaction cancels */
int ltdb_index_transaction_cancel(struct ldb_module *module)
{
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
talloc_free(ltdb->idxptr);
ltdb->idxptr = NULL;
return LDB_SUCCESS;
*/
int ltdb_store_idxptr(struct ldb_module *module, const struct ldb_message *msg, int flgs)
{
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
int ret;
if (ltdb->idxptr) {
const struct ldb_message *index_list,
struct dn_list *list)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb;
struct ldb_dn *dn;
int ret;
unsigned int i, j;
struct ldb_message *msg;
+ ldb = ldb_module_get_ctx(module);
+
list->count = 0;
list->dn = NULL;
const struct ldb_message *index_list,
struct dn_list *list)
{
+ struct ldb_context *ldb;
+ ldb = ldb_module_get_ctx(module);
+
if (ldb_attr_dn(tree->u.equality.attr) == 0) {
list->dn = talloc_array(list, char *, 1);
if (list->dn == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
list->dn[0] = talloc_strdup(list->dn, (char *)tree->u.equality.value.data);
if (list->dn[0] == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
list->count = 1;
const struct ldb_message *index_list,
struct dn_list *list)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb;
unsigned int i;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
ret = LDB_ERR_OPERATIONS_ERROR;
list->dn = NULL;
list->count = 0;
const struct ldb_message *index_list,
struct dn_list *list)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb;
unsigned int i;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
ret = LDB_ERR_OPERATIONS_ERROR;
list->dn = NULL;
list->count = 0;
struct ldb_dn *parent_dn,
struct dn_list *list)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb;
struct dn_list *list2;
struct ldb_message *msg;
struct ldb_dn *key;
unsigned int i, j;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
list2 = talloc_zero(module, struct dn_list);
if (list2 == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
static int ltdb_index_filter(const struct dn_list *dn_list,
struct ltdb_context *ac)
{
+ struct ldb_context *ldb;
struct ldb_message *msg;
unsigned int i;
+ ldb = ldb_module_get_ctx(ac->module);
+
for (i = 0; i < dn_list->count; i++) {
struct ldb_dn *dn;
int ret;
return LDB_ERR_OPERATIONS_ERROR;
}
- dn = ldb_dn_new(msg, ac->module->ldb, dn_list->dn[i]);
+ dn = ldb_dn_new(msg, ldb, dn_list->dn[i]);
if (dn == NULL) {
talloc_free(msg);
return LDB_ERR_OPERATIONS_ERROR;
return LDB_ERR_OPERATIONS_ERROR;
}
- if (!ldb_match_msg(ac->module->ldb, msg,
+ if (!ldb_match_msg(ldb, msg,
ac->tree, ac->base, ac->scope)) {
talloc_free(msg);
continue;
*/
int ltdb_search_indexed(struct ltdb_context *ac)
{
- struct ltdb_private *ltdb = talloc_get_type(ac->module->private_data, struct ltdb_private);
+ struct ldb_context *ldb;
+ void *data = ldb_module_get_private(ac->module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
struct dn_list *dn_list;
int ret, idxattr, idxone;
+ ldb = ldb_module_get_ctx(ac->module);
+
idxattr = idxone = 0;
ret = ldb_msg_find_idx(ltdb->cache->indexlist, NULL, NULL, LTDB_IDXATTR);
if (ret == 0 ) {
/* with BASE searches only one DN can match */
dn_list->dn = talloc_array(dn_list, char *, 1);
if (dn_list->dn == NULL) {
- ldb_oom(ac->module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
dn_list->dn[0] = ldb_dn_alloc_linearized(dn_list, ac->base);
if (dn_list->dn[0] == NULL) {
- ldb_oom(ac->module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
dn_list->count = 1;
static int ltdb_index_add1(struct ldb_module *module, const char *dn,
struct ldb_message_element *el, int v_idx)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb;
struct ldb_message *msg;
struct ldb_dn *dn_key;
int ret;
unsigned int i;
+ ldb = ldb_module_get_ctx(module);
+
msg = talloc(module, struct ldb_message);
if (msg == NULL) {
errno = ENOMEM;
static int ltdb_index_add0(struct ldb_module *module, const char *dn,
struct ldb_message_element *elements, int num_el)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
int ret;
unsigned int i, j;
int ltdb_index_del_value(struct ldb_module *module, const char *dn,
struct ldb_message_element *el, int v_idx)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb;
struct ldb_message *msg;
struct ldb_dn *dn_key;
int ret, i;
unsigned int j;
+ ldb = ldb_module_get_ctx(module);
+
if (dn[0] == '@') {
return LDB_SUCCESS;
}
ldb_dn_get_linearized(dn_key));
ldif.changetype = LDB_CHANGETYPE_NONE;
ldif.msg = msg;
- ldb_ldif_write_file(module->ldb, stdout, &ldif);
+ ldb_ldif_write_file(ldb, stdout, &ldif);
sleep(100);
/* it ain't there. hmmm */
talloc_free(dn_key);
*/
int ltdb_index_del(struct ldb_module *module, const struct ldb_message *msg)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
int ret;
const char *dn;
unsigned int i, j;
*/
int ltdb_index_one(struct ldb_module *module, const struct ldb_message *msg, int add)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
struct ldb_message_element el;
struct ldb_val val;
struct ldb_dn *pdn;
*/
static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *state)
{
+ struct ldb_context *ldb;
struct ldb_module *module = (struct ldb_module *)state;
struct ldb_message *msg;
const char *dn = NULL;
int ret;
TDB_DATA key2;
+ ldb = ldb_module_get_ctx(module);
+
if (strncmp((char *)key.dptr, "DN=@", 4) == 0 ||
strncmp((char *)key.dptr, "DN=", 3) != 0) {
return 0;
key2 = ltdb_key(module, msg->dn);
if (key2.dptr == NULL) {
/* probably a corrupt record ... darn */
- ldb_debug(module->ldb, LDB_DEBUG_ERROR, "Invalid DN in re_index: %s\n",
+ ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid DN in re_index: %s\n",
ldb_dn_get_linearized(msg->dn));
talloc_free(msg);
return 0;
if (ret == LDB_SUCCESS) {
ret = ltdb_index_add0(module, dn, msg->elements, msg->num_elements);
} else {
- ldb_debug(module->ldb, LDB_DEBUG_ERROR,
+ ldb_debug(ldb, LDB_DEBUG_ERROR,
"Adding special ONE LEVEL index failed (%s)!\n",
ldb_dn_get_linearized(msg->dn));
}
*/
int ltdb_reindex(struct ldb_module *module)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
int ret;
if (ltdb_cache_reload(module) != 0) {
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
#include "ldb_tdb.h"
/* change this if the data format ever changes */
const struct ldb_message *message,
struct TDB_DATA *data)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb;
unsigned int i, j, real_elements=0;
size_t size;
const char *dn;
uint8_t *p;
size_t len;
+ ldb = ldb_module_get_ctx(module);
+
dn = ldb_dn_get_linearized(message->dn);
if (dn == NULL) {
errno = ENOMEM;
const struct TDB_DATA *data,
struct ldb_message *message)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb;
uint8_t *p;
unsigned int remaining;
unsigned int i, j;
unsigned format;
size_t len;
+ ldb = ldb_module_get_ctx(module);
message->elements = NULL;
p = data->dptr;
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
-
#include "ldb_tdb.h"
/*
static int msg_add_all_elements(struct ldb_module *module, struct ldb_message *ret,
const struct ldb_message *msg)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb;
unsigned int i;
int check_duplicates = (ret->num_elements != 0);
+ ldb = ldb_module_get_ctx(module);
+
if (msg_add_distinguished_name(ret) != 0) {
return -1;
}
*/
static int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
TDB_DATA tdb_key, tdb_data;
if (ldb_dn_is_null(dn)) {
*/
int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_message *msg)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
int ret;
TDB_DATA tdb_key, tdb_data;
*/
static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *state)
{
+ struct ldb_context *ldb;
struct ltdb_context *ac;
struct ldb_message *msg;
int ret;
ac = talloc_get_type(state, struct ltdb_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (key.dsize < 4 ||
strncmp((char *)key.dptr, "DN=", 3) != 0) {
}
if (!msg->dn) {
- msg->dn = ldb_dn_new(msg, ac->module->ldb,
+ msg->dn = ldb_dn_new(msg, ldb,
(char *)key.dptr + 3);
if (msg->dn == NULL) {
talloc_free(msg);
}
/* see if it matches the given expression */
- if (!ldb_match_msg(ac->module->ldb, msg,
+ if (!ldb_match_msg(ldb, msg,
ac->tree, ac->base, ac->scope)) {
talloc_free(msg);
return 0;
*/
static int ltdb_search_full(struct ltdb_context *ctx)
{
- struct ltdb_private *ltdb = talloc_get_type(ctx->module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(ctx->module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
int ret;
if (ltdb->in_transaction != 0) {
*/
int ltdb_search(struct ltdb_context *ctx)
{
+ struct ldb_context *ldb;
struct ldb_module *module = ctx->module;
struct ldb_request *req = ctx->req;
- struct ltdb_private *ltdb = talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
int ret;
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb = ldb_module_get_ctx(module);
+
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
if (ltdb_lock_read(module) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
/* Check what we should do with a NULL dn */
switch (req->op.search.scope) {
case LDB_SCOPE_BASE:
- ldb_asprintf_errstring(module->ldb,
+ ldb_asprintf_errstring(ldb,
"NULL Base DN invalid for a base search");
ret = LDB_ERR_INVALID_DN_SYNTAX;
break;
case LDB_SCOPE_ONELEVEL:
- ldb_asprintf_errstring(module->ldb,
+ ldb_asprintf_errstring(ldb,
"NULL Base DN invalid for a one-level search");
ret = LDB_ERR_INVALID_DN_SYNTAX;
break;
} else if (ldb_dn_is_valid(req->op.search.base) == false) {
/* We don't want invalid base DNs here */
- ldb_asprintf_errstring(module->ldb,
+ ldb_asprintf_errstring(ldb,
"Invalid Base DN: %s",
ldb_dn_get_linearized(req->op.search.base));
ret = LDB_ERR_INVALID_DN_SYNTAX;
ret = ltdb_search_base(module, req->op.search.base);
if (ret == LDB_ERR_NO_SUCH_OBJECT) {
- ldb_asprintf_errstring(module->ldb,
+ ldb_asprintf_errstring(ldb,
"No such Base DN: %s",
ldb_dn_get_linearized(req->op.search.base));
}
/* Not indexed, so we need to do a full scan */
ret = ltdb_search_full(ctx);
if (ret != LDB_SUCCESS) {
- ldb_set_errstring(module->ldb, "Indexed and full searches both failed!\n");
+ ldb_set_errstring(ldb, "Indexed and full searches both failed!\n");
}
}
}
* Author: Simo Sorce
*/
-#include "ldb_includes.h"
-
#include "ldb_tdb.h"
*/
int ltdb_lock_read(struct ldb_module *module)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
if (ltdb->in_transaction == 0) {
return tdb_lockall_read(ltdb->tdb);
}
*/
int ltdb_unlock_read(struct ldb_module *module)
{
- struct ltdb_private *ltdb = (struct ltdb_private *)module->private_data;
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
if (ltdb->in_transaction == 0) {
return tdb_unlockall_read(ltdb->tdb);
}
*/
struct TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
TDB_DATA key;
char *key_str = NULL;
const char *dn_folded = NULL;
static int ltdb_check_special_dn(struct ldb_module *module,
const struct ldb_message *msg)
{
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
int i, j;
if (! ldb_dn_is_special(msg->dn) ||
for (i = 0; i < msg->num_elements; i++) {
for (j = 0; j < msg->elements[i].num_values; j++) {
if (ltdb_check_at_attributes_values(&msg->elements[i].values[j]) != 0) {
- ldb_set_errstring(module->ldb, "Invalid attribute value in an @ATTRIBUTES entry");
+ ldb_set_errstring(ldb, "Invalid attribute value in an @ATTRIBUTES entry");
return LDB_ERR_INVALID_ATTRIBUTE_SYNTAX;
}
}
*/
int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs)
{
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
TDB_DATA tdb_key, tdb_data;
int ret;
static int ltdb_add_internal(struct ldb_module *module,
const struct ldb_message *msg)
{
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
int ret;
ret = ltdb_check_special_dn(module, msg);
ret = ltdb_store(module, msg, TDB_INSERT);
if (ret == LDB_ERR_ENTRY_ALREADY_EXISTS) {
- ldb_asprintf_errstring(module->ldb,
+ ldb_asprintf_errstring(ldb,
"Entry %s already exists",
ldb_dn_get_linearized(msg->dn));
return ret;
struct ldb_request *req = ctx->req;
int tret;
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
tret = ltdb_add_internal(module, req->op.add.message);
if (tret != LDB_SUCCESS) {
*/
int ltdb_delete_noindex(struct ldb_module *module, struct ldb_dn *dn)
{
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
TDB_DATA tdb_key;
int ret;
struct ldb_request *req = ctx->req;
int tret;
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
if (ltdb_cache_load(module) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
const char *name,
const struct ldb_val *val)
{
- struct ldb_context *ldb = module->ldb;
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
unsigned int i;
int found;
struct ldb_message_element *el;
int ltdb_modify_internal(struct ldb_module *module,
const struct ldb_message *msg)
{
- struct ldb_context *ldb = module->ldb;
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ struct ldb_context *ldb = ldb_module_get_ctx(module);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
TDB_DATA tdb_key, tdb_data;
struct ldb_message *msg2;
unsigned i, j;
for (j=0;j<el->num_values;j++) {
if (ldb_msg_find_val(el2, &el->values[j])) {
- ldb_asprintf_errstring(module->ldb, "%s: value #%d already exists", el->name, j);
+ ldb_asprintf_errstring(ldb, "%s: value #%d already exists", el->name, j);
ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
goto failed;
}
if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) {
- ldb_asprintf_errstring(module->ldb, "%s: value #%d provided more than once", el->name, j);
+ ldb_asprintf_errstring(ldb, "%s: value #%d provided more than once", el->name, j);
ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
goto failed;
}
for (j=0;j<el->num_values;j++) {
if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) {
- ldb_asprintf_errstring(module->ldb, "%s: value #%d provided more than once", el->name, j);
+ ldb_asprintf_errstring(ldb, "%s: value #%d provided more than once", el->name, j);
ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
goto failed;
}
if (msg->elements[i].num_values == 0) {
if (msg_delete_attribute(module, ldb, msg2,
msg->elements[i].name) != 0) {
- ldb_asprintf_errstring(module->ldb, "No such attribute: %s for delete on %s", msg->elements[i].name, dn);
+ ldb_asprintf_errstring(ldb, "No such attribute: %s for delete on %s", msg->elements[i].name, dn);
ret = LDB_ERR_NO_SUCH_ATTRIBUTE;
goto failed;
}
msg2,
msg->elements[i].name,
&msg->elements[i].values[j]) != 0) {
- ldb_asprintf_errstring(module->ldb, "No matching attribute value when deleting attribute: %s on %s", msg->elements[i].name, dn);
+ ldb_asprintf_errstring(ldb, "No matching attribute value when deleting attribute: %s on %s", msg->elements[i].name, dn);
ret = LDB_ERR_NO_SUCH_ATTRIBUTE;
goto failed;
}
}
break;
default:
- ldb_asprintf_errstring(module->ldb,
+ ldb_asprintf_errstring(ldb,
"Invalid ldb_modify flags on %s: 0x%x",
msg->elements[i].name,
msg->elements[i].flags & LDB_FLAG_MOD_MASK);
struct ldb_request *req = ctx->req;
int tret;
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
tret = ltdb_check_special_dn(module, req->op.mod.message);
if (tret != LDB_SUCCESS) {
struct ldb_message *msg;
int tret;
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
if (ltdb_cache_load(ctx->module) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
static int ltdb_start_trans(struct ldb_module *module)
{
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
if (tdb_transaction_start(ltdb->tdb) != 0) {
return ltdb_err_map(tdb_error(ltdb->tdb));
static int ltdb_end_trans(struct ldb_module *module)
{
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
ltdb->in_transaction--;
static int ltdb_del_trans(struct ldb_module *module)
{
- struct ltdb_private *ltdb =
- talloc_get_type(module->private_data, struct ltdb_private);
+ void *data = ldb_module_get_private(module);
+ struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
ltdb->in_transaction--;
static int ltdb_sequence_number(struct ltdb_context *ctx,
struct ldb_extended **ext)
{
+ struct ldb_context *ldb;
struct ldb_module *module = ctx->module;
struct ldb_request *req = ctx->req;
TALLOC_CTX *tmp_ctx;
const char *date;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
seq = talloc_get_type(req->op.extended.data,
struct ldb_seqnum_request);
if (seq == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
- req->handle->state = LDB_ASYNC_PENDING;
+ ldb_request_set_state(req, LDB_ASYNC_PENDING);
if (ltdb_lock_read(module) != 0) {
return LDB_ERR_OPERATIONS_ERROR;
goto done;
}
- dn = ldb_dn_new(tmp_ctx, module->ldb, LTDB_BASEINFO);
+ dn = ldb_dn_new(tmp_ctx, ldb, LTDB_BASEINFO);
msg = talloc(tmp_ctx, struct ldb_message);
if (msg == NULL) {
return ret;
}
-static void ltdb_request_done(struct ldb_request *req, int error)
+static void ltdb_request_done(struct ltdb_context *ctx, int error)
{
+ struct ldb_context *ldb;
+ struct ldb_request *req;
struct ldb_reply *ares;
+ ldb = ldb_module_get_ctx(ctx->module);
+ req = ctx->req;
+
/* if we already returned an error just return */
- if (req->handle->status != LDB_SUCCESS) {
+ if (ldb_request_get_status(req) != LDB_SUCCESS) {
return;
}
ares = talloc_zero(req, struct ldb_reply);
if (!ares) {
- ldb_oom(req->handle->ldb);
+ ldb_oom(ldb);
req->callback(req, NULL);
return;
}
struct ltdb_context *ctx;
ctx = talloc_get_type(private_data, struct ltdb_context);
- ltdb_request_done(ctx->req, LDB_ERR_TIME_LIMIT_EXCEEDED);
+ ltdb_request_done(ctx, LDB_ERR_TIME_LIMIT_EXCEEDED);
}
-static void ltdb_request_extended_done(struct ldb_request *req,
+static void ltdb_request_extended_done(struct ltdb_context *ctx,
struct ldb_extended *ext,
int error)
{
+ struct ldb_context *ldb;
+ struct ldb_request *req;
struct ldb_reply *ares;
+ ldb = ldb_module_get_ctx(ctx->module);
+ req = ctx->req;
+
/* if we already returned an error just return */
- if (req->handle->status != LDB_SUCCESS) {
+ if (ldb_request_get_status(req) != LDB_SUCCESS) {
return;
}
ares = talloc_zero(req, struct ldb_reply);
if (!ares) {
- ldb_oom(req->handle->ldb);
+ ldb_oom(ldb);
req->callback(req, NULL);
return;
}
ret = LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
}
- ltdb_request_extended_done(ctx->req, ext, ret);
+ ltdb_request_extended_done(ctx, ext, ret);
}
static void ltdb_callback(struct tevent_context *ev,
if (!ctx->callback_failed) {
/* Once we are done, we do not need timeout events */
talloc_free(ctx->timeout_event);
- ltdb_request_done(ctx->req, ret);
+ ltdb_request_done(ctx, ret);
}
}
static int ltdb_handle_request(struct ldb_module *module,
struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct tevent_context *ev;
struct ltdb_context *ac;
struct tevent_timer *te;
return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
}
+ ldb = ldb_module_get_ctx(module);
+
if (req->starttime == 0 || req->timeout == 0) {
- ldb_set_errstring(module->ldb, "Invalid timeout settings");
+ ldb_set_errstring(ldb, "Invalid timeout settings");
return LDB_ERR_TIME_LIMIT_EXCEEDED;
}
- ev = ldb_get_event_context(module->ldb);
+ ev = ldb_get_event_context(ldb);
ac = talloc_zero(req, struct ltdb_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
+ ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
*/
static int ltdb_connect(struct ldb_context *ldb, const char *url,
unsigned int flags, const char *options[],
- struct ldb_module **module)
+ struct ldb_module **_module)
{
+ struct ldb_module *module;
const char *path;
int tdb_flags, open_flags;
struct ltdb_private *ltdb;
/* note that we use quite a large default hash size */
ltdb->tdb = ltdb_wrap_open(ltdb, path, 10000,
tdb_flags, open_flags,
- ldb->create_perms, ldb);
+ ldb_get_create_perms(ldb), ldb);
if (!ltdb->tdb) {
ldb_debug(ldb, LDB_DEBUG_ERROR,
"Unable to open tdb '%s'\n", path);
ltdb->sequence_number = 0;
- *module = talloc(ldb, struct ldb_module);
- if ((*module) == NULL) {
- ldb_oom(ldb);
+ module = ldb_module_new(ldb, ldb, "ldb_tdb backend", <db_ops);
+ if (!module) {
talloc_free(ltdb);
return -1;
}
- talloc_set_name_const(*module, "ldb_tdb backend");
- (*module)->ldb = ldb;
- (*module)->prev = (*module)->next = NULL;
- (*module)->private_data = ltdb;
- (*module)->ops = <db_ops;
+ ldb_module_set_private(module, ltdb);
- if (ltdb_cache_load(*module) != 0) {
- talloc_free(*module);
+ if (ltdb_cache_load(module) != 0) {
+ talloc_free(module);
talloc_free(ltdb);
return -1;
}
+ *_module = module;
return 0;
}
#include "tdb.h"
#endif
+#include "ldb_module.h"
+
/* this private structure is used by the ltdb backend in the
ldb_context */
struct ltdb_private {
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "ldb_includes.h"
-
#include "ldb_tdb.h"
/*
* Author: Simo Sorce
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
struct asq_context {
static struct asq_context *asq_context_init(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct asq_context *ac;
+ ldb = ldb_module_get_ctx(module);
+
ac = talloc_zero(req, struct asq_context);
if (ac == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return NULL;
}
static int asq_build_first_request(struct asq_context *ac, struct ldb_request **base_req)
{
+ struct ldb_context *ldb;
const char **base_attrs;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
ac->req_attrs = ac->req->op.search.attrs;
ac->req_attribute = talloc_strdup(ac, ac->asq_ctrl->source_attribute);
if (ac->req_attribute == NULL)
base_attrs[1] = NULL;
- ret = ldb_build_search_req(base_req, ac->module->ldb, ac,
+ ret = ldb_build_search_req(base_req, ldb, ac,
ac->req->op.search.base,
LDB_SCOPE_BASE,
NULL,
static int asq_build_multiple_requests(struct asq_context *ac, bool *terminated)
{
+ struct ldb_context *ldb;
struct ldb_control **saved_controls;
struct ldb_control *control;
struct ldb_dn *dn;
return LDB_ERR_NO_SUCH_OBJECT;
}
+ ldb = ldb_module_get_ctx(ac->module);
+
el = ldb_msg_find_element(ac->base_res->message, ac->req_attribute);
/* no values found */
if (el == NULL) {
for (i = 0; i < el->num_values; i++) {
- dn = ldb_dn_new(ac, ac->module->ldb,
+ dn = ldb_dn_new(ac, ldb,
(const char *)el->values[i].data);
if ( ! ldb_dn_validate(dn)) {
ac->asq_ret = ASQ_CTRL_INVALID_ATTRIBUTE_SYNTAX;
}
ret = ldb_build_search_req_ex(&ac->reqs[i],
- ac->module->ldb, ac,
+ ldb, ac,
dn, LDB_SCOPE_BASE,
ac->req->op.search.tree,
ac->req_attrs,
static int asq_search_continue(struct asq_context *ac)
{
+ struct ldb_context *ldb;
bool terminated = false;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
switch (ac->step) {
case ASQ_SEARCH_BASE:
ac->step = ASQ_SEARCH_MULTI;
- return ldb_request(ac->module->ldb, ac->reqs[ac->cur_req]);
+ return ldb_request(ldb, ac->reqs[ac->cur_req]);
case ASQ_SEARCH_MULTI:
return asq_search_terminate(ac);
}
- return ldb_request(ac->module->ldb, ac->reqs[ac->cur_req]);
+ return ldb_request(ldb, ac->reqs[ac->cur_req]);
}
return LDB_ERR_OPERATIONS_ERROR;
static int asq_search(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct ldb_request *base_req;
struct ldb_control *control;
struct asq_context *ac;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
/* check if there's a paged request control */
control = ldb_request_get_control(req, LDB_CONTROL_ASQ_OID);
if (control == NULL) {
ac->step = ASQ_SEARCH_BASE;
- return ldb_request(module->ldb, base_req);
+ return ldb_request(ldb, base_req);
}
static int asq_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_ASQ_OID);
if (ret != LDB_SUCCESS) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING, "asq: Unable to register control with rootdse!\n");
+ ldb_debug(ldb, LDB_DEBUG_WARNING, "asq: Unable to register control with rootdse!\n");
}
return ldb_next_init(module);
modifiersName: not supported by w2k3?
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
/*
construct a canonical name from a message
struct ldb_message *msg,
const char * const *attrs)
{
+ struct ldb_context *ldb;
int i, a=0;
+ ldb = ldb_module_get_ctx(module);
+
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) {
return 0;
failed:
- ldb_debug_set(module->ldb, LDB_DEBUG_WARNING,
+ ldb_debug_set(ldb, LDB_DEBUG_WARNING,
"operational_search_post_process failed for attribute '%s'\n",
attrs[a]);
return -1;
static int operational_search(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct operational_context *ac;
struct ldb_request *down_req;
const char **search_attrs = NULL;
int i, a;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
ac = talloc(req, struct operational_context);
if (ac == NULL) {
return LDB_ERR_OPERATIONS_ERROR;
}
}
- 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,
* Author: Simo Sorce
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
struct message_store {
/* keep the whole ldb_reply as an optimization
static int paged_search(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct ldb_control *control;
struct private_data *private_data;
struct ldb_paged_control *paged_ctrl;
struct paged_context *ac;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
/* check if there's a paged request control */
control = ldb_request_get_control(req, LDB_CONTROL_PAGED_RESULTS_OID);
if (control == NULL) {
return LDB_ERR_PROTOCOL_ERROR;
}
- private_data = talloc_get_type(module->private_data, struct private_data);
+ private_data = talloc_get_type(ldb_module_get_private(module),
+ struct private_data);
ac = talloc_zero(req, struct paged_context);
if (ac == NULL) {
- ldb_set_errstring(module->ldb, "Out of Memory");
+ ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
}
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ldb_build_search_req_ex(&search_req, module->ldb, ac,
+ ret = ldb_build_search_req_ex(&search_req, ldb, ac,
req->op.search.base,
req->op.search.scope,
req->op.search.tree,
static int paged_request_init(struct ldb_module *module)
{
+ struct ldb_context *ldb;
struct private_data *data;
int ret;
+ ldb = ldb_module_get_ctx(module);
+
data = talloc(module, struct private_data);
if (data == NULL) {
return LDB_ERR_OTHER;
data->next_free_id = 1;
data->store = NULL;
- module->private_data = data;
+ ldb_module_set_private(module, data);
ret = ldb_mod_register_control(module, LDB_CONTROL_PAGED_RESULTS_OID);
if (ret != LDB_SUCCESS) {
- ldb_debug(module->ldb, LDB_DEBUG_WARNING,
+ ldb_debug(ldb, LDB_DEBUG_WARNING,
"paged_request:"
"Unable to register control with rootdse!\n");
}
*/
#include "includes.h"
-#include "ldb_includes.h"
+#include "ldb_module.h"
#define PS_DEFAULT_PAGE_SIZE 500
/* 500 objects per query seem to be a decent compromise
static int ps_search(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct private_data *private_data;
struct ps_context *ac;
- private_data = talloc_get_type(module->private_data, struct private_data);
+ private_data = talloc_get_type(ldb_module_get_private(module), struct private_data);
+ ldb = ldb_module_get_ctx(module);
/* check if paging is supported and if there is a any control */
if (!private_data || !private_data->paged_supported || req->controls) {
ac = talloc_zero(req, struct ps_context);
if (ac == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
static int ps_next_request(struct ps_context *ac) {
+ struct ldb_context *ldb;
struct ldb_paged_control *control;
struct ldb_control **controls;
struct ldb_request *new_req;
int ret;
+ ldb = ldb_module_get_ctx(ac->module);
+
controls = talloc_array(ac, struct ldb_control *, 2);
if (!controls) {
return LDB_ERR_OPERATIONS_ERROR;
controls[0]->data = control;
controls[1] = NULL;
- ret = ldb_build_search_req_ex(&new_req, ac->module->ldb, ac,
+ ret = ldb_build_search_req_ex(&new_req, ldb, ac,
ac->req->op.search.base,
ac->req->op.search.scope,
ac->req->op.search.tree,
static int ps_init(struct ldb_module *module)
{
+ struct ldb_context *ldb;
static const char *attrs[] = { "supportedControl", NULL };
struct private_data *data;
struct ldb_dn *base;
int ret;
struct ldb_request *req;
+ ldb = ldb_module_get_ctx(module);
+
data = talloc(module, struct private_data);
if (data == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- module->private_data = data;
data->paged_supported = false;
- base = ldb_dn_new(module, module->ldb, "");
+ ldb_module_set_private(module, data);
+
+ base = ldb_dn_new(module, ldb, "");
if (base == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
- ret = ldb_build_search_req(&req, module->ldb, module,
+ ret = ldb_build_search_req(&req, ldb, module,
base, LDB_SCOPE_BASE,
"(objectClass=*)",
attrs, NULL,
* Simo Sorce Mar 2006
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
struct rename_context {
static int rdn_name_add(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct ldb_request *down_req;
struct rename_context *ac;
struct ldb_message *msg;
struct ldb_val rdn_val;
int i, ret;
- ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_add_record\n");
+ ldb = ldb_module_get_ctx(module);
+ ldb_debug(ldb, LDB_DEBUG_TRACE, "rdn_name_add_record\n");
/* do not manipulate our control entries */
if (ldb_dn_is_special(req->op.add.message->dn)) {
return LDB_ERR_OPERATIONS_ERROR;
}
} else {
- a = ldb_schema_attribute_by_name(module->ldb, rdn_name);
+ a = ldb_schema_attribute_by_name(ldb, rdn_name);
for (i = 0; i < attribute->num_values; i++) {
- ret = a->syntax->comparison_fn(module->ldb, msg,
+ ret = a->syntax->comparison_fn(ldb, msg,
&rdn_val, &attribute->values[i]);
if (ret == 0) {
/* overwrite so it matches in case */
}
}
if (i == attribute->num_values) {
- ldb_debug_set(module->ldb, LDB_DEBUG_FATAL,
+ ldb_debug_set(ldb, LDB_DEBUG_FATAL,
"RDN mismatch on %s: %s (%s)",
ldb_dn_get_linearized(msg->dn), rdn_name, rdn_val.data);
talloc_free(ac);
}
}
- ret = ldb_build_add_req(&down_req, module->ldb, req,
+ ret = ldb_build_add_req(&down_req, ldb, req,
msg,
req->controls,
ac, rdn_name_add_callback,
static int rdn_rename_callback(struct ldb_request *req, struct ldb_reply *ares)
{
+ struct ldb_context *ldb;
struct rename_context *ac;
struct ldb_request *mod_req;
const char *rdn_name;
int ret;
ac = talloc_get_type(req->context, struct rename_context);
+ ldb = ldb_module_get_ctx(ac->module);
if (!ares) {
goto error;
goto error;
}
- ret = ldb_build_mod_req(&mod_req, ac->module->ldb,
+ ret = ldb_build_mod_req(&mod_req, ldb,
ac, msg, NULL,
ac, rdn_modify_callback,
req);
talloc_steal(mod_req, msg);
/* do the mod call */
- return ldb_request(ac->module->ldb, mod_req);
+ return ldb_request(ldb, mod_req);
error:
return ldb_module_done(ac->req, NULL, NULL,
static int rdn_name_rename(struct ldb_module *module, struct ldb_request *req)
{
+ struct ldb_context *ldb;
struct rename_context *ac;
struct ldb_request *down_req;
int ret;
- ldb_debug(module->ldb, LDB_DEBUG_TRACE, "rdn_name_rename\n");
+ ldb = ldb_module_get_ctx(module);
+ ldb_debug(ldb, LDB_DEBUG_TRACE, "rdn_name_rename\n");
/* do not manipulate our control entries */
if (ldb_dn_is_special(req->op.rename.newdn)) {
ac->req = req;
ret = ldb_build_rename_req(&down_req,
- module->ldb,
+ ldb,
ac,
req->op.rename.olddn,
req->op.rename.newdn,
* Author: Simo Sorce
*/
-#include "ldb_includes.h"
+#include "ldb_module.h"
struct private_data {
static int skel_destructor(struct ldb_module *ctx)
{
- struct private_data *data = talloc_get_type(ctx->private_data, struct private_data);
+ struct private_data *data;
+
+ data = talloc_get_type(ldb_module_get_private(ctx), struct private_data);
+
/* put your clean-up functions here */
if (data->some_private_data) talloc_free(data->some_private_data);
+
return 0;
}
static int skel_init(struct ldb_module *module)
{
+ struct ldb_context *ldb;
struct private_data *data;
+ ldb = ldb_module_get_ctx(module);
+
data = talloc(module, struct private_data);
if (data == NULL) {
- ldb_oom(module->ldb);
+ ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
data->some_private_data = NULL;
- module->private_data = data;
+ ldb_module_set_private(module, data);
talloc_set_destructor (module, skel_destructor);
* 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");
}
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "ldb_includes.h"
+#include "ldb_private.h"
#include <Python.h>
#include "pyldb.h"
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "ldb_includes.h"
-#include "ldb.h"
-#include "ldb_errors.h"
+#include "ldb_module.h"
int sample_add(struct ldb_module *mod, struct ldb_request *req)
{
License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "ldb_includes.h"
+#include "ldb.h"
#include "tools/cmdline.h"
#if (_SAMBA_BUILD_ >= 4)
ret = talloc_zero(ldb, struct ldb_cmdline);
if (ret == NULL) {
- ldb_oom(ldb);
+ fprintf(stderr, "Out of memory!\n");
goto failed;
}
options.options = talloc_realloc(ret, options.options,
const char *, num_options+3);
if (options.options == NULL) {
- ldb_oom(ldb);
+ fprintf(stderr, "Out of memory!\n");
goto failed;
}
options.options[num_options] = poptGetOptArg(pc);
options.controls = talloc_array(ret, char *, cc + 1);
if (options.controls == NULL) {
- ldb_oom(ldb);
+ fprintf(stderr, "Out of memory!\n");
goto failed;
}
for (p = cs, cc = 0; p != NULL; cc++) {
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb.h"
#include "tools/cmdline.h"
static int failures;
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb.h"
#include "tools/cmdline.h"
static int ldb_delete_recursive(struct ldb_context *ldb, struct ldb_dn *dn)
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb.h"
#include "tools/cmdline.h"
static struct ldb_cmdline *options;
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb.h"
#include "tools/cmdline.h"
static int failures;
* Author: Stefan Metzmacher
*/
-#include "ldb_includes.h"
+#include "ldb.h"
#include "tools/cmdline.h"
static void usage(void)
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb.h"
#include "tools/cmdline.h"
static void usage(void)
* Author: Andrew Tridgell
*/
-#include "ldb_includes.h"
+#include "ldb.h"
#include "tools/cmdline.h"
static struct timeval tp1,tp2;
$(eval $(call proto_header_template,$(libclisrcdir)/ldap/ldap_proto.h,$(LIBCLI_LDAP_OBJ_FILES:.o=.c)))
[SUBSYSTEM::LDAP_ENCODE]
-# FIXME PRIVATE_DEPENDENCIES = LIBLDB
+PRIVATE_DEPENDENCIES = LIBLDB
LDAP_ENCODE_OBJ_FILES = $(libclisrcdir)/ldap/ldap_ndr.o
#ifndef _SMB_LDAP_H_
#define _SMB_LDAP_H_
+#include "libcli/ldap/ldap_errors.h"
#include "lib/ldb/include/ldb.h"
#include "librpc/gen_ndr/misc.h"
LDAP_AUTH_MECH_SASL = 3
};
-enum ldap_result_code {
- LDAP_SUCCESS = 0,
- LDAP_OPERATIONS_ERROR = 1,
- LDAP_PROTOCOL_ERROR = 2,
- LDAP_TIME_LIMIT_EXCEEDED = 3,
- LDAP_SIZE_LIMIT_EXCEEDED = 4,
- LDAP_COMPARE_FALSE = 5,
- LDAP_COMPARE_TRUE = 6,
- LDAP_AUTH_METHOD_NOT_SUPPORTED = 7,
- LDAP_STRONG_AUTH_REQUIRED = 8,
- LDAP_REFERRAL = 10,
- LDAP_ADMIN_LIMIT_EXCEEDED = 11,
- LDAP_UNAVAILABLE_CRITICAL_EXTENSION = 12,
- LDAP_CONFIDENTIALITY_REQUIRED = 13,
- LDAP_SASL_BIND_IN_PROGRESS = 14,
- LDAP_NO_SUCH_ATTRIBUTE = 16,
- LDAP_UNDEFINED_ATTRIBUTE_TYPE = 17,
- LDAP_INAPPROPRIATE_MATCHING = 18,
- LDAP_CONSTRAINT_VIOLATION = 19,
- LDAP_ATTRIBUTE_OR_VALUE_EXISTS = 20,
- LDAP_INVALID_ATTRIBUTE_SYNTAX = 21,
- LDAP_NO_SUCH_OBJECT = 32,
- LDAP_ALIAS_PROBLEM = 33,
- LDAP_INVALID_DN_SYNTAX = 34,
- LDAP_ALIAS_DEREFERENCING_PROBLEM = 36,
- LDAP_INAPPROPRIATE_AUTHENTICATION = 48,
- LDAP_INVALID_CREDENTIALS = 49,
- LDAP_INSUFFICIENT_ACCESS_RIGHTS = 50,
- LDAP_BUSY = 51,
- LDAP_UNAVAILABLE = 52,
- LDAP_UNWILLING_TO_PERFORM = 53,
- LDAP_LOOP_DETECT = 54,
- LDAP_NAMING_VIOLATION = 64,
- LDAP_OBJECT_CLASS_VIOLATION = 65,
- LDAP_NOT_ALLOWED_ON_NON_LEAF = 66,
- LDAP_NOT_ALLOWED_ON_RDN = 67,
- LDAP_ENTRY_ALREADY_EXISTS = 68,
- LDAP_OBJECT_CLASS_MODS_PROHIBITED = 69,
- LDAP_AFFECTS_MULTIPLE_DSAS = 71,
- LDAP_OTHER = 80
-};
-
struct ldap_Result {
int resultcode;
const char *dn;
--- /dev/null
+/*
+ Unix SMB/CIFS Implementation.
+ LDAP protocol helper functions for SAMBA
+ Copyright (C) Volker Lendecke 2004
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#ifndef _SMB_LDAP_ERRORS_H_
+#define _SMB_LDAP_ERRORS_H_
+
+enum ldap_result_code {
+ LDAP_SUCCESS = 0,
+ LDAP_OPERATIONS_ERROR = 1,
+ LDAP_PROTOCOL_ERROR = 2,
+ LDAP_TIME_LIMIT_EXCEEDED = 3,
+ LDAP_SIZE_LIMIT_EXCEEDED = 4,
+ LDAP_COMPARE_FALSE = 5,
+ LDAP_COMPARE_TRUE = 6,
+ LDAP_AUTH_METHOD_NOT_SUPPORTED = 7,
+ LDAP_STRONG_AUTH_REQUIRED = 8,
+ LDAP_REFERRAL = 10,
+ LDAP_ADMIN_LIMIT_EXCEEDED = 11,
+ LDAP_UNAVAILABLE_CRITICAL_EXTENSION = 12,
+ LDAP_CONFIDENTIALITY_REQUIRED = 13,
+ LDAP_SASL_BIND_IN_PROGRESS = 14,
+ LDAP_NO_SUCH_ATTRIBUTE = 16,
+ LDAP_UNDEFINED_ATTRIBUTE_TYPE = 17,
+ LDAP_INAPPROPRIATE_MATCHING = 18,
+ LDAP_CONSTRAINT_VIOLATION = 19,
+ LDAP_ATTRIBUTE_OR_VALUE_EXISTS = 20,
+ LDAP_INVALID_ATTRIBUTE_SYNTAX = 21,
+ LDAP_NO_SUCH_OBJECT = 32,
+ LDAP_ALIAS_PROBLEM = 33,
+ LDAP_INVALID_DN_SYNTAX = 34,
+ LDAP_ALIAS_DEREFERENCING_PROBLEM = 36,
+ LDAP_INAPPROPRIATE_AUTHENTICATION = 48,
+ LDAP_INVALID_CREDENTIALS = 49,
+ LDAP_INSUFFICIENT_ACCESS_RIGHTS = 50,
+ LDAP_BUSY = 51,
+ LDAP_UNAVAILABLE = 52,
+ LDAP_UNWILLING_TO_PERFORM = 53,
+ LDAP_LOOP_DETECT = 54,
+ LDAP_NAMING_VIOLATION = 64,
+ LDAP_OBJECT_CLASS_VIOLATION = 65,
+ LDAP_NOT_ALLOWED_ON_NON_LEAF = 66,
+ LDAP_NOT_ALLOWED_ON_RDN = 67,
+ LDAP_ENTRY_ALREADY_EXISTS = 68,
+ LDAP_OBJECT_CLASS_MODS_PROHIBITED = 69,
+ LDAP_AFFECTS_MULTIPLE_DSAS = 71,
+ LDAP_OTHER = 80
+};
+
+#endif /* _SMB_LDAP_ERRORS_H_ */
*/
#include "includes.h"
-#include "dsdb/samdb/samdb.h"
#include "libcli/security/security.h"
#include "auth/session.h"
/* NT error codes. please read nterr.h */
#include "includes.h"
-#include "libcli/ldap/ldap.h"
+#include "libcli/ldap/ldap_errors.h"
#undef strcasecmp
typedef struct
SUBSYSTEM = LIBLDB
INIT_FUNCTION = LDB_MODULE(wins_ldb)
PRIVATE_DEPENDENCIES = \
- LIBNETIF LIBSAMBA-HOSTCONFIG LIBSAMBA-UTIL
+ LIBLDB LIBNETIF LIBSAMBA-HOSTCONFIG LIBSAMBA-UTIL
# End MODULE ldb_wins_ldb
#######################
*/
#include "includes.h"
+#include "lib/events/events.h"
#include "nbt_server/nbt_server.h"
#include "nbt_server/wins/winsdb.h"
#include "lib/ldb/include/ldb.h"
#include "includes.h"
#include "param/share.h"
#include "libcli/rap/rap.h"
+#include "libcli/raw/interfaces.h"
#include "librpc/gen_ndr/srvsvc.h"
#include "rpc_server/common/common.h"
#include "param/param.h"
#include "librpc/gen_ndr/security.h"
#include "../tdb/include/tdb.h"
#include "tdb_wrap.h"
-#include "../lib/util/util_ldb.h"
#include "libcli/security/security.h"
#include "lib/events/events.h"
#include "param/param.h"
#include "ntvfs/ntvfs.h"
#include "ntvfs/common/ntvfs_common.h"
#include "libcli/wbclient/wbclient.h"
-#include "dsdb/samdb/samdb.h"
+#include "lib/events/events.h"
struct pvfs_wait;
struct pvfs_oplock;
################################################
# Start SUBSYSTEM DCERPC_COMMON
[SUBSYSTEM::DCERPC_COMMON]
+PRIVATE_DEPENDENCIES = LIBLDB
#
# End SUBSYSTEM DCERPC_COMMON
################################################
#include "system/network.h"
#include "lib/socket/netif.h"
#include "param/share.h"
-#include "dsdb/samdb/samdb.h"
#include "param/param.h"
#include "dynconfig/dynconfig.h"
#include "smbd/process_model.h"
*/
#include "includes.h"
-#include "ldb_includes.h"
+#include "ldb.h"
#include "system/locale.h"
#include "lib/ldb/tools/cmdline.h"
#include "param/param.h"
*/
#include "includes.h"
+#include "lib/events/events.h"
#include "utils/net/net.h"
#include "libnet/libnet.h"
#include "libcli/security/security.h"
#include "param/secrets.h"
#include "param/param.h"
-#include "lib/events/events.h"
#include "lib/util/util_ldb.h"
int net_machinepw_usage(struct net_context *ctx, int argc, const char **argv)
*/
#include "includes.h"
-#include "ldb_includes.h"
+#include "ldb.h"
#include "tools/cmdline.h"
#include "dsdb/samdb/samdb.h"