wbinfo: use wbcLookupDomainControllerEx for wbinfo --dsgetdcname.
authorGünther Deschner <gd@samba.org>
Mon, 19 Oct 2009 14:54:37 +0000 (16:54 +0200)
committerGünther Deschner <gd@samba.org>
Mon, 19 Oct 2009 16:44:51 +0000 (18:44 +0200)
Guenther

nsswitch/wbinfo.c

index 219ec24fbaa72f4777695a7022a916b5b03eda23..d3d9250e81f2a8847216b0014cc466f0ec0261c7 100644 (file)
@@ -688,36 +688,29 @@ static bool wbinfo_getdcname(const char *domain_name)
 /* Find a DC */
 static bool wbinfo_dsgetdcname(const char *domain_name, uint32_t flags)
 {
 /* Find a DC */
 static bool wbinfo_dsgetdcname(const char *domain_name, uint32_t flags)
 {
-       struct winbindd_request request;
-       struct winbindd_response response;
-
-       ZERO_STRUCT(request);
-       ZERO_STRUCT(response);
-
-       fstrcpy(request.data.dsgetdcname.domain_name, domain_name);
-       request.data.dsgetdcname.flags = flags;
-
-       request.flags |= DS_DIRECTORY_SERVICE_REQUIRED;
-
-       /* Send request */
+       wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+       struct wbcDomainControllerInfoEx *dc_info;
+       char *str = NULL;
 
 
-       if (winbindd_request_response(WINBINDD_DSGETDCNAME, &request,
-                                     &response) != NSS_STATUS_SUCCESS) {
-               d_fprintf(stderr, "Could not find dc for %s\n", domain_name);
+       wbc_status = wbcLookupDomainControllerEx(domain_name, NULL, NULL,
+                                                flags | DS_DIRECTORY_SERVICE_REQUIRED,
+                                                &dc_info);
+       if (!WBC_ERROR_IS_OK(wbc_status)) {
+               printf("Could not find dc for %s\n", domain_name);
                return false;
        }
 
                return false;
        }
 
-       /* Display response */
+       wbcGuidToString(dc_info->domain_guid, &str);
 
 
-       d_printf("%s\n", response.data.dsgetdcname.dc_unc);
-       d_printf("%s\n", response.data.dsgetdcname.dc_address);
-       d_printf("%d\n", response.data.dsgetdcname.dc_address_type);
-       d_printf("%s\n", response.data.dsgetdcname.domain_guid);
-       d_printf("%s\n", response.data.dsgetdcname.domain_name);
-       d_printf("%s\n", response.data.dsgetdcname.forest_name);
-       d_printf("0x%08x\n", response.data.dsgetdcname.dc_flags);
-       d_printf("%s\n", response.data.dsgetdcname.dc_site_name);
-       d_printf("%s\n", response.data.dsgetdcname.client_site_name);
+       d_printf("%s\n", dc_info->dc_unc);
+       d_printf("%s\n", dc_info->dc_address);
+       d_printf("%d\n", dc_info->dc_address_type);
+       d_printf("%s\n", str);
+       d_printf("%s\n", dc_info->domain_name);
+       d_printf("%s\n", dc_info->forest_name);
+       d_printf("0x%08x\n", dc_info->dc_flags);
+       d_printf("%s\n", dc_info->dc_site_name);
+       d_printf("%s\n", dc_info->client_site_name);
 
        return true;
 }
 
        return true;
 }