summaryrefslogtreecommitdiff
path: root/nsswitch/wbinfo.c
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-12-21 21:50:43 +0100
committerVolker Lendecke <vl@samba.org>2009-12-21 23:23:52 +0100
commit9b6b01aab6a6a0ebb34798bb78febb2df17b302d (patch)
treeaf8861a982ce0c9f95d65b2d8e5d5a0d280d00e2 /nsswitch/wbinfo.c
parent2308ec70a53d3990ea98162bcbcc73326ef63687 (diff)
downloadsamba-9b6b01aab6a6a0ebb34798bb78febb2df17b302d.tar.gz
samba-9b6b01aab6a6a0ebb34798bb78febb2df17b302d.tar.bz2
samba-9b6b01aab6a6a0ebb34798bb78febb2df17b302d.zip
s3:winbind: Add a lower-cost alternative to wbinfo -t: wbinfo --ping-dc
This just does a NULL RPC call through an existing NETLOGON connection. If someone knows an operation that "just works" and does not return NOT_SUPPORTED, please tell me :-)
Diffstat (limited to 'nsswitch/wbinfo.c')
-rw-r--r--nsswitch/wbinfo.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/nsswitch/wbinfo.c b/nsswitch/wbinfo.c
index d3d9250e81..45d8684bad 100644
--- a/nsswitch/wbinfo.c
+++ b/nsswitch/wbinfo.c
@@ -5,6 +5,7 @@
Copyright (C) Tim Potter 2000-2003
Copyright (C) Andrew Bartlett 2002-2007
+ Copyright (C) Volker Lendecke 2009
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -779,6 +780,30 @@ static bool wbinfo_change_secret(const char *domain)
return true;
}
+/* Check DC connection */
+
+static bool wbinfo_ping_dc(void)
+{
+ wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
+ struct wbcAuthErrorInfo *error = NULL;
+
+ wbc_status = wbcPingDc(NULL, &error);
+
+ d_printf("checking the NETLOGON dc connection %s\n",
+ 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);
+ }
+ if (!WBC_ERROR_IS_OK(wbc_status)) {
+ return false;
+ }
+
+ return true;
+}
+
/* Convert uid to sid */
static bool wbinfo_uid_to_sid(uid_t uid)
@@ -1710,6 +1735,7 @@ enum {
OPT_VERBOSE,
OPT_ONLINESTATUS,
OPT_CHANGE_USER_PASSWORD,
+ OPT_PING_DC,
OPT_SID_TO_FULLNAME,
OPT_NTLMV2,
OPT_LANMAN
@@ -1759,6 +1785,8 @@ int main(int argc, char **argv, char **envp)
{ "remove-gid-mapping", 0, POPT_ARG_STRING, &string_arg, OPT_REMOVE_GID_MAPPING, "Remove gid to sid mapping in idmap", "GID,SID" },
{ "check-secret", 't', POPT_ARG_NONE, 0, 't', "Check shared secret" },
{ "change-secret", 'c', POPT_ARG_NONE, 0, 'c', "Change shared secret" },
+ { "ping-dc", 0, POPT_ARG_NONE, 0, OPT_PING_DC,
+ "Check the NETLOGON connection" },
{ "trusted-domains", 'm', POPT_ARG_NONE, 0, 'm', "List trusted domains" },
{ "all-domains", 0, POPT_ARG_NONE, 0, OPT_LIST_ALL_DOMAINS, "List all domains (trusted and own domain)" },
{ "own-domain", 0, POPT_ARG_NONE, 0, OPT_LIST_OWN_DOMAIN, "List own domain" },
@@ -1995,6 +2023,12 @@ int main(int argc, char **argv, char **envp)
goto done;
}
break;
+ case OPT_PING_DC:
+ if (!wbinfo_ping_dc()) {
+ d_fprintf(stderr, "Could not ping our DC\n");
+ goto done;
+ }
+ break;
case 'm':
if (!wbinfo_list_domains(false, verbose)) {
d_fprintf(stderr,