summaryrefslogtreecommitdiff
path: root/source3/nsswitch/winbind_krb5_locator.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/nsswitch/winbind_krb5_locator.c')
-rw-r--r--source3/nsswitch/winbind_krb5_locator.c39
1 files changed, 18 insertions, 21 deletions
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;
}