/* [<][>][^][v][top][bottom][index][help] */
DEFINITIONS
This source file includes following definitions.
- cmd_wkssvc_wkstagetinfo
- cmd_wkssvc_getjoininformation
- cmd_wkssvc_messagebuffersend
- cmd_wkssvc_enumeratecomputernames
1 /*
2 Unix SMB/CIFS implementation.
3 RPC pipe client
4
5 Copyright (C) Günther Deschner 2007
6
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.
11
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.
16
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/>.
19 */
20
21 #include "includes.h"
22 #include "rpcclient.h"
23
24 static WERROR cmd_wkssvc_wkstagetinfo(struct rpc_pipe_client *cli,
/* [<][>][^][v][top][bottom][index][help] */
25 TALLOC_CTX *mem_ctx,
26 int argc,
27 const char **argv)
28 {
29 NTSTATUS status;
30 WERROR werr;
31 uint32_t level = 100;
32 union wkssvc_NetWkstaInfo info;
33 const char *server_name;
34
35 if (argc > 2) {
36 printf("usage: %s <level>\n", argv[0]);
37 return WERR_OK;
38 }
39
40 if (argc > 1) {
41 level = atoi(argv[1]);
42 }
43
44 server_name = cli->desthost;
45
46 status = rpccli_wkssvc_NetWkstaGetInfo(cli, mem_ctx,
47 server_name,
48 level,
49 &info,
50 &werr);
51 if (!NT_STATUS_IS_OK(status)) {
52 return ntstatus_to_werror(status);
53 }
54
55 return werr;
56 }
57
58 static WERROR cmd_wkssvc_getjoininformation(struct rpc_pipe_client *cli,
/* [<][>][^][v][top][bottom][index][help] */
59 TALLOC_CTX *mem_ctx,
60 int argc,
61 const char **argv)
62 {
63 const char *server_name;
64 const char *name_buffer;
65 enum wkssvc_NetJoinStatus name_type;
66 NTSTATUS status;
67 WERROR werr;
68
69 server_name = cli->desthost;
70 name_buffer = "";
71
72 status = rpccli_wkssvc_NetrGetJoinInformation(cli, mem_ctx,
73 server_name,
74 &name_buffer,
75 &name_type,
76 &werr);
77 if (!NT_STATUS_IS_OK(status)) {
78 return ntstatus_to_werror(status);
79 }
80
81 if (W_ERROR_IS_OK(werr)) {
82 printf("%s (%d)\n", name_buffer, name_type);
83 }
84
85 return werr;
86 }
87
88 static WERROR cmd_wkssvc_messagebuffersend(struct rpc_pipe_client *cli,
/* [<][>][^][v][top][bottom][index][help] */
89 TALLOC_CTX *mem_ctx,
90 int argc,
91 const char **argv)
92 {
93 const char *server_name = cli->desthost;
94 const char *message_name = cli->desthost;
95 const char *message_sender_name = cli->desthost;
96 smb_ucs2_t *message_buffer = NULL;
97 size_t message_size = 0;
98 const char *message = "my message";
99 NTSTATUS status;
100 WERROR werr;
101
102 if (argc > 1) {
103 message = argv[1];
104 }
105
106 if (!push_ucs2_talloc(mem_ctx, &message_buffer, message,
107 &message_size))
108 {
109 return WERR_NOMEM;
110 }
111
112 status = rpccli_wkssvc_NetrMessageBufferSend(cli, mem_ctx,
113 server_name,
114 message_name,
115 message_sender_name,
116 (uint8_t *)message_buffer,
117 message_size,
118 &werr);
119 if (!NT_STATUS_IS_OK(status)) {
120 return ntstatus_to_werror(status);
121 }
122
123 return werr;
124 }
125
126 static WERROR cmd_wkssvc_enumeratecomputernames(struct rpc_pipe_client *cli,
/* [<][>][^][v][top][bottom][index][help] */
127 TALLOC_CTX *mem_ctx,
128 int argc,
129 const char **argv)
130 {
131 const char *server_name;
132 enum wkssvc_ComputerNameType name_type = NetAllComputerNames;
133 NTSTATUS status;
134 struct wkssvc_ComputerNamesCtr *ctr = NULL;
135 WERROR werr;
136
137 server_name = cli->desthost;
138
139 if (argc >= 2) {
140 name_type = atoi(argv[1]);
141 }
142
143 status = rpccli_wkssvc_NetrEnumerateComputerNames(cli, mem_ctx,
144 server_name,
145 name_type, 0,
146 &ctr,
147 &werr);
148 if (!NT_STATUS_IS_OK(status)) {
149 return ntstatus_to_werror(status);
150 }
151
152 if (W_ERROR_IS_OK(werr)) {
153 int i=0;
154 for (i = 0; i < ctr->count; i++) {
155 printf("name: %d %s\n", i, ctr->computer_name->string);
156 }
157 }
158
159 return werr;
160 }
161
162 struct cmd_set wkssvc_commands[] = {
163
164 { "WKSSVC" },
165 { "wkssvc_wkstagetinfo", RPC_RTYPE_WERROR, NULL, cmd_wkssvc_wkstagetinfo, &ndr_table_wkssvc.syntax_id, NULL, "Query WKSSVC Workstation Information", "" },
166 { "wkssvc_getjoininformation", RPC_RTYPE_WERROR, NULL, cmd_wkssvc_getjoininformation, &ndr_table_wkssvc.syntax_id, NULL, "Query WKSSVC Join Information", "" },
167 { "wkssvc_messagebuffersend", RPC_RTYPE_WERROR, NULL, cmd_wkssvc_messagebuffersend, &ndr_table_wkssvc.syntax_id, NULL, "Send WKSSVC message", "" },
168 { "wkssvc_enumeratecomputernames", RPC_RTYPE_WERROR, NULL, cmd_wkssvc_enumeratecomputernames, &ndr_table_wkssvc.syntax_id, NULL, "Enumerate WKSSVC computer names", "" },
169 { NULL }
170 };