summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-01-17 16:10:33 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:43:40 -0500
commitfb9dabe39e18ff9cfd3abb4160ba19971ca33795 (patch)
tree687ea38d2dc6c0cda427473cec96302d79e5097b /source4/lib/ldb
parent64e88a8ccf2faa34ee9d182f4e89fa6e44c609a6 (diff)
downloadsamba-fb9dabe39e18ff9cfd3abb4160ba19971ca33795.tar.gz
samba-fb9dabe39e18ff9cfd3abb4160ba19971ca33795.tar.bz2
samba-fb9dabe39e18ff9cfd3abb4160ba19971ca33795.zip
r20852: add a function to add a ldb control to a ldb_request
metze (This used to be commit f0bf86ed66f7f9995df35db55f2f3875e7dbacbe)
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/common/ldb_controls.c28
-rw-r--r--source4/lib/ldb/include/ldb.h12
2 files changed, 40 insertions, 0 deletions
diff --git a/source4/lib/ldb/common/ldb_controls.c b/source4/lib/ldb/common/ldb_controls.c
index d2729c82ab..182e1b41d4 100644
--- a/source4/lib/ldb/common/ldb_controls.c
+++ b/source4/lib/ldb/common/ldb_controls.c
@@ -104,3 +104,31 @@ int check_critical_controls(struct ldb_control **controls)
return 0;
}
+
+int ldb_request_add_control(struct ldb_request *req, const char *oid, bool critical, void *data)
+{
+ unsigned n;
+ struct ldb_control **ctrls;
+ struct ldb_control *ctrl;
+
+ for (n=0; req->controls && req->controls[n];) { n++; }
+
+ ctrls = talloc_realloc(req, req->controls,
+ struct ldb_control *,
+ n + 2);
+ if (!ctrls) return LDB_ERR_OPERATIONS_ERROR;
+ req->controls = ctrls;
+ ctrls[n] = NULL;
+ ctrls[n+1] = NULL;
+
+ ctrl = talloc(ctrls, struct ldb_control);
+ if (!ctrl) return LDB_ERR_OPERATIONS_ERROR;
+
+ ctrl->oid = talloc_strdup(ctrl, oid);
+ if (!ctrl->oid) return LDB_ERR_OPERATIONS_ERROR;
+ ctrl->critical = critical;
+ ctrl->data = data;
+
+ ctrls[n] = ctrl;
+ return LDB_SUCCESS;
+}
diff --git a/source4/lib/ldb/include/ldb.h b/source4/lib/ldb/include/ldb.h
index 62afbfb609..9cc5904348 100644
--- a/source4/lib/ldb/include/ldb.h
+++ b/source4/lib/ldb/include/ldb.h
@@ -990,6 +990,18 @@ int ldb_build_rename_req(struct ldb_request **ret_req,
ldb_request_callback_t callback);
/**
+ Add a ldb_control to a ldb_request
+
+ \param req the request struct where to add the control
+ \param oid the object identifier of the control as string
+ \param ciritical whether the control should be critical or not
+ \param data a talloc pointer to the control specific data
+
+ \return result code (LDB_SUCCESS on success, or a failure code)
+*/
+int ldb_request_add_control(struct ldb_request *req, const char *oid, bool critical, void *data);
+
+/**
Search the database
This function searches the database, and returns