diff options
author | coffeedude <coffeedude@drizzt.ad.plainjoe.org> | 2008-05-13 12:58:52 -0500 |
---|---|---|
committer | coffeedude <coffeedude@drizzt.ad.plainjoe.org> | 2008-05-13 12:58:52 -0500 |
commit | 34933a5c236ee489e4c11172820cdc0496b9e334 (patch) | |
tree | d0cac4fecd16558d4ebf44bcac57da2773fcf4c8 /source3 | |
parent | 9cd646c166f2c9511158c09354e4f103ff681bcf (diff) | |
download | samba-34933a5c236ee489e4c11172820cdc0496b9e334.tar.gz samba-34933a5c236ee489e4c11172820cdc0496b9e334.tar.bz2 samba-34933a5c236ee489e4c11172820cdc0496b9e334.zip |
libwbclient: Abstract the DS_XXX flags for DsGetDcName().
The wbcLookupDomainController() call supports a set of flags
defined in wbclient.h. Add a mapping function between these
flags and the original DS_XXX flags in order to prevent having
to include the generated RPC headers in wbclient.h.
(This used to be commit 31614cd5e08dd6389c66e6ddf9f2d5429c6ab033)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/winbindd/winbindd.h | 1 | ||||
-rw-r--r-- | source3/winbindd/winbindd_locator.c | 46 |
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; |