s3-rpcclient: use get_domain_handle() fn in enum domain users & groups.
[Samba.git] / source3 / rpcclient / cmd_ntsvcs.c
bloba345cdc8bf0b3d84a83bd5a4ee47745a9fa80d90
1 /*
2 Unix SMB/CIFS implementation.
3 RPC pipe client
5 Copyright (C) Günther Deschner 2008
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/>.
21 #include "includes.h"
22 #include "rpcclient.h"
24 static WERROR cmd_ntsvcs_get_version(struct rpc_pipe_client *cli,
25 TALLOC_CTX *mem_ctx,
26 int argc,
27 const char **argv)
29 NTSTATUS status;
30 WERROR werr;
31 uint16_t version;
33 status = rpccli_PNP_GetVersion(cli, mem_ctx,
34 &version, &werr);
35 if (!NT_STATUS_IS_OK(status)) {
36 return ntstatus_to_werror(status);
39 if (W_ERROR_IS_OK(werr)) {
40 printf("version: %d\n", version);
43 return werr;
46 static WERROR cmd_ntsvcs_validate_dev_inst(struct rpc_pipe_client *cli,
47 TALLOC_CTX *mem_ctx,
48 int argc,
49 const char **argv)
51 NTSTATUS status;
52 WERROR werr;
53 const char *devicepath = NULL;
54 uint32_t flags = 0;
56 if (argc < 2 || argc > 3) {
57 printf("usage: %s [devicepath] <flags>\n", argv[0]);
58 return WERR_OK;
61 devicepath = argv[1];
63 if (argc >= 3) {
64 flags = atoi(argv[2]);
67 status = rpccli_PNP_ValidateDeviceInstance(cli, mem_ctx,
68 devicepath,
69 flags,
70 &werr);
71 if (!NT_STATUS_IS_OK(status)) {
72 return ntstatus_to_werror(status);
75 return werr;
78 static WERROR cmd_ntsvcs_hw_prof_flags(struct rpc_pipe_client *cli,
79 TALLOC_CTX *mem_ctx,
80 int argc,
81 const char **argv)
83 NTSTATUS status;
84 WERROR werr;
85 const char *devicepath = NULL;
86 uint32_t profile_flags = 0;
87 uint16_t veto_type = 0;
88 const char *unk5 = NULL;
89 const char *unk5a = NULL;
91 if (argc < 2) {
92 printf("usage: %s [devicepath]\n", argv[0]);
93 return WERR_OK;
96 devicepath = argv[1];
98 status = rpccli_PNP_HwProfFlags(cli, mem_ctx,
100 devicepath,
102 &profile_flags,
103 &veto_type,
104 unk5,
105 &unk5a,
108 &werr);
109 if (!NT_STATUS_IS_OK(status)) {
110 return ntstatus_to_werror(status);
113 return werr;
116 static WERROR cmd_ntsvcs_get_hw_prof_info(struct rpc_pipe_client *cli,
117 TALLOC_CTX *mem_ctx,
118 int argc,
119 const char **argv)
121 NTSTATUS status;
122 WERROR werr;
123 uint32_t idx = 0;
124 struct PNP_HwProfInfo info;
125 uint32_t size = 0, flags = 0;
127 ZERO_STRUCT(info);
129 status = rpccli_PNP_GetHwProfInfo(cli, mem_ctx,
130 idx,
131 &info,
132 size,
133 flags,
134 &werr);
135 if (!NT_STATUS_IS_OK(status)) {
136 return ntstatus_to_werror(status);
139 return werr;
142 static WERROR cmd_ntsvcs_get_dev_reg_prop(struct rpc_pipe_client *cli,
143 TALLOC_CTX *mem_ctx,
144 int argc,
145 const char **argv)
147 NTSTATUS status;
148 WERROR werr;
149 const char *devicepath = NULL;
150 uint32_t property = DEV_REGPROP_DESC;
151 uint32_t reg_data_type = REG_NONE;
152 uint8_t *buffer;
153 uint32_t buffer_size = 0;
154 uint32_t needed = 0;
155 uint32_t flags = 0;
157 if (argc < 2) {
158 printf("usage: %s [devicepath] [buffersize]\n", argv[0]);
159 return WERR_OK;
162 devicepath = argv[1];
164 if (argc >= 3) {
165 buffer_size = atoi(argv[2]);
166 needed = buffer_size;
169 buffer = talloc_array(mem_ctx, uint8_t, buffer_size);
170 W_ERROR_HAVE_NO_MEMORY(buffer);
172 status = rpccli_PNP_GetDeviceRegProp(cli, mem_ctx,
173 devicepath,
174 property,
175 &reg_data_type,
176 buffer,
177 &buffer_size,
178 &needed,
179 flags,
180 &werr);
181 if (!NT_STATUS_IS_OK(status)) {
182 return ntstatus_to_werror(status);
185 return werr;
188 static WERROR cmd_ntsvcs_get_dev_list_size(struct rpc_pipe_client *cli,
189 TALLOC_CTX *mem_ctx,
190 int argc,
191 const char **argv)
193 NTSTATUS status;
194 WERROR werr;
195 uint32_t size = 0;
196 uint32_t flags = 0;
197 const char *filter = NULL;
199 if (argc > 3) {
200 printf("usage: %s [filter] [flags]\n", argv[0]);
201 return WERR_OK;
204 if (argc >= 2) {
205 filter = argv[1];
208 if (argc >= 3) {
209 flags = atoi(argv[2]);
212 status = rpccli_PNP_GetDeviceListSize(cli, mem_ctx,
213 filter,
214 &size,
215 flags,
216 &werr);
217 if (!NT_STATUS_IS_OK(status)) {
218 return ntstatus_to_werror(status);
221 printf("size: %d\n", size);
223 return werr;
226 static WERROR cmd_ntsvcs_get_dev_list(struct rpc_pipe_client *cli,
227 TALLOC_CTX *mem_ctx,
228 int argc,
229 const char **argv)
231 NTSTATUS status;
232 WERROR werr;
233 const char *filter = NULL;
234 uint16_t *buffer = NULL;
235 uint32_t length = 0;
236 uint32_t flags = 0;
238 if (argc > 4) {
239 printf("usage: %s [filter] [length] [flags]\n", argv[0]);
240 return WERR_OK;
243 if (argc >= 2) {
244 filter = argv[1];
247 if (argc >= 3) {
248 length = atoi(argv[2]);
251 if (argc >= 4) {
252 flags = atoi(argv[3]);
255 buffer = talloc(mem_ctx, uint16_t);
256 if (!buffer) {
257 return WERR_NOMEM;
260 status = rpccli_PNP_GetDeviceList(cli, mem_ctx,
261 filter,
262 buffer,
263 &length,
264 flags,
265 &werr);
266 if (!NT_STATUS_IS_OK(status)) {
267 return ntstatus_to_werror(status);
270 printf("devlist needs size: %d\n", length);
272 return werr;
275 struct cmd_set ntsvcs_commands[] = {
277 { "NTSVCS" },
278 { "ntsvcs_getversion", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_version, &ndr_table_ntsvcs.syntax_id, NULL, "Query NTSVCS version", "" },
279 { "ntsvcs_validatedevinst", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_validate_dev_inst, &ndr_table_ntsvcs.syntax_id, NULL, "Query NTSVCS device instance", "" },
280 { "ntsvcs_hwprofflags", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_hw_prof_flags, &ndr_table_ntsvcs.syntax_id, NULL, "Query NTSVCS HW prof flags", "" },
281 { "ntsvcs_hwprofinfo", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_hw_prof_info, &ndr_table_ntsvcs.syntax_id, NULL, "Query NTSVCS HW prof info", "" },
282 { "ntsvcs_getdevregprop", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_dev_reg_prop, &ndr_table_ntsvcs.syntax_id, NULL, "Query NTSVCS device registry property", "" },
283 { "ntsvcs_getdevlistsize", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_dev_list_size, &ndr_table_ntsvcs.syntax_id, NULL, "Query NTSVCS device list size", "" },
284 { "ntsvcs_getdevlist", RPC_RTYPE_WERROR, NULL, cmd_ntsvcs_get_dev_list, &ndr_table_ntsvcs.syntax_id, NULL, "Query NTSVCS device list", "" },
285 { NULL }