}
}
- site_name = samdb_client_site_name(sam_ctx, r, client_str, NULL);
+ site_name = samdb_client_site_name(sam_ctx, r, client_str, NULL, true);
status = get_dcs(r, sam_ctx, site_name, need_fqdn, &set, 0);
if (!NT_STATUS_IS_OK(status)) {
}
}
- site_name = samdb_client_site_name(sam_ctx, r, client_str, NULL);
+ site_name = samdb_client_site_name(sam_ctx, r, client_str, NULL, true);
status = get_dcs(r, sam_ctx, site_name, need_fqdn, &set, 0);
if (!NT_STATUS_IS_OK(status)) {
/*
* Finds the client site by using the client's IP address.
* The "subnet_name" returns the name of the subnet if parameter != NULL
+ *
+ * Has a Windows-based fallback to provide the only site available, or an empty
+ * string if there are multiple sites.
*/
const char *samdb_client_site_name(struct ldb_context *ldb, TALLOC_CTX *mem_ctx,
- const char *ip_address, char **subnet_name)
+ const char *ip_address, char **subnet_name,
+ bool fallback)
{
const char *attrs[] = { "cn", "siteObject", NULL };
struct ldb_dn *sites_container_dn, *subnets_dn, *sites_dn;
}
}
- if (site_name == NULL) {
+ if (site_name == NULL && fallback) {
/* This is the Windows Server fallback rule: when no subnet
* exists and we have only one site available then use it (it
* is for sure the same as our server site). If more sites do
server_site = samdb_server_site_name(sam_ctx, mem_ctx);
NT_STATUS_HAVE_NO_MEMORY(server_site);
client_site = samdb_client_site_name(sam_ctx, mem_ctx,
- src_address, NULL);
+ src_address, NULL,
+ true);
NT_STATUS_HAVE_NO_MEMORY(client_site);
if (strcasecmp(server_site, client_site) == 0) {
server_type |= DS_SERVER_CLOSEST;
ctr->sitename[i].string = samdb_client_site_name(sam_ctx,
mem_ctx,
addr_str,
- &subnet_name);
+ &subnet_name,
+ true);
W_ERROR_HAVE_NO_MEMORY(ctr->sitename[i].string);
ctr->subnetname[i].string = subnet_name;
}