summaryrefslogtreecommitdiff
path: root/lib/ldb/common
diff options
context:
space:
mode:
authorMatthieu Patou <mat@matws.net>2012-05-15 10:14:55 -0700
committerMatthieu Patou <mat@matws.net>2012-06-22 23:22:02 -0700
commit9ebb081ccec0587736920e85a9de624e079836e5 (patch)
tree31e4aba0fc0ccd6992f0cb47b57cb0b4057df89f /lib/ldb/common
parentd7aa7e8ef0db7da07785994e3be7c3cf00289f4d (diff)
downloadsamba-9ebb081ccec0587736920e85a9de624e079836e5.tar.gz
samba-9ebb081ccec0587736920e85a9de624e079836e5.tar.bz2
samba-9ebb081ccec0587736920e85a9de624e079836e5.zip
ldb: add the VERIFY_NAME control
Diffstat (limited to 'lib/ldb/common')
-rw-r--r--lib/ldb/common/ldb_controls.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/ldb/common/ldb_controls.c b/lib/ldb/common/ldb_controls.c
index 7ce4fc34af..097ae20ece 100644
--- a/lib/ldb/common/ldb_controls.c
+++ b/lib/ldb/common/ldb_controls.c
@@ -368,6 +368,25 @@ char *ldb_control_to_string(TALLOC_CTX *mem_ctx, const struct ldb_control *contr
return res;
}
+ if (strcmp(control->oid, LDB_CONTROL_VERIFY_NAME_OID) == 0) {
+ struct ldb_verify_name_control *rep_control = talloc_get_type(control->data, struct ldb_verify_name_control);
+
+ if (rep_control->gc != NULL) {
+ res = talloc_asprintf(mem_ctx, "%s:%d:%d:%s",
+ LDB_CONTROL_VERIFY_NAME_NAME,
+ control->critical,
+ rep_control->flags,
+ rep_control->gc);
+
+ } else {
+ res = talloc_asprintf(mem_ctx, "%s:%d:%d",
+ LDB_CONTROL_VERIFY_NAME_NAME,
+ control->critical,
+ rep_control->flags);
+ }
+ return res;
+ }
+
/*
* From here we don't know the control
*/
@@ -1018,6 +1037,40 @@ struct ldb_control *ldb_parse_control_from_string(struct ldb_context *ldb, TALLO
return ctrl;
}
+ if (LDB_CONTROL_CMP(control_strings, LDB_CONTROL_VERIFY_NAME_NAME) == 0) {
+ const char *p;
+ char gc[1024];
+ int crit, flags, ret;
+ struct ldb_verify_name_control *control;
+
+ gc[0] = '\0';
+
+ p = &(control_strings[sizeof(LDB_CONTROL_VERIFY_NAME_NAME)]);
+ ret = sscanf(p, "%d:%d:%1023[^$]", &crit, &flags, gc);
+ if ((ret != 3) || (crit < 0) || (crit > 1)) {
+ ret = sscanf(p, "%d:%d", &crit, &flags);
+ if ((ret != 2) || (crit < 0) || (crit > 1)) {
+ error_string = talloc_asprintf(mem_ctx, "invalid verify_name control syntax\n");
+ error_string = talloc_asprintf_append(error_string, " syntax: crit(b):flags(i)[:gc(s)]\n");
+ error_string = talloc_asprintf_append(error_string, " note: b = boolean");
+ error_string = talloc_asprintf_append(error_string, " note: i = integer");
+ error_string = talloc_asprintf_append(error_string, " note: s = string");
+ ldb_set_errstring(ldb, error_string);
+ talloc_free(error_string);
+ talloc_free(ctrl);
+ return NULL;
+ }
+ }
+
+ ctrl->oid = LDB_CONTROL_VERIFY_NAME_OID;
+ ctrl->critical = crit;
+ control = talloc(ctrl, struct ldb_verify_name_control);
+ control->gc = talloc_strdup(control, gc);
+ control->gc_len = strlen(gc);
+ control->flags = flags;
+ ctrl->data = control;
+ return ctrl;
+ }
/*
* When no matching control has been found.
*/