From 796904e983151cfa46a89a0be62f8940b9655f4a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 21 May 2010 13:29:14 +0200 Subject: s4:ldb_controls: make it possible to pass arbitrary control via the command line --controls=local_oid:1.3.6.1.4.1.7165.4.3.7:1 To specify the DSDB_CONTROL_PASSWORD_HASH_VALUES_OID control as critical. metze --- source4/lib/ldb/common/ldb_controls.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/source4/lib/ldb/common/ldb_controls.c b/source4/lib/ldb/common/ldb_controls.c index ef0e06f6ce..010ed2de03 100644 --- a/source4/lib/ldb/common/ldb_controls.c +++ b/source4/lib/ldb/common/ldb_controls.c @@ -802,6 +802,40 @@ struct ldb_control **ldb_parse_control_strings(struct ldb_context *ldb, void *me continue; } + if (strncmp(control_strings[i], "local_oid:", 10) == 0) { + const char *p; + int crit = 0, ret = 0; + char oid[256]; + + oid[0] = '\0'; + p = &(control_strings[i][10]); + ret = sscanf(p, "%64[^:]:%d", oid, &crit); + + if ((ret != 2) || strlen(oid) == 0 || (crit < 0) || (crit > 1)) { + error_string = talloc_asprintf(mem_ctx, "invalid local_oid control syntax\n"); + error_string = talloc_asprintf_append(error_string, " syntax: oid(s):crit(b)\n"); + error_string = talloc_asprintf_append(error_string, " note: b = boolean, s = string"); + 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 = talloc_strdup(ctrl[i], oid); + if (!ctrl[i]->oid) { + ldb_oom(ldb); + return NULL; + } + ctrl[i]->critical = crit; + ctrl[i]->data = NULL; + + continue; + } + /* no controls matched, throw an error */ ldb_asprintf_errstring(ldb, "Invalid control name: '%s'", control_strings[i]); return NULL; -- cgit