winbindd: Add force_dc to bypass cached connection and DC lookup
authorRalph Boehme <slow@samba.org>
Tue, 22 Nov 2022 13:23:21 +0000 (14:23 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 21 Dec 2022 19:10:35 +0000 (19:10 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/winbindd/winbindd.h
source3/winbindd/winbindd_cm.c

index 5044fee0c68344c734d3d3026eb4d7f148a5fa4a..8a40208e3786df6b7eb47b4dbd81a405ae55b8a7 100644 (file)
@@ -153,6 +153,7 @@ struct winbindd_domain {
        } backend_data;
 
        /* A working DC */
+       bool force_dc;
        char *dcname;
        const char *ping_dcname;
        struct sockaddr_storage dcaddr;
index 135c122e2eec0040f86dcb7e50448457e9f00e36..264fc1368d64519ce6e1acc71c6c84d0a49300c3 100644 (file)
@@ -1404,7 +1404,11 @@ static bool connect_preferred_dc(TALLOC_CTX *mem_ctx,
         * We have to check the server affinity cache here since later we select
         * a DC based on response time and not preference.
         */
-       saf_servername = saf_fetch(mem_ctx, domain->name);
+       if (domain->force_dc) {
+               saf_servername = domain->dcname;
+       } else {
+               saf_servername = saf_fetch(mem_ctx, domain->name);
+       }
 
        /*
         * Check the negative connection cache before talking to it. It going
@@ -1509,6 +1513,10 @@ static bool find_dc(TALLOC_CTX *mem_ctx,
                return true;
        }
 
+       if (domain->force_dc) {
+               return false;
+       }
+
  again:
        if (!get_dcs(mem_ctx, domain, &dcs, &num_dcs, request_flags) || (num_dcs == 0))
                return False;