summaryrefslogtreecommitdiff
path: root/source3/winbindd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/winbindd')
-rw-r--r--source3/winbindd/winbindd.h1
-rw-r--r--source3/winbindd/winbindd_locator.c46
2 files changed, 46 insertions, 1 deletions
diff --git a/source3/winbindd/winbindd.h b/source3/winbindd/winbindd.h
index 0840e581fe..301d877e61 100644
--- a/source3/winbindd/winbindd.h
+++ b/source3/winbindd/winbindd.h
@@ -24,6 +24,7 @@
#define _WINBINDD_H
#include "nsswitch/winbind_struct_protocol.h"
+#include "nsswitch/libwbclient/wbclient.h"
#ifdef HAVE_LIBNSCD
#include <libnscd.h>
diff --git a/source3/winbindd/winbindd_locator.c b/source3/winbindd/winbindd_locator.c
index 709fbcc5d1..b2a8bd7e30 100644
--- a/source3/winbindd/winbindd_locator.c
+++ b/source3/winbindd/winbindd_locator.c
@@ -54,12 +54,54 @@ void winbindd_dsgetdcname(struct winbindd_cli_state *state)
sendto_child(state, locator_child());
}
+struct wbc_flag_map {
+ uint32_t wbc_dc_flag;
+ uint32_t ds_dc_flags;
+};
+
+static uint32_t get_dsgetdc_flags(uint32_t wbc_flags)
+{
+ struct wbc_flag_map lookup_dc_flags[] = {
+ { WBC_LOOKUP_DC_FORCE_REDISCOVERY, DS_FORCE_REDISCOVERY },
+ { WBC_LOOKUP_DC_DS_REQUIRED, DS_DIRECTORY_SERVICE_REQUIRED },
+ { WBC_LOOKUP_DC_DS_PREFERRED, DS_DIRECTORY_SERVICE_PREFERRED},
+ { WBC_LOOKUP_DC_GC_SERVER_REQUIRED, DS_GC_SERVER_REQUIRED },
+ { WBC_LOOKUP_DC_PDC_REQUIRED, DS_PDC_REQUIRED},
+ { WBC_LOOKUP_DC_BACKGROUND_ONLY, DS_BACKGROUND_ONLY },
+ { WBC_LOOKUP_DC_IP_REQUIRED, DS_IP_REQUIRED },
+ { WBC_LOOKUP_DC_KDC_REQUIRED, DS_KDC_REQUIRED },
+ { WBC_LOOKUP_DC_TIMESERV_REQUIRED, DS_TIMESERV_REQUIRED },
+ { WBC_LOOKUP_DC_WRITABLE_REQUIRED, DS_WRITABLE_REQUIRED },
+ { WBC_LOOKUP_DC_GOOD_TIMESERV_PREFERRED, DS_GOOD_TIMESERV_PREFERRED },
+ { WBC_LOOKUP_DC_AVOID_SELF, DS_AVOID_SELF },
+ { WBC_LOOKUP_DC_ONLY_LDAP_NEEDED, DS_ONLY_LDAP_NEEDED },
+ { WBC_LOOKUP_DC_IS_FLAT_NAME, DS_IS_FLAT_NAME },
+ { WBC_LOOKUP_DC_IS_DNS_NAME, DS_IS_DNS_NAME },
+ { WBC_LOOKUP_DC_TRY_NEXTCLOSEST_SITE, DS_TRY_NEXTCLOSEST_SITE },
+ { WBC_LOOKUP_DC_DS_6_REQUIRED, DS_DIRECTORY_SERVICE_6_REQUIRED },
+ { WBC_LOOKUP_DC_RETURN_DNS_NAME, DS_RETURN_DNS_NAME },
+ { WBC_LOOKUP_DC_RETURN_FLAT_NAME, DS_RETURN_FLAT_NAME }
+ };
+ uint32_t ds_flags = 0;
+ int i = 0 ;
+ int num_entries = sizeof(lookup_dc_flags) / sizeof(struct wbc_flag_map);
+
+ for (i=0; i<num_entries; i++) {
+ if (wbc_flags & lookup_dc_flags[i].wbc_dc_flag)
+ ds_flags |= lookup_dc_flags[i].ds_dc_flags;
+ }
+
+ return ds_flags;
+}
+
+
static enum winbindd_result dual_dsgetdcname(struct winbindd_domain *domain,
struct winbindd_cli_state *state)
{
NTSTATUS result;
struct netr_DsRGetDCNameInfo *info = NULL;
const char *dc = NULL;
+ uint32_t ds_flags = 0;
state->request.domain_name
[sizeof(state->request.domain_name)-1] = '\0';
@@ -67,9 +109,11 @@ static enum winbindd_result dual_dsgetdcname(struct winbindd_domain *domain,
DEBUG(3, ("[%5lu]: dsgetdcname for %s\n", (unsigned long)state->pid,
state->request.domain_name));
+ ds_flags = get_dsgetdc_flags(state->request.flags);
+
result = dsgetdcname(state->mem_ctx, winbind_messaging_context(),
state->request.domain_name,
- NULL, NULL, state->request.flags, &info);
+ NULL, NULL, ds_flags, &info);
if (!NT_STATUS_IS_OK(result)) {
return WINBINDD_ERROR;