diff options
author | Günther Deschner <gd@samba.org> | 2006-10-07 05:26:21 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:15:18 -0500 |
commit | 7b84b133fe375e69817fe5c76089f67280507809 (patch) | |
tree | 8171348f76887d3d757d44246f1193f0663bfd88 /source3/rpcclient | |
parent | e0b6961ac5b501f51bd004a392c606e3ef308fee (diff) | |
download | samba-7b84b133fe375e69817fe5c76089f67280507809.tar.gz samba-7b84b133fe375e69817fe5c76089f67280507809.tar.bz2 samba-7b84b133fe375e69817fe5c76089f67280507809.zip |
r19161: Add NET_GETANYDCNAME (getdcname only gives the PDC while getanydcname
gives just any DC), also make sure to set timeouts in rpcclient
accordingly so that we actually get the DC's reply.
Guenther
(This used to be commit 6091c8152a3998d2503cb0911a217ee904509633)
Diffstat (limited to 'source3/rpcclient')
-rw-r--r-- | source3/rpcclient/cmd_netlogon.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index 1a145711cc..5ae449a68c 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -51,14 +51,51 @@ static WERROR cmd_netlogon_getdcname(struct rpc_pipe_client *cli, { fstring dcname; WERROR result = WERR_GENERAL_FAILURE; + int old_timeout; if (argc != 2) { fprintf(stderr, "Usage: %s domainname\n", argv[0]); return WERR_OK; } + /* Make sure to wait for our DC's reply */ + old_timeout = cli_set_timeout(cli->cli, 30000); /* 30 seconds. */ + result = rpccli_netlogon_getdcname(cli, mem_ctx, cli->cli->desthost, argv[1], dcname); + cli_set_timeout(cli->cli, old_timeout); + + if (!W_ERROR_IS_OK(result)) + goto done; + + /* Display results */ + + printf("%s\n", dcname); + + done: + return result; +} + +static WERROR cmd_netlogon_getanydcname(struct rpc_pipe_client *cli, + TALLOC_CTX *mem_ctx, int argc, + const char **argv) +{ + fstring dcname; + WERROR result = WERR_GENERAL_FAILURE; + int old_timeout; + + if (argc != 2) { + fprintf(stderr, "Usage: %s domainname\n", argv[0]); + return WERR_OK; + } + + /* Make sure to wait for our DC's reply */ + old_timeout = cli_set_timeout(cli->cli, 30000); /* 30 seconds. */ + + result = rpccli_netlogon_getanydcname(cli, mem_ctx, cli->cli->desthost, argv[1], dcname); + + cli_set_timeout(cli->cli, old_timeout); + if (!W_ERROR_IS_OK(result)) goto done; @@ -368,7 +405,8 @@ struct cmd_set netlogon_commands[] = { { "NETLOGON" }, { "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, NULL, "Logon Control 2", "" }, - { "getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getdcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, + { "getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getdcname, PI_NETLOGON, NULL, "Get trusted PDC name", "" }, + { "getanydcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getanydcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "dsr_getdcname", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getdcname, PI_NETLOGON, NULL, "Get trusted DC name", "" }, { "dsr_getsitename", RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_getsitename, PI_NETLOGON, NULL, "Get sitename", "" }, { "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, NULL, "Logon Control", "" }, |