s4-rpc_server/drsupai: Avoid looping with Azure AD Connect by not incrementing temp_h...
authorAndrew Bartlett <abartlet@samba.org>
Wed, 26 Jul 2023 02:27:16 +0000 (14:27 +1200)
committerJule Anger <janger@samba.org>
Mon, 21 Aug 2023 09:12:14 +0000 (09:12 +0000)
commit794ce23b3503fa6c1b892854f86c4de9de42c31d
tree40148e54c95311ce2bb3827d82eb04909b355036
parent50bba4925e0cd47fd0419c242e66ff9220d1ae7a
s4-rpc_server/drsupai: Avoid looping with Azure AD Connect by not incrementing temp_highest_usn for the NC root

We send the NC root first, as a special case for every chunk
that we send until the natural point where it belongs.

We do not bump the tmp_highest_usn in the highwatermark that
the client and server use (it is meant to be an opauqe cookie)
until the 'natural' point where the object appears, similar
to the cache for GET_ANC.

The issue is that without this, because the NC root was sorted
first in whatever chunk it appeared in but could have a 'high'
highwatermark, Azure AD Connect will send back the same
new_highwatermark->tmp_highest_usn, and due to a bug,
a zero reserved_usn, which makes Samba discard it.

The reserved_usn is now much less likely to ever be set because
the tmp_higest_usn is now always advancing.

RN: Avoid infinite loop in initial user sync with Azure AD Connect
 when synchronising a large Samba AD domain.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15401

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
(cherry picked from commit 79ca6ef28a6f94965cb030c4a7da8c1b9db7150b)

Autobuild-User(v4-18-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-18-test): Mon Aug 21 09:12:14 UTC 2023 on atb-devel-224
selftest/knownfail.d/getncchanges
source4/rpc_server/drsuapi/getncchanges.c