return ldb_request_done(req, LDB_SUCCESS);
}
+static struct ldb_request *ldb_build_req_common(TALLOC_CTX *mem_ctx,
+ struct ldb_context *ldb,
+ struct ldb_control **controls,
+ void *context,
+ ldb_request_callback_t callback,
+ struct ldb_request *parent)
+{
+ struct ldb_request *req = NULL;
+
+ req = talloc_zero(mem_ctx, struct ldb_request);
+ if (req == NULL) {
+ return NULL;
+ }
+ req->controls = controls;
+ req->context = context;
+ req->callback = callback;
+
+ ldb_set_timeout_from_prev_req(ldb, parent, req);
+
+ req->handle = ldb_handle_new(req, ldb);
+ if (req->handle == NULL) {
+ TALLOC_FREE(req);
+ return NULL;
+ }
+
+ if (parent != NULL) {
+ req->handle->nesting++;
+ req->handle->parent = parent;
+ req->handle->flags = parent->handle->flags;
+ req->handle->custom_flags = parent->handle->custom_flags;
+ }
+
+ return req;
+}
+
int ldb_build_search_req_ex(struct ldb_request **ret_req,
struct ldb_context *ldb,
TALLOC_CTX *mem_ctx,
*ret_req = NULL;
- req = talloc(mem_ctx, struct ldb_request);
+ req = ldb_build_req_common(mem_ctx, ldb, controls,
+ context, callback, parent);
if (req == NULL) {
ldb_oom(ldb);
return LDB_ERR_OPERATIONS_ERROR;
}
req->op.search.attrs = attrs;
- req->controls = controls;
- req->context = context;
- req->callback = callback;
-
- ldb_set_timeout_from_prev_req(ldb, parent, req);
-
- req->handle = ldb_handle_new(req, ldb);
- if (req->handle == NULL) {
- ldb_oom(ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- if (parent) {
- req->handle->nesting++;
- req->handle->parent = parent;
- req->handle->flags = parent->handle->flags;
- req->handle->custom_flags = parent->handle->custom_flags;
- }
-
*ret_req = req;
return LDB_SUCCESS;
}
*ret_req = NULL;
- req = talloc(mem_ctx, struct ldb_request);
+ req = ldb_build_req_common(mem_ctx, ldb, controls,
+ context, callback, parent);
if (req == NULL) {
ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
req->operation = LDB_ADD;
req->op.add.message = message;
- req->controls = controls;
- req->context = context;
- req->callback = callback;
-
- ldb_set_timeout_from_prev_req(ldb, parent, req);
-
- req->handle = ldb_handle_new(req, ldb);
- if (req->handle == NULL) {
- ldb_oom(ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- if (parent) {
- req->handle->nesting++;
- req->handle->parent = parent;
- req->handle->flags = parent->handle->flags;
- req->handle->custom_flags = parent->handle->custom_flags;
- }
-
*ret_req = req;
-
return LDB_SUCCESS;
}
*ret_req = NULL;
- req = talloc(mem_ctx, struct ldb_request);
+ req = ldb_build_req_common(mem_ctx, ldb, controls,
+ context, callback, parent);
if (req == NULL) {
ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
req->operation = LDB_MODIFY;
req->op.mod.message = message;
- req->controls = controls;
- req->context = context;
- req->callback = callback;
-
- ldb_set_timeout_from_prev_req(ldb, parent, req);
-
- req->handle = ldb_handle_new(req, ldb);
- if (req->handle == NULL) {
- ldb_oom(ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- if (parent) {
- req->handle->nesting++;
- req->handle->parent = parent;
- req->handle->flags = parent->handle->flags;
- req->handle->custom_flags = parent->handle->custom_flags;
- }
*ret_req = req;
-
return LDB_SUCCESS;
}
*ret_req = NULL;
- req = talloc(mem_ctx, struct ldb_request);
+ req = ldb_build_req_common(mem_ctx, ldb, controls,
+ context, callback, parent);
if (req == NULL) {
ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
req->operation = LDB_DELETE;
req->op.del.dn = dn;
- req->controls = controls;
- req->context = context;
- req->callback = callback;
-
- ldb_set_timeout_from_prev_req(ldb, parent, req);
-
- req->handle = ldb_handle_new(req, ldb);
- if (req->handle == NULL) {
- ldb_oom(ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- if (parent) {
- req->handle->nesting++;
- req->handle->parent = parent;
- req->handle->flags = parent->handle->flags;
- req->handle->custom_flags = parent->handle->custom_flags;
- }
-
*ret_req = req;
-
return LDB_SUCCESS;
}
*ret_req = NULL;
- req = talloc(mem_ctx, struct ldb_request);
+ req = ldb_build_req_common(mem_ctx, ldb, controls,
+ context, callback, parent);
if (req == NULL) {
ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
req->operation = LDB_RENAME;
req->op.rename.olddn = olddn;
req->op.rename.newdn = newdn;
- req->controls = controls;
- req->context = context;
- req->callback = callback;
-
- ldb_set_timeout_from_prev_req(ldb, parent, req);
-
- req->handle = ldb_handle_new(req, ldb);
- if (req->handle == NULL) {
- ldb_oom(ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- if (parent) {
- req->handle->nesting++;
- req->handle->parent = parent;
- req->handle->flags = parent->handle->flags;
- req->handle->custom_flags = parent->handle->custom_flags;
- }
-
*ret_req = req;
-
return LDB_SUCCESS;
}
*ret_req = NULL;
- req = talloc(mem_ctx, struct ldb_request);
+ req = ldb_build_req_common(mem_ctx, ldb, controls,
+ context, callback, parent);
if (req == NULL) {
ldb_set_errstring(ldb, "Out of Memory");
return LDB_ERR_OPERATIONS_ERROR;
req->operation = LDB_EXTENDED;
req->op.extended.oid = oid;
req->op.extended.data = data;
- req->controls = controls;
- req->context = context;
- req->callback = callback;
-
- ldb_set_timeout_from_prev_req(ldb, parent, req);
-
- req->handle = ldb_handle_new(req, ldb);
- if (req->handle == NULL) {
- ldb_oom(ldb);
- return LDB_ERR_OPERATIONS_ERROR;
- }
-
- if (parent) {
- req->handle->nesting++;
- req->handle->parent = parent;
- req->handle->flags = parent->handle->flags;
- req->handle->custom_flags = parent->handle->custom_flags;
- }
-
*ret_req = req;
-
return LDB_SUCCESS;
}