summaryrefslogtreecommitdiff
path: root/source4/rpc_server/drsuapi
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2012-12-15 10:18:08 +0100
committerStefan Metzmacher <metze@samba.org>2013-01-01 21:09:41 +0100
commitf77bfed088b93f3ed0f00d0c172ad495c6c2b09b (patch)
tree127ab677cba01f7dabce4a836b7d86b58a73fbe3 /source4/rpc_server/drsuapi
parent16aef75c4f83c114206aa7637fedc9c2c2486877 (diff)
downloadsamba-f77bfed088b93f3ed0f00d0c172ad495c6c2b09b.tar.gz
samba-f77bfed088b93f3ed0f00d0c172ad495c6c2b09b.tar.bz2
samba-f77bfed088b93f3ed0f00d0c172ad495c6c2b09b.zip
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 <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Tue Jan 1 21:09:42 CET 2013 on sn-devel-104
Diffstat (limited to 'source4/rpc_server/drsuapi')
-rw-r--r--source4/rpc_server/drsuapi/getncchanges.c29
1 files changed, 18 insertions, 11 deletions
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;
}