1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

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
This commit is contained in:
Stefan Metzmacher 2010-05-21 13:29:14 +02:00
parent d7542b58fc
commit 796904e983

View File

@ -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;