diff options
author | Günther Deschner <gd@samba.org> | 2008-10-07 18:54:08 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2008-10-10 11:13:04 +0200 |
commit | 83f55e07557579cd0b9fe3972947fb2327990014 (patch) | |
tree | b944f60d0ea7bdd23105a95697ff232c14d508b6 | |
parent | 10f65cc4ca5a48b6f4dc8c4de23e59628b6f95b2 (diff) | |
download | samba-83f55e07557579cd0b9fe3972947fb2327990014.tar.gz samba-83f55e07557579cd0b9fe3972947fb2327990014.tar.bz2 samba-83f55e07557579cd0b9fe3972947fb2327990014.zip |
krb5_locator: use wbcLookupDomainControllerEx() for query.
Guenther
-rw-r--r-- | source3/Makefile.in | 6 | ||||
-rw-r--r-- | source3/nsswitch/winbind_krb5_locator.c | 39 |
2 files changed, 21 insertions, 24 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index 175dcb36be..3ef197bcf2 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -1078,7 +1078,7 @@ LDBDEL_OBJ = $(LDB_CMDLINE_OBJ) lib/ldb/tools/ldbdel.o LDBMODIFY_OBJ = $(LDB_CMDLINE_OBJ) lib/ldb/tools/ldbmodify.o WINBIND_KRB5_LOCATOR_OBJ1 = nsswitch/winbind_krb5_locator.o -WINBIND_KRB5_LOCATOR_OBJ = $(WINBIND_KRB5_LOCATOR_OBJ1) $(WBCOMMON_OBJ) $(LIBREPLACE_OBJ) +WINBIND_KRB5_LOCATOR_OBJ = $(WINBIND_KRB5_LOCATOR_OBJ1) $(LIBREPLACE_OBJ) POPT_OBJ=../lib/popt/findme.o ../lib/popt/popt.o ../lib/popt/poptconfig.o \ ../lib/popt/popthelp.o ../lib/popt/poptparse.o @@ -2177,9 +2177,9 @@ bin/vlp@EXEEXT@: $(BINARY_PREREQS) $(VLP_OBJ) @LIBTALLOC_SHARED@ @LIBTDB_SHARED@ $(LDAP_LIBS) $(KRB5LIBS) $(LIBS) $(LIBTALLOC_LIBS) $(LIBTDB_LIBS) \ @SONAMEFLAG@`basename $@`@NSSSONAMEVERSIONSUFFIX@ -bin/winbind_krb5_locator.@SHLIBEXT@: $(BINARY_PREREQS) $(WINBIND_KRB5_LOCATOR_OBJ) +bin/winbind_krb5_locator.@SHLIBEXT@: $(BINARY_PREREQS) $(WINBIND_KRB5_LOCATOR_OBJ) @LIBWBCLIENT_SHARED@ @echo "Linking $@" - @$(SHLD) $(LDSHFLAGS) -o $@ $(WINBIND_KRB5_LOCATOR_OBJ) \ + @$(SHLD) $(LDSHFLAGS) -o $@ $(WINBIND_KRB5_LOCATOR_OBJ) $(WINBIND_LIBS) \ @SONAMEFLAG@`basename $@` bin/pam_winbind.@SHLIBEXT@: $(BINARY_PREREQS) $(PAM_WINBIND_OBJ) diff --git a/source3/nsswitch/winbind_krb5_locator.c b/source3/nsswitch/winbind_krb5_locator.c index 7eecd13b70..b9e35bdec5 100644 --- a/source3/nsswitch/winbind_krb5_locator.c +++ b/source3/nsswitch/winbind_krb5_locator.c @@ -18,6 +18,7 @@ */ #include "nsswitch/winbind_client.h" +#include "libwbclient/wbclient.h" #ifndef DEBUG_KRB5 #undef DEBUG_KRB5 @@ -244,54 +245,50 @@ static void smb_krb5_locator_close(void *private_data) static bool ask_winbind(const char *realm, char **dcname) { - NSS_STATUS status; - struct winbindd_request request; - struct winbindd_response response; + wbcErr wbc_status; const char *dc = NULL; + struct wbcDomainControllerInfoEx *dc_info = NULL; + uint32_t flags; - ZERO_STRUCT(request); - ZERO_STRUCT(response); + flags = WBC_LOOKUP_DC_KDC_REQUIRED | + WBC_LOOKUP_DC_IS_DNS_NAME | + WBC_LOOKUP_DC_RETURN_DNS_NAME | + WBC_LOOKUP_DC_IP_REQUIRED; - request.data.dsgetdcname.flags = 0x40020600; - /* DS_KDC_REQUIRED | - DS_IS_DNS_NAME | - DS_RETURN_DNS_NAME | - DS_IP_REQUIRED */ + wbc_status = wbcLookupDomainControllerEx(realm, NULL, NULL, flags, &dc_info); - strncpy(request.data.dsgetdcname.domain_name, realm, - sizeof(request.data.dsgetdcname.domain_name)-1); - - status = winbindd_request_response(WINBINDD_DSGETDCNAME, - &request, &response); - if (status != NSS_STATUS_SUCCESS) { + if (!WBC_ERROR_IS_OK(wbc_status)) { #ifdef DEBUG_KRB5 fprintf(stderr,"[%5u]: smb_krb5_locator_lookup: failed with: %s\n", - (unsigned int)getpid(), nss_err_str(status)); + (unsigned int)getpid(), wbcErrorString(wbc_status)); #endif return false; } - if (response.data.dsgetdcname.dc_address[0] != '\0') { - dc = response.data.dsgetdcname.dc_address; + if (dc_info->dc_address) { + dc = dc_info->dc_address; if (dc[0] == '\\') dc++; if (dc[0] == '\\') dc++; } - if (!dc && response.data.dsgetdcname.dc_unc[0] != '\0') { - dc = response.data.dsgetdcname.dc_unc; + if (!dc && dc_info->dc_unc) { + dc = dc_info->dc_unc; if (dc[0] == '\\') dc++; if (dc[0] == '\\') dc++; } if (!dc) { + wbcFreeMemory(dc_info); return false; } *dcname = strdup(dc); if (!*dcname) { + wbcFreeMemory(dc_info); return false; } + wbcFreeMemory(dc_info); return true; } |