90 lines
3.4 KiB
Diff
90 lines
3.4 KiB
Diff
From cce018a29027fe531de9191cdc905ab201deb133 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
|
|
Date: Tue, 5 Jan 2016 13:20:14 +0100
|
|
Subject: [PATCH 06/49] AD SRV: prefer site-local DCs in LDAP ping
|
|
|
|
Resolves:
|
|
https://fedorahosted.org/sssd/ticket/2765
|
|
|
|
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
(cherry picked from commit a1c6869c67fcf4971ac843315b97bf46893ca92d)
|
|
---
|
|
src/providers/ad/ad_srv.c | 40 ++++++++++++++++++++++++++++++----------
|
|
1 file changed, 30 insertions(+), 10 deletions(-)
|
|
|
|
diff --git a/src/providers/ad/ad_srv.c b/src/providers/ad/ad_srv.c
|
|
index 123aac6a4a73a60b5d597d9b34eb5fbd7865f8d3..e719272520cee11739431a686a6cf09aaf76947e 100644
|
|
--- a/src/providers/ad/ad_srv.c
|
|
+++ b/src/providers/ad/ad_srv.c
|
|
@@ -118,7 +118,8 @@ static void ad_get_dc_servers_done(struct tevent_req *subreq);
|
|
static struct tevent_req *ad_get_dc_servers_send(TALLOC_CTX *mem_ctx,
|
|
struct tevent_context *ev,
|
|
struct resolv_ctx *resolv_ctx,
|
|
- const char *domain)
|
|
+ const char *discovery_domain,
|
|
+ const char *site)
|
|
{
|
|
struct ad_get_dc_servers_state *state = NULL;
|
|
struct tevent_req *req = NULL;
|
|
@@ -133,21 +134,39 @@ static struct tevent_req *ad_get_dc_servers_send(TALLOC_CTX *mem_ctx,
|
|
return NULL;
|
|
}
|
|
|
|
- domains = talloc_zero_array(state, const char *, 2);
|
|
+ domains = talloc_zero_array(state, const char *, 3);
|
|
if (domains == NULL) {
|
|
ret = ENOMEM;
|
|
goto immediately;
|
|
}
|
|
|
|
- domains[0] = talloc_strdup(domains, domain);
|
|
- if (domains[0] == NULL) {
|
|
- ret = ENOMEM;
|
|
- goto immediately;
|
|
+ if (site == NULL) {
|
|
+ DEBUG(SSSDBG_TRACE_FUNC, "Looking up domain controllers in domain "
|
|
+ "%s\n", discovery_domain);
|
|
+
|
|
+ domains[0] = talloc_strdup(domains, discovery_domain);
|
|
+ if (domains[0] == NULL) {
|
|
+ ret = ENOMEM;
|
|
+ goto immediately;
|
|
+ }
|
|
+ } else {
|
|
+ DEBUG(SSSDBG_TRACE_FUNC, "Looking up domain controllers in domain "
|
|
+ "%s and site %s\n", discovery_domain, site);
|
|
+
|
|
+ domains[0] = talloc_asprintf(state, AD_SITE_DOMAIN_FMT,
|
|
+ site, discovery_domain);
|
|
+ if (domains[0] == NULL) {
|
|
+ ret = ENOMEM;
|
|
+ goto immediately;
|
|
+ }
|
|
+
|
|
+ domains[1] = talloc_strdup(domains, discovery_domain);
|
|
+ if (domains[1] == NULL) {
|
|
+ ret = ENOMEM;
|
|
+ goto immediately;
|
|
+ }
|
|
}
|
|
|
|
- DEBUG(SSSDBG_TRACE_FUNC, "Looking up domain controllers in domain %s\n",
|
|
- domain);
|
|
-
|
|
subreq = fo_discover_srv_send(state, ev, resolv_ctx,
|
|
"ldap", FO_PROTO_TCP, domains);
|
|
if (subreq == NULL) {
|
|
@@ -692,7 +711,8 @@ struct tevent_req *ad_srv_plugin_send(TALLOC_CTX *mem_ctx,
|
|
DEBUG(SSSDBG_TRACE_FUNC, "About to find domain controllers\n");
|
|
|
|
subreq = ad_get_dc_servers_send(state, ev, ctx->be_res->resolv,
|
|
- state->discovery_domain);
|
|
+ state->discovery_domain,
|
|
+ state->ctx->ad_site_override);
|
|
if (subreq == NULL) {
|
|
ret = ENOMEM;
|
|
goto immediately;
|
|
--
|
|
2.5.0
|
|
|