summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-12-20 10:27:03 +1100
committerAndrew Tridgell <tridge@samba.org>2010-01-02 08:16:51 +1100
commit340d7e807b2be7fb5c50a0cddf9378aa9bd929bf (patch)
tree2702c8b1106d9fd6bad6b24d49b355d9b01561f9 /source4
parentbcc952d19dd5e1731386ccd1d7150e4bc306c60c (diff)
downloadsamba-340d7e807b2be7fb5c50a0cddf9378aa9bd929bf.tar.gz
samba-340d7e807b2be7fb5c50a0cddf9378aa9bd929bf.tar.bz2
samba-340d7e807b2be7fb5c50a0cddf9378aa9bd929bf.zip
s4-drs: fixed the UDV return in getncchanges
We should overwrite an existing entry if found
Diffstat (limited to 'source4')
-rw-r--r--source4/rpc_server/drsuapi/getncchanges.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/source4/rpc_server/drsuapi/getncchanges.c b/source4/rpc_server/drsuapi/getncchanges.c
index 84dc21d1b7..3189381d8e 100644
--- a/source4/rpc_server/drsuapi/getncchanges.c
+++ b/source4/rpc_server/drsuapi/getncchanges.c
@@ -447,6 +447,7 @@ static WERROR get_nc_changes_udv(struct ldb_context *sam_ctx,
NTTIME now;
time_t t = time(NULL);
struct replUpToDateVectorBlob ouv;
+ int i;
werr = load_udv(sam_ctx, udv, ncRoot_dn, &ouv);
if (!W_ERROR_IS_OK(werr)) {
@@ -459,13 +460,24 @@ static WERROR get_nc_changes_udv(struct ldb_context *sam_ctx,
unix_to_nt_time(&now, t);
tmp_cursor->last_sync_success = now;
- udv->count = ouv.ctr.ctr2.count + 1;
+ udv->count = ouv.ctr.ctr2.count;
udv->cursors = talloc_steal(udv, ouv.ctr.ctr2.cursors);
- udv->cursors = talloc_realloc(udv, udv->cursors, struct drsuapi_DsReplicaCursor2, udv->count);
- if (!udv->cursors) {
- return WERR_DS_DRA_INTERNAL_ERROR;
+
+ for (i=0; i<udv->count; i++) {
+ if (GUID_equal(&tmp_cursor->source_dsa_invocation_id,
+ &udv->cursors[i].source_dsa_invocation_id)) {
+ udv->cursors[i] = *tmp_cursor;
+ break;
+ }
+ }
+ if (i == udv->count) {
+ udv->cursors = talloc_realloc(udv, udv->cursors, struct drsuapi_DsReplicaCursor2, udv->count+1);
+ if (!udv->cursors) {
+ return WERR_DS_DRA_INTERNAL_ERROR;
+ }
+ udv->cursors[udv->count] = *tmp_cursor;
+ udv->count++;
}
- udv->cursors[udv->count - 1] = *tmp_cursor;
qsort(udv->cursors, udv->count,
sizeof(struct drsuapi_DsReplicaCursor2),