Implement NETLOGON GetDCName client side. You can ask a DC for the name of
[ira/wip.git] / source3 / rpcclient / cmd_netlogon.c
index a48b59bf6a38ec31b4a49dd77aec08c5b53dfa5c..9e281fefce444538df98cc215f23e3e195139b81 100644 (file)
@@ -45,6 +45,31 @@ static NTSTATUS cmd_netlogon_logon_ctrl2(struct cli_state *cli,
        return result;
 }
 
+static NTSTATUS cmd_netlogon_getdcname(struct cli_state *cli, 
+                                      TALLOC_CTX *mem_ctx, int argc, 
+                                      const char **argv)
+{
+       fstring dcname;
+       NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+
+       if (argc != 2) {
+               fprintf(stderr, "Usage: %s domainname\n", argv[0]);
+               return NT_STATUS_OK;
+       }
+
+       result = cli_netlogon_getdcname(cli, mem_ctx, argv[1], dcname);
+
+       if (!NT_STATUS_IS_OK(result))
+               goto done;
+
+       /* Display results */
+
+       printf("%s\n", dcname);
+
+ done:
+       return result;
+}
+
 static NTSTATUS cmd_netlogon_logon_ctrl(struct cli_state *cli, 
                                         TALLOC_CTX *mem_ctx, int argc, 
                                         const char **argv)
@@ -309,6 +334,7 @@ struct cmd_set netlogon_commands[] = {
        { "NETLOGON" },
 
        { "logonctrl2", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl2, NULL, PI_NETLOGON, "Logon Control 2",     "" },
+       { "getdcname", RPC_RTYPE_NTSTATUS, cmd_netlogon_getdcname, NULL, PI_NETLOGON, "Get trusted DC name",     "" },
        { "logonctrl",  RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl,  NULL, PI_NETLOGON, "Logon Control",       "" },
        { "samsync",    RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync,    NULL, PI_NETLOGON, "Sam Synchronisation", "" },
        { "samdeltas",  RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas,  NULL, PI_NETLOGON, "Query Sam Deltas",    "" },