2 Unix SMB/CIFS implementation.
5 Copyright (C) Günther Deschner 2007
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "rpcclient.h"
24 static WERROR cmd_wkssvc_wkstagetinfo(struct rpc_pipe_client *cli,
32 union wkssvc_NetWkstaInfo info;
33 const char *server_name;
36 printf("usage: %s <level>\n", argv[0]);
41 level = atoi(argv[1]);
44 server_name = cli->cli->desthost;
46 status = rpccli_wkssvc_NetWkstaGetInfo(cli, mem_ctx,
51 if (!NT_STATUS_IS_OK(status)) {
52 return ntstatus_to_werror(status);
58 static WERROR cmd_wkssvc_getjoininformation(struct rpc_pipe_client *cli,
63 const char *server_name;
64 const char *name_buffer;
65 enum wkssvc_NetJoinStatus name_type;
69 server_name = cli->cli->desthost;
72 status = rpccli_wkssvc_NetrGetJoinInformation(cli, mem_ctx,
77 if (!NT_STATUS_IS_OK(status)) {
78 return ntstatus_to_werror(status);
81 if (W_ERROR_IS_OK(werr)) {
82 printf("%s (%d)\n", name_buffer, name_type);
88 static WERROR cmd_wkssvc_messagebuffersend(struct rpc_pipe_client *cli,
93 const char *server_name = cli->cli->desthost;
94 const char *message_name = cli->cli->desthost;
95 const char *message_sender_name = cli->cli->desthost;
96 smb_ucs2_t *message_buffer = NULL;
97 size_t message_size = 0;
98 const char *message = "my message";
106 message_size = push_ucs2_talloc(mem_ctx,
109 if (message_size == -1) {
113 status = rpccli_wkssvc_NetrMessageBufferSend(cli, mem_ctx,
117 (uint8_t *)message_buffer,
120 if (!NT_STATUS_IS_OK(status)) {
121 return ntstatus_to_werror(status);
127 static WERROR cmd_wkssvc_enumeratecomputernames(struct rpc_pipe_client *cli,
132 const char *server_name;
133 enum wkssvc_ComputerNameType name_type = NetAllComputerNames;
135 struct wkssvc_ComputerNamesCtr *ctr = NULL;
138 server_name = cli->cli->desthost;
141 name_type = atoi(argv[1]);
144 status = rpccli_wkssvc_NetrEnumerateComputerNames(cli, mem_ctx,
149 if (!NT_STATUS_IS_OK(status)) {
150 return ntstatus_to_werror(status);
153 if (W_ERROR_IS_OK(werr)) {
155 for (i = 0; i < ctr->count; i++) {
156 printf("name: %d %s\n", i, ctr->computer_name->string);
163 struct cmd_set wkssvc_commands[] = {
166 { "wkssvc_wkstagetinfo", RPC_RTYPE_WERROR, NULL, cmd_wkssvc_wkstagetinfo, PI_WKSSVC, NULL, "Query WKSSVC Workstation Information", "" },
167 { "wkssvc_getjoininformation", RPC_RTYPE_WERROR, NULL, cmd_wkssvc_getjoininformation, PI_WKSSVC, NULL, "Query WKSSVC Join Information", "" },
168 { "wkssvc_messagebuffersend", RPC_RTYPE_WERROR, NULL, cmd_wkssvc_messagebuffersend, PI_WKSSVC, NULL, "Send WKSSVC message", "" },
169 { "wkssvc_enumeratecomputernames", RPC_RTYPE_WERROR, NULL, cmd_wkssvc_enumeratecomputernames, PI_WKSSVC, NULL, "Enumerate WKSSVC computer names", "" },