bool unix_primary_group;
bool unix_nss_info;
+ int ldap_timeout;
struct ldb_context *ldb;
struct ldb_dn **deny_ous;
domname, "unix_primary_group", false);
ctx->unix_nss_info = idmap_config_bool(
domname, "unix_nss_info", false);
+ ctx->ldap_timeout = idmap_config_int(
+ domname, "ldap_timeout", 10);
schema_mode = idmap_config_const_string(
domname, "schema_mode", "rfc2307");
rc = tldap_search(ctx->ld, ctx->default_nc, TLDAP_SCOPE_SUB, filter,
attrs, ARRAY_SIZE(attrs), 0, NULL, 0, NULL, 0,
- 0, 0, 0, talloc_tos(), &msgs);
+ ctx->ldap_timeout, 0, 0, talloc_tos(), &msgs);
if (!TLDAP_RC_IS_SUCCESS(rc)) {
return NT_STATUS_LDAP(TLDAP_RC_V(rc));
}
{
const NTSTATUS status_server_down =
NT_STATUS_LDAP(TLDAP_RC_V(TLDAP_SERVER_DOWN));
+ const NTSTATUS status_timeout =
+ NT_STATUS_LDAP(TLDAP_RC_V(TLDAP_TIMEOUT));
NTSTATUS status;
status = idmap_ad_query_user(domain, info);
- if (NT_STATUS_EQUAL(status, status_server_down)) {
+ if (NT_STATUS_EQUAL(status, status_server_down) ||
+ NT_STATUS_EQUAL(status, status_timeout))
+ {
TALLOC_FREE(domain->private_data);
- status = idmap_ad_query_user(domain, info);
+ return NT_STATUS_HOST_UNREACHABLE;
}
return status;
rc = tldap_search(ctx->ld, ctx->default_nc, TLDAP_SCOPE_SUB, filter,
attrs, ARRAY_SIZE(attrs), 0, NULL, 0, NULL, 0,
- 0, 0, 0, talloc_tos(), &msgs);
+ ctx->ldap_timeout, 0, 0, talloc_tos(), &msgs);
if (!TLDAP_RC_IS_SUCCESS(rc)) {
return NT_STATUS_LDAP(TLDAP_RC_V(rc));
}
rc = tldap_search(ctx->ld, ctx->default_nc, TLDAP_SCOPE_SUB, filter,
attrs, ARRAY_SIZE(attrs), 0, NULL, 0, NULL, 0,
- 0, 0, 0, talloc_tos(), &msgs);
+ ctx->ldap_timeout, 0, 0, talloc_tos(), &msgs);
if (!TLDAP_RC_IS_SUCCESS(rc)) {
return NT_STATUS_LDAP(TLDAP_RC_V(rc));
}
{
const NTSTATUS status_server_down =
NT_STATUS_LDAP(TLDAP_RC_V(TLDAP_SERVER_DOWN));
+ const NTSTATUS status_timeout =
+ NT_STATUS_LDAP(TLDAP_RC_V(TLDAP_TIMEOUT));
NTSTATUS status;
status = idmap_ad_unixids_to_sids(dom, ids);
- if (NT_STATUS_EQUAL(status, status_server_down)) {
+ if (NT_STATUS_EQUAL(status, status_server_down) ||
+ NT_STATUS_EQUAL(status, status_timeout))
+ {
TALLOC_FREE(dom->private_data);
- status = idmap_ad_unixids_to_sids(dom, ids);
+ return NT_STATUS_HOST_UNREACHABLE;
}
return status;
{
const NTSTATUS status_server_down =
NT_STATUS_LDAP(TLDAP_RC_V(TLDAP_SERVER_DOWN));
+ const NTSTATUS status_timeout =
+ NT_STATUS_LDAP(TLDAP_RC_V(TLDAP_TIMEOUT));
NTSTATUS status;
status = idmap_ad_sids_to_unixids(dom, ids);
- if (NT_STATUS_EQUAL(status, status_server_down)) {
+ if (NT_STATUS_EQUAL(status, status_server_down) ||
+ NT_STATUS_EQUAL(status, status_timeout))
+ {
TALLOC_FREE(dom->private_data);
- status = idmap_ad_sids_to_unixids(dom, ids);
+ return NT_STATUS_HOST_UNREACHABLE;
}
return status;
#include "lib/global_contexts.h"
#include "librpc/gen_ndr/ndr_winbind_c.h"
#include "libsmb/smbsock_connect.h"
+#include "source3/libsmb/namequery.h"
+#include "source3/libsmb/dsgetdcname.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_WINBIND
winbindd_unset_locator_kdc_env(domain);
}
+void winbind_idmap_add_failed_connection_entry(const char *_domain_name)
+{
+ struct netr_DsRGetDCNameInfo *dcinfo = NULL;
+ const char *dc_unc = NULL;
+ const char *dc_address = NULL;
+ char *domain_name = NULL;
+ struct winbindd_domain *domain = NULL;
+ NTSTATUS failed_status = NT_STATUS_HOST_UNREACHABLE;
+ NTSTATUS status;
+
+ domain_name = talloc_strdup_upper(talloc_tos(), _domain_name);
+ if (domain_name == NULL) {
+ DBG_ERR("talloc_strdup_upper failed\n");
+ return;
+ }
+
+ status = wb_dsgetdcname_gencache_get(talloc_tos(), domain_name, &dcinfo);
+ if (!NT_STATUS_IS_OK(status)) {
+ DBG_DEBUG("Missing DC cache for domain '%s'\n", domain_name);
+ goto done;
+ }
+
+ dc_unc = dcinfo->dc_unc;
+ while (dc_unc[0] == '\\') {
+ dc_unc++;
+ }
+ dc_address = dcinfo->dc_address;
+ while (dc_address[0] == '\\') {
+ dc_address++;
+ }
+
+ add_failed_connection_entry(domain_name, dc_unc, failed_status);
+ add_failed_connection_entry(domain_name, dc_address, failed_status);
+
+ domain = find_domain_from_name_noinit(domain_name);
+ if (domain == NULL) {
+ goto done;
+ }
+ if (domain->alt_name == NULL) {
+ goto done;
+ }
+
+ add_failed_connection_entry(domain->alt_name, dc_unc, failed_status);
+ add_failed_connection_entry(domain->alt_name, dc_address, failed_status);
+
+done:
+ TALLOC_FREE(domain_name);
+ TALLOC_FREE(dcinfo);
+}
+
/* Choose between anonymous or authenticated connections. We need to use
an authenticated connection if DCs have the RestrictAnonymous registry
entry set > 0, or the "Additional restrictions for anonymous