summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common/ldb_controls.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/ldb/common/ldb_controls.c')
-rw-r--r--source4/lib/ldb/common/ldb_controls.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/source4/lib/ldb/common/ldb_controls.c b/source4/lib/ldb/common/ldb_controls.c
index b38373ec12..a8dd6b5859 100644
--- a/source4/lib/ldb/common/ldb_controls.c
+++ b/source4/lib/ldb/common/ldb_controls.c
@@ -123,7 +123,7 @@ int check_critical_controls(struct ldb_control **controls)
int ldb_request_add_control(struct ldb_request *req, const char *oid, bool critical, void *data)
{
- unsigned n;
+ unsigned i, n;
struct ldb_control **ctrls;
struct ldb_control *ctrl;
@@ -135,10 +135,15 @@ int ldb_request_add_control(struct ldb_request *req, const char *oid, bool criti
n++;
}
- ctrls = talloc_realloc(req, req->controls,
+ ctrls = talloc_array(req,
struct ldb_control *,
n + 2);
if (!ctrls) return LDB_ERR_OPERATIONS_ERROR;
+
+ for (i=0; i<n; i++) {
+ ctrls[i] = req->controls[i];
+ }
+
req->controls = ctrls;
ctrls[n] = NULL;
ctrls[n+1] = NULL;
@@ -407,6 +412,33 @@ struct ldb_control **ldb_parse_control_strings(struct ldb_context *ldb, void *me
continue;
}
+ if (strncmp(control_strings[i], "relax:", 6) == 0) {
+ const char *p;
+ int crit, ret;
+
+ p = &(control_strings[i][6]);
+ ret = sscanf(p, "%d", &crit);
+ if ((ret != 1) || (crit < 0) || (crit > 1)) {
+ error_string = talloc_asprintf(mem_ctx, "invalid relax control syntax\n");
+ error_string = talloc_asprintf_append(error_string, " syntax: crit(b)\n");
+ error_string = talloc_asprintf_append(error_string, " note: b = boolean");
+ ldb_set_errstring(ldb, error_string);
+ talloc_free(error_string);
+ return NULL;
+ }
+
+ ctrl[i] = talloc(ctrl, struct ldb_control);
+ if (!ctrl[i]) {
+ ldb_oom(ldb);
+ return NULL;
+ }
+ ctrl[i]->oid = LDB_CONTROL_RELAX_OID;
+ ctrl[i]->critical = crit;
+ ctrl[i]->data = NULL;
+
+ continue;
+ }
+
if (strncmp(control_strings[i], "domain_scope:", 13) == 0) {
const char *p;
int crit, ret;