wbinfo: Improve output of wbinfo --ping-dc
authorChristof Schmitt <christof.schmitt@us.ibm.com>
Fri, 10 Aug 2012 15:41:41 +0000 (08:41 -0700)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 15 Aug 2012 01:44:43 +0000 (11:44 +1000)
Use wbcPingDc2 to get the DC name and print it.

Cleanup error messages: Remove "Could not ping our DC", there is always
a more specific message.  Avoid printing "failed to call wbcPingDc" in
case the ping has been attempted and it returns an error, the error is
already printed.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
nsswitch/wbinfo.c

index 3f7036dcbadc1d6eed92d5b9d9d7bbff5907bf08..70a7b1547a4a8ff87fbe989f5483f9d7ce9428f8 100644 (file)
@@ -831,16 +831,19 @@ static bool wbinfo_ping_dc(void)
 {
        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
        struct wbcAuthErrorInfo *error = NULL;
+       char *dcname = NULL;
 
-       wbc_status = wbcPingDc(NULL, &error);
+       wbc_status = wbcPingDc2(NULL, &error, &dcname);
 
-       d_printf("checking the NETLOGON dc connection %s\n",
+       d_printf("checking the NETLOGON dc connection to \"%s\" %s\n",
+                dcname ? dcname : "",
                 WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed");
 
        if (wbc_status == WBC_ERR_AUTH_ERROR) {
                d_fprintf(stderr, "error code was %s (0x%x)\n",
                          error->nt_string, error->nt_status);
                wbcFreeMemory(error);
+               return false;
        }
        if (!WBC_ERROR_IS_OK(wbc_status)) {
                d_fprintf(stderr, "failed to call wbcPingDc: %s\n",
@@ -2371,7 +2374,6 @@ int main(int argc, char **argv, char **envp)
                        break;
                case 'P':
                        if (!wbinfo_ping_dc()) {
-                               d_fprintf(stderr, "Could not ping our DC\n");
                                goto done;
                        }
                        break;