From f77bfed088b93f3ed0f00d0c172ad495c6c2b09b Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 15 Dec 2012 10:18:08 +0100 Subject: s4:drsuapi: try to behave more like windows for usn order (bug #9508) We don't behave completely like a Windows server, but it's much more identical than before. The partition head is always the first object followed by the rest sorted by uSNChanged. Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett Autobuild-User(master): Stefan Metzmacher Autobuild-Date(master): Tue Jan 1 21:09:42 CET 2013 on sn-devel-104 --- source4/rpc_server/drsuapi/getncchanges.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'source4/rpc_server/drsuapi') diff --git a/source4/rpc_server/drsuapi/getncchanges.c b/source4/rpc_server/drsuapi/getncchanges.c index 8ea17e5bfd..c3fd000e8a 100644 --- a/source4/rpc_server/drsuapi/getncchanges.c +++ b/source4/rpc_server/drsuapi/getncchanges.c @@ -700,20 +700,27 @@ static int site_res_cmp_usn_order(struct drsuapi_changed_objects *m1, struct drsuapi_changed_objects *m2, struct drsuapi_getncchanges_state *getnc_state) { - unsigned usnchanged1, usnchanged2; - unsigned cn1, cn2; + int ret; - cn1 = ldb_dn_get_comp_num(m1->dn); - cn2 = ldb_dn_get_comp_num(m2->dn); - if (cn1 != cn2) { - return cn1 > cn2 ? 1 : -1; + ret = ldb_dn_compare(getnc_state->ncRoot_dn, m1->dn); + if (ret == 0) { + return -1; } - usnchanged1 = m1->usn; - usnchanged2 = m2->usn; - if (usnchanged1 == usnchanged2) { - return 0; + + ret = ldb_dn_compare(getnc_state->ncRoot_dn, m2->dn); + if (ret == 0) { + return 1; } - return usnchanged1 > usnchanged2 ? 1 : -1; + + if (m1->usn == m2->usn) { + return ldb_dn_compare(m2->dn, m1->dn); + } + + if (m1->usn < m2->usn) { + return -1; + } + + return 1; } -- cgit