summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common
diff options
context:
space:
mode:
authorNadezhda Ivanova <nivanova@samba.org>2010-09-27 10:01:09 -0700
committerAndrew Tridgell <tridge@samba.org>2010-09-27 19:00:38 +0000
commitaeedd29d390a1bb8ad1b446bf9b39cffd42e5612 (patch)
treef0de78df1754f4f1a0ca09b88f8d9cc22686fb44 /source4/lib/ldb/common
parent2cf0525b2382d22b3497f49eb58b9fd8f0c837e1 (diff)
downloadsamba-aeedd29d390a1bb8ad1b446bf9b39cffd42e5612.tar.gz
samba-aeedd29d390a1bb8ad1b446bf9b39cffd42e5612.tar.bz2
samba-aeedd29d390a1bb8ad1b446bf9b39cffd42e5612.zip
s4-ldb: Added ldb_request_replace_control
It is the same as ldb_request_add_control, except it will replace an existing control. Autobuild-User: Andrew Tridgell <tridge@samba.org> Autobuild-Date: Mon Sep 27 19:00:38 UTC 2010 on sn-devel-104
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r--source4/lib/ldb/common/ldb_controls.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/source4/lib/ldb/common/ldb_controls.c b/source4/lib/ldb/common/ldb_controls.c
index 769761dfd4..a63357de7f 100644
--- a/source4/lib/ldb/common/ldb_controls.c
+++ b/source4/lib/ldb/common/ldb_controls.c
@@ -234,6 +234,28 @@ int ldb_reply_add_control(struct ldb_reply *ares, const char *oid, bool critical
return LDB_SUCCESS;
}
+/* Add a control to the request, replacing the old one if it is already in the request */
+int ldb_request_replace_control(struct ldb_request *req, const char *oid, bool critical, void *data)
+{
+ unsigned int n;
+ int ret;
+
+ ret = ldb_request_add_control(req, oid, critical, data);
+ if (ret != LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS) {
+ return ret;
+ }
+
+ for (n=0; req->controls[n];n++) {
+ if (strcmp(oid, req->controls[n]->oid) == 0) {
+ req->controls[n]->critical = critical;
+ req->controls[n]->data = data;
+ return LDB_SUCCESS;
+ }
+ }
+
+ return LDB_ERR_OPERATIONS_ERROR;
+}
+
/* Parse controls from the format used on the command line and in ejs */
struct ldb_control **ldb_parse_control_strings(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, const char **control_strings)