summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/ldb/tools/ldbsearch.c16
1 files changed, 11 insertions, 5 deletions
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;