From 8139c1e6f2cf154dad0c0c3fbf8c4fac960bdfe0 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 17 Jan 2006 17:23:11 +0000 Subject: r12983: - fix using a DIRSYNC cookie from the command line - also w2k doesn't work correct with max_attrs = 0, so we should use a high number, with this I'm getting the same results from w2k and w2k3 metze (This used to be commit ce9f086c3c1a65bf1b4c843ec44e8817d9361182) --- source4/lib/ldb/tools/ldbsearch.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'source4/lib/ldb/tools/ldbsearch.c') diff --git a/source4/lib/ldb/tools/ldbsearch.c b/source4/lib/ldb/tools/ldbsearch.c index 6c1071318e..df895350ee 100644 --- a/source4/lib/ldb/tools/ldbsearch.c +++ b/source4/lib/ldb/tools/ldbsearch.c @@ -82,10 +82,17 @@ static struct ldb_control **parse_controls(void *mem_ctx, char **control_strings ret = sscanf(p, "%d:%d:%d:%1023[^$]", &crit, &flags, &max_attrs, cookie); if ((ret < 3) || (crit < 0) || (crit > 1) || (flags < 0) || (max_attrs < 0)) { - fprintf(stderr, "invalid paged_results control syntax\n"); + fprintf(stderr, "invalid dirsync control syntax\n"); return NULL; } + /* w2k3 seems to ignore the parameter, + * but w2k sends a wrong cookie when this value is to small + * this would cause looping forever, while getting + * the same data and same cookie forever + */ + if (max_attrs == 0) max_attrs = 0x0FFFFFFF; + ctrl[i] = talloc(ctrl, struct ldb_control); ctrl[i]->oid = LDB_CONTROL_DIRSYNC_OID; ctrl[i]->critical = crit; @@ -93,9 +100,8 @@ static struct ldb_control **parse_controls(void *mem_ctx, char **control_strings control->flags = flags; control->max_attributes = max_attrs; if (*cookie) { - ldb_base64_decode(cookie); - control->cookie = talloc_strdup(control, cookie); - control->cookie_len = strlen(cookie); + control->cookie_len = ldb_base64_decode(cookie); + control->cookie = talloc_memdup(control, cookie, control->cookie_len); } else { control->cookie = NULL; control->cookie_len = 0; @@ -332,7 +338,7 @@ static int handle_controls_reply(struct ldb_control **reply, struct ldb_control req_control->cookie_len = rep_control->cookie_len; cookie = ldb_base64_encode(req_control, rep_control->cookie, rep_control->cookie_len); - fprintf(stderr, "Debug: The cookie returned was: %s\n", cookie); + printf("# DIRSYNC cookie returned was:\n# %s\n", cookie); ret = 1; -- cgit