1 | /*
|
---|
2 | Unix SMB/CIFS implementation.
|
---|
3 | RPC pipe client
|
---|
4 |
|
---|
5 | Copyright (C) Guenther Deschner 2008
|
---|
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 cracknames(struct rpc_pipe_client *cli,
|
---|
25 | TALLOC_CTX *mem_ctx,
|
---|
26 | struct policy_handle *bind_handle,
|
---|
27 | enum drsuapi_DsNameFormat format_offered,
|
---|
28 | enum drsuapi_DsNameFormat format_desired,
|
---|
29 | int argc,
|
---|
30 | const char **argv,
|
---|
31 | union drsuapi_DsNameCtr *ctr)
|
---|
32 | {
|
---|
33 | NTSTATUS status;
|
---|
34 | WERROR werr;
|
---|
35 | int i;
|
---|
36 | int32_t level = 1;
|
---|
37 | union drsuapi_DsNameRequest req;
|
---|
38 | int32_t level_out;
|
---|
39 | struct drsuapi_DsNameString *names;
|
---|
40 |
|
---|
41 | names = TALLOC_ZERO_ARRAY(mem_ctx, struct drsuapi_DsNameString, argc);
|
---|
42 | W_ERROR_HAVE_NO_MEMORY(names);
|
---|
43 |
|
---|
44 | for (i=0; i<argc; i++) {
|
---|
45 | names[i].str = argv[i];
|
---|
46 | }
|
---|
47 |
|
---|
48 | req.req1.codepage = 1252; /* german */
|
---|
49 | req.req1.language = 0x00000407; /* german */
|
---|
50 | req.req1.count = argc;
|
---|
51 | req.req1.names = names;
|
---|
52 | req.req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS;
|
---|
53 | req.req1.format_offered = format_offered;
|
---|
54 | req.req1.format_desired = format_desired;
|
---|
55 |
|
---|
56 | status = rpccli_drsuapi_DsCrackNames(cli, mem_ctx,
|
---|
57 | bind_handle,
|
---|
58 | level,
|
---|
59 | &req,
|
---|
60 | &level_out,
|
---|
61 | ctr,
|
---|
62 | &werr);
|
---|
63 | if (!NT_STATUS_IS_OK(status)) {
|
---|
64 | return ntstatus_to_werror(status);
|
---|
65 | }
|
---|
66 |
|
---|
67 | if (!W_ERROR_IS_OK(werr)) {
|
---|
68 | return werr;
|
---|
69 | }
|
---|
70 |
|
---|
71 | return WERR_OK;
|
---|
72 | }
|
---|
73 |
|
---|
74 | static WERROR cmd_drsuapi_cracknames(struct rpc_pipe_client *cli,
|
---|
75 | TALLOC_CTX *mem_ctx, int argc,
|
---|
76 | const char **argv)
|
---|
77 | {
|
---|
78 | NTSTATUS status;
|
---|
79 | WERROR werr;
|
---|
80 | int i;
|
---|
81 |
|
---|
82 | struct GUID bind_guid;
|
---|
83 | struct policy_handle bind_handle;
|
---|
84 |
|
---|
85 | union drsuapi_DsNameCtr ctr;
|
---|
86 |
|
---|
87 | if (argc < 2) {
|
---|
88 | printf("usage: %s name\n", argv[0]);
|
---|
89 | return WERR_OK;
|
---|
90 | }
|
---|
91 |
|
---|
92 | GUID_from_string(DRSUAPI_DS_BIND_GUID, &bind_guid);
|
---|
93 |
|
---|
94 | status = rpccli_drsuapi_DsBind(cli, mem_ctx,
|
---|
95 | &bind_guid,
|
---|
96 | NULL,
|
---|
97 | &bind_handle,
|
---|
98 | &werr);
|
---|
99 |
|
---|
100 | if (!NT_STATUS_IS_OK(status)) {
|
---|
101 | return ntstatus_to_werror(status);
|
---|
102 | }
|
---|
103 |
|
---|
104 | werr = cracknames(cli, mem_ctx,
|
---|
105 | &bind_handle,
|
---|
106 | DRSUAPI_DS_NAME_FORMAT_UKNOWN,
|
---|
107 | DRSUAPI_DS_NAME_FORMAT_FQDN_1779,
|
---|
108 | 1,
|
---|
109 | argv+1,
|
---|
110 | &ctr);
|
---|
111 |
|
---|
112 | if (!W_ERROR_IS_OK(werr)) {
|
---|
113 | goto out;
|
---|
114 | }
|
---|
115 |
|
---|
116 | for (i=0; i < ctr.ctr1->count; i++) {
|
---|
117 | printf("status: %d\n",
|
---|
118 | ctr.ctr1->array[i].status);
|
---|
119 | printf("dns_domain_name: %s\n",
|
---|
120 | ctr.ctr1->array[i].dns_domain_name);
|
---|
121 | printf("result_name: %s\n",
|
---|
122 | ctr.ctr1->array[i].result_name);
|
---|
123 | }
|
---|
124 |
|
---|
125 | out:
|
---|
126 | if (is_valid_policy_hnd(&bind_handle)) {
|
---|
127 | rpccli_drsuapi_DsUnbind(cli, mem_ctx, &bind_handle, &werr);
|
---|
128 | }
|
---|
129 |
|
---|
130 | return werr;
|
---|
131 | }
|
---|
132 |
|
---|
133 | static void display_domain_controller_info_01(struct drsuapi_DsGetDCConnection01 *r)
|
---|
134 | {
|
---|
135 | printf("client_ip_address:\t%s\n", r->client_ip_address);
|
---|
136 | printf("unknown2:\t%d\n", r->unknown2);
|
---|
137 | printf("connection_time:\t%d\n", r->connection_time);
|
---|
138 | printf("unknown4:\t%d\n", r->unknown4);
|
---|
139 | printf("unknown5:\t%d\n", r->unknown5);
|
---|
140 | printf("unknown6:\t%d\n", r->unknown6);
|
---|
141 | printf("client_account:\t%s\n", r->client_account);
|
---|
142 | }
|
---|
143 |
|
---|
144 | static void display_domain_controller_info_1(struct drsuapi_DsGetDCInfo1 *r)
|
---|
145 | {
|
---|
146 | printf("netbios_name:\t%s\n", r->netbios_name);
|
---|
147 | printf("dns_name:\t%s\n", r->dns_name);
|
---|
148 | printf("site_name:\t%s\n", r->site_name);
|
---|
149 | printf("computer_dn:\t%s\n", r->computer_dn);
|
---|
150 | printf("server_dn:\t%s\n", r->server_dn);
|
---|
151 | printf("is_pdc:\t\t%s\n", r->is_pdc ? "true" : "false");
|
---|
152 | printf("is_enabled:\t%s\n", r->is_enabled ? "true" : "false");
|
---|
153 | }
|
---|
154 |
|
---|
155 | static void display_domain_controller_info_2(struct drsuapi_DsGetDCInfo2 *r)
|
---|
156 | {
|
---|
157 | printf("netbios_name:\t%s\n", r->netbios_name);
|
---|
158 | printf("dns_name:\t%s\n", r->dns_name);
|
---|
159 | printf("site_name:\t%s\n", r->site_name);
|
---|
160 | printf("site_dn:\t%s\n", r->site_dn);
|
---|
161 | printf("computer_dn:\t%s\n", r->computer_dn);
|
---|
162 | printf("server_dn:\t%s\n", r->server_dn);
|
---|
163 | printf("ntds_dn:\t%s\n", r->ntds_dn);
|
---|
164 | printf("is_pdc:\t\t%s\n", r->is_pdc ? "true" : "false");
|
---|
165 | printf("is_enabled:\t%s\n", r->is_enabled ? "true" : "false");
|
---|
166 | printf("is_gc:\t\t%s\n", r->is_gc ? "true" : "false");
|
---|
167 | printf("site_guid:\t%s\n", GUID_string(talloc_tos(), &r->site_guid));
|
---|
168 | printf("computer_guid:\t%s\n", GUID_string(talloc_tos(), &r->computer_guid));
|
---|
169 | printf("server_guid:\t%s\n", GUID_string(talloc_tos(), &r->server_guid));
|
---|
170 | printf("ntds_guid:\t%s\n", GUID_string(talloc_tos(), &r->ntds_guid));
|
---|
171 | }
|
---|
172 |
|
---|
173 | static void display_domain_controller_info_3(struct drsuapi_DsGetDCInfo3 *r)
|
---|
174 | {
|
---|
175 | printf("netbios_name:\t%s\n", r->netbios_name);
|
---|
176 | printf("dns_name:\t%s\n", r->dns_name);
|
---|
177 | printf("site_name:\t%s\n", r->site_name);
|
---|
178 | printf("site_dn:\t%s\n", r->site_dn);
|
---|
179 | printf("computer_dn:\t%s\n", r->computer_dn);
|
---|
180 | printf("server_dn:\t%s\n", r->server_dn);
|
---|
181 | printf("ntds_dn:\t%s\n", r->ntds_dn);
|
---|
182 | printf("is_pdc:\t\t%s\n", r->is_pdc ? "true" : "false");
|
---|
183 | printf("is_enabled:\t%s\n", r->is_enabled ? "true" : "false");
|
---|
184 | printf("is_gc:\t\t%s\n", r->is_gc ? "true" : "false");
|
---|
185 | printf("is_rodc:\t%s\n", r->is_rodc ? "true" : "false");
|
---|
186 | printf("site_guid:\t%s\n", GUID_string(talloc_tos(), &r->site_guid));
|
---|
187 | printf("computer_guid:\t%s\n", GUID_string(talloc_tos(), &r->computer_guid));
|
---|
188 | printf("server_guid:\t%s\n", GUID_string(talloc_tos(), &r->server_guid));
|
---|
189 | printf("ntds_guid:\t%s\n", GUID_string(talloc_tos(), &r->ntds_guid));
|
---|
190 | }
|
---|
191 |
|
---|
192 | static void display_domain_controller_info(int32_t level,
|
---|
193 | union drsuapi_DsGetDCInfoCtr *ctr)
|
---|
194 | {
|
---|
195 | int i;
|
---|
196 |
|
---|
197 | switch (level) {
|
---|
198 | case DRSUAPI_DC_CONNECTION_CTR_01:
|
---|
199 | for (i=0; i<ctr->ctr01.count; i++) {
|
---|
200 | printf("----------\n");
|
---|
201 | display_domain_controller_info_01(&ctr->ctr01.array[i]);
|
---|
202 | }
|
---|
203 | break;
|
---|
204 | case DRSUAPI_DC_INFO_CTR_1:
|
---|
205 | for (i=0; i<ctr->ctr1.count; i++) {
|
---|
206 | printf("----------\n");
|
---|
207 | display_domain_controller_info_1(&ctr->ctr1.array[i]);
|
---|
208 | }
|
---|
209 | break;
|
---|
210 | case DRSUAPI_DC_INFO_CTR_2:
|
---|
211 | for (i=0; i<ctr->ctr2.count; i++) {
|
---|
212 | printf("----------\n");
|
---|
213 | display_domain_controller_info_2(&ctr->ctr2.array[i]);
|
---|
214 | }
|
---|
215 | break;
|
---|
216 | case DRSUAPI_DC_INFO_CTR_3:
|
---|
217 | for (i=0; i<ctr->ctr3.count; i++) {
|
---|
218 | printf("----------\n");
|
---|
219 | display_domain_controller_info_3(&ctr->ctr3.array[i]);
|
---|
220 | }
|
---|
221 | break;
|
---|
222 | default:
|
---|
223 | break;
|
---|
224 | }
|
---|
225 | }
|
---|
226 |
|
---|
227 | static WERROR cmd_drsuapi_getdcinfo(struct rpc_pipe_client *cli,
|
---|
228 | TALLOC_CTX *mem_ctx, int argc,
|
---|
229 | const char **argv)
|
---|
230 | {
|
---|
231 | NTSTATUS status;
|
---|
232 | WERROR werr;
|
---|
233 |
|
---|
234 | struct GUID bind_guid;
|
---|
235 | struct policy_handle bind_handle;
|
---|
236 |
|
---|
237 | const char *domain = NULL;
|
---|
238 | int32_t level = 1;
|
---|
239 | int32_t level_out;
|
---|
240 | union drsuapi_DsGetDCInfoRequest req;
|
---|
241 | union drsuapi_DsGetDCInfoCtr ctr;
|
---|
242 |
|
---|
243 | if (argc < 2) {
|
---|
244 | printf("usage: %s domain [level]\n", argv[0]);
|
---|
245 | return WERR_OK;
|
---|
246 | }
|
---|
247 |
|
---|
248 | domain = argv[1];
|
---|
249 | if (argc >= 3) {
|
---|
250 | level = atoi(argv[2]);
|
---|
251 | }
|
---|
252 |
|
---|
253 | GUID_from_string(DRSUAPI_DS_BIND_GUID, &bind_guid);
|
---|
254 |
|
---|
255 | status = rpccli_drsuapi_DsBind(cli, mem_ctx,
|
---|
256 | &bind_guid,
|
---|
257 | NULL,
|
---|
258 | &bind_handle,
|
---|
259 | &werr);
|
---|
260 |
|
---|
261 | if (!NT_STATUS_IS_OK(status)) {
|
---|
262 | return ntstatus_to_werror(status);
|
---|
263 | }
|
---|
264 |
|
---|
265 | req.req1.domain_name = domain;
|
---|
266 | req.req1.level = level;
|
---|
267 |
|
---|
268 | status = rpccli_drsuapi_DsGetDomainControllerInfo(cli, mem_ctx,
|
---|
269 | &bind_handle,
|
---|
270 | 1,
|
---|
271 | &req,
|
---|
272 | &level_out,
|
---|
273 | &ctr,
|
---|
274 | &werr);
|
---|
275 | if (!NT_STATUS_IS_OK(status)) {
|
---|
276 | werr = ntstatus_to_werror(status);
|
---|
277 | goto out;
|
---|
278 | }
|
---|
279 |
|
---|
280 | if (!W_ERROR_IS_OK(werr)) {
|
---|
281 | goto out;
|
---|
282 | }
|
---|
283 |
|
---|
284 | display_domain_controller_info(level_out, &ctr);
|
---|
285 | out:
|
---|
286 | if (is_valid_policy_hnd(&bind_handle)) {
|
---|
287 | rpccli_drsuapi_DsUnbind(cli, mem_ctx, &bind_handle, &werr);
|
---|
288 | }
|
---|
289 |
|
---|
290 | return werr;
|
---|
291 | }
|
---|
292 |
|
---|
293 | static WERROR cmd_drsuapi_getncchanges(struct rpc_pipe_client *cli,
|
---|
294 | TALLOC_CTX *mem_ctx, int argc,
|
---|
295 | const char **argv)
|
---|
296 | {
|
---|
297 | NTSTATUS status;
|
---|
298 | WERROR werr;
|
---|
299 |
|
---|
300 | struct policy_handle bind_handle;
|
---|
301 |
|
---|
302 | struct GUID bind_guid;
|
---|
303 | struct drsuapi_DsBindInfoCtr bind_info;
|
---|
304 | struct drsuapi_DsBindInfo28 info28;
|
---|
305 |
|
---|
306 | const char *nc_dn = NULL;
|
---|
307 |
|
---|
308 | DATA_BLOB session_key;
|
---|
309 |
|
---|
310 | int32_t level = 8;
|
---|
311 | bool single = false;
|
---|
312 | int32_t level_out = 0;
|
---|
313 | union drsuapi_DsGetNCChangesRequest req;
|
---|
314 | union drsuapi_DsGetNCChangesCtr ctr;
|
---|
315 | struct drsuapi_DsReplicaObjectIdentifier nc;
|
---|
316 | struct dom_sid null_sid;
|
---|
317 |
|
---|
318 | struct drsuapi_DsGetNCChangesCtr1 *ctr1 = NULL;
|
---|
319 | struct drsuapi_DsGetNCChangesCtr6 *ctr6 = NULL;
|
---|
320 | int32_t out_level = 0;
|
---|
321 | int y;
|
---|
322 |
|
---|
323 | uint32_t supported_extensions = 0;
|
---|
324 | uint32_t replica_flags = DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE |
|
---|
325 | DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP |
|
---|
326 | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS |
|
---|
327 | DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS |
|
---|
328 | DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED;
|
---|
329 |
|
---|
330 | if (argc > 3) {
|
---|
331 | printf("usage: %s [naming_context_or_object_dn [single]]\n", argv[0]);
|
---|
332 | return WERR_OK;
|
---|
333 | }
|
---|
334 |
|
---|
335 | if (argc >= 2) {
|
---|
336 | nc_dn = argv[1];
|
---|
337 | }
|
---|
338 |
|
---|
339 | if (argc == 3) {
|
---|
340 | if (strequal(argv[2], "single")) {
|
---|
341 | single = true;
|
---|
342 | } else {
|
---|
343 | printf("warning: ignoring unknown argument '%s'\n",
|
---|
344 | argv[2]);
|
---|
345 | }
|
---|
346 | }
|
---|
347 |
|
---|
348 | ZERO_STRUCT(info28);
|
---|
349 |
|
---|
350 | ZERO_STRUCT(null_sid);
|
---|
351 | ZERO_STRUCT(req);
|
---|
352 |
|
---|
353 | GUID_from_string(DRSUAPI_DS_BIND_GUID, &bind_guid);
|
---|
354 |
|
---|
355 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_BASE;
|
---|
356 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ASYNC_REPLICATION;
|
---|
357 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_REMOVEAPI;
|
---|
358 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_MOVEREQ_V2;
|
---|
359 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHG_COMPRESS;
|
---|
360 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V1;
|
---|
361 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_RESTORE_USN_OPTIMIZATION;
|
---|
362 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_KCC_EXECUTE;
|
---|
363 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRY_V2;
|
---|
364 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_LINKED_VALUE_REPLICATION;
|
---|
365 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V2;
|
---|
366 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_INSTANCE_TYPE_NOT_REQ_ON_MOD;
|
---|
367 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_CRYPTO_BIND;
|
---|
368 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GET_REPL_INFO;
|
---|
369 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_STRONG_ENCRYPTION;
|
---|
370 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_DCINFO_V01;
|
---|
371 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_TRANSITIVE_MEMBERSHIP;
|
---|
372 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ADD_SID_HISTORY;
|
---|
373 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_POST_BETA3;
|
---|
374 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GET_MEMBERSHIPS2;
|
---|
375 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V6;
|
---|
376 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_NONDOMAIN_NCS;
|
---|
377 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8;
|
---|
378 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V5;
|
---|
379 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V6;
|
---|
380 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3;
|
---|
381 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7;
|
---|
382 | info28.supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT;
|
---|
383 | info28.site_guid = GUID_zero();
|
---|
384 | info28.pid = 0;
|
---|
385 | info28.repl_epoch = 0;
|
---|
386 |
|
---|
387 | bind_info.length = 28;
|
---|
388 | bind_info.info.info28 = info28;
|
---|
389 |
|
---|
390 | status = rpccli_drsuapi_DsBind(cli, mem_ctx,
|
---|
391 | &bind_guid,
|
---|
392 | &bind_info,
|
---|
393 | &bind_handle,
|
---|
394 | &werr);
|
---|
395 |
|
---|
396 | if (!NT_STATUS_IS_OK(status)) {
|
---|
397 | return ntstatus_to_werror(status);
|
---|
398 | }
|
---|
399 |
|
---|
400 | if (!W_ERROR_IS_OK(werr)) {
|
---|
401 | return werr;
|
---|
402 | }
|
---|
403 |
|
---|
404 | if (bind_info.length == 24) {
|
---|
405 | supported_extensions = bind_info.info.info24.supported_extensions;
|
---|
406 | } else if (bind_info.length == 28) {
|
---|
407 | supported_extensions = bind_info.info.info28.supported_extensions;
|
---|
408 | } else if (bind_info.length == 48) {
|
---|
409 | supported_extensions = bind_info.info.info48.supported_extensions;
|
---|
410 | }
|
---|
411 |
|
---|
412 | if (!nc_dn) {
|
---|
413 |
|
---|
414 | union drsuapi_DsNameCtr crack_ctr;
|
---|
415 | const char *name;
|
---|
416 |
|
---|
417 | name = talloc_asprintf(mem_ctx, "%s\\", lp_workgroup());
|
---|
418 | W_ERROR_HAVE_NO_MEMORY(name);
|
---|
419 |
|
---|
420 | werr = cracknames(cli, mem_ctx,
|
---|
421 | &bind_handle,
|
---|
422 | DRSUAPI_DS_NAME_FORMAT_UKNOWN,
|
---|
423 | DRSUAPI_DS_NAME_FORMAT_FQDN_1779,
|
---|
424 | 1,
|
---|
425 | &name,
|
---|
426 | &crack_ctr);
|
---|
427 | if (!W_ERROR_IS_OK(werr)) {
|
---|
428 | return werr;
|
---|
429 | }
|
---|
430 |
|
---|
431 | if (crack_ctr.ctr1->count != 1) {
|
---|
432 | return WERR_NO_SUCH_DOMAIN;
|
---|
433 | }
|
---|
434 |
|
---|
435 | if (crack_ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
|
---|
436 | return WERR_NO_SUCH_DOMAIN;
|
---|
437 | }
|
---|
438 |
|
---|
439 | nc_dn = talloc_strdup(mem_ctx, crack_ctr.ctr1->array[0].result_name);
|
---|
440 | W_ERROR_HAVE_NO_MEMORY(nc_dn);
|
---|
441 |
|
---|
442 | printf("using: %s\n", nc_dn);
|
---|
443 | }
|
---|
444 |
|
---|
445 | nc.dn = nc_dn;
|
---|
446 | nc.guid = GUID_zero();
|
---|
447 | nc.sid = null_sid;
|
---|
448 |
|
---|
449 | if (supported_extensions & DRSUAPI_SUPPORTED_EXTENSION_GETCHGREQ_V8) {
|
---|
450 | level = 8;
|
---|
451 | req.req8.naming_context = &nc;
|
---|
452 | req.req8.replica_flags = replica_flags;
|
---|
453 | req.req8.max_object_count = 402;
|
---|
454 | req.req8.max_ndr_size = 402116;
|
---|
455 | if (single) {
|
---|
456 | req.req8.extended_op = DRSUAPI_EXOP_REPL_OBJ;
|
---|
457 | }
|
---|
458 | } else {
|
---|
459 | level = 5;
|
---|
460 | req.req5.naming_context = &nc;
|
---|
461 | req.req5.replica_flags = replica_flags;
|
---|
462 | req.req5.max_object_count = 402;
|
---|
463 | req.req5.max_ndr_size = 402116;
|
---|
464 | if (single) {
|
---|
465 | req.req5.extended_op = DRSUAPI_EXOP_REPL_OBJ;
|
---|
466 | }
|
---|
467 | }
|
---|
468 |
|
---|
469 | for (y=0; ;y++) {
|
---|
470 |
|
---|
471 | if (level == 8) {
|
---|
472 | DEBUG(1,("start[%d] tmp_higest_usn: %llu , highest_usn: %llu\n",y,
|
---|
473 | (long long)req.req8.highwatermark.tmp_highest_usn,
|
---|
474 | (long long)req.req8.highwatermark.highest_usn));
|
---|
475 | }
|
---|
476 |
|
---|
477 | status = rpccli_drsuapi_DsGetNCChanges(cli, mem_ctx,
|
---|
478 | &bind_handle,
|
---|
479 | level,
|
---|
480 | &req,
|
---|
481 | &level_out,
|
---|
482 | &ctr,
|
---|
483 | &werr);
|
---|
484 | if (!NT_STATUS_IS_OK(status)) {
|
---|
485 | printf("Failed to get NC Changes: %s",
|
---|
486 | get_friendly_werror_msg(werr));
|
---|
487 | goto out;
|
---|
488 | }
|
---|
489 |
|
---|
490 | if (!W_ERROR_IS_OK(werr)) {
|
---|
491 | status = werror_to_ntstatus(werr);
|
---|
492 | goto out;
|
---|
493 | }
|
---|
494 |
|
---|
495 | if (level_out == 1) {
|
---|
496 | out_level = 1;
|
---|
497 | ctr1 = &ctr.ctr1;
|
---|
498 | } else if (level_out == 2) {
|
---|
499 | out_level = 1;
|
---|
500 | ctr1 = ctr.ctr2.ctr.mszip1.ctr1;
|
---|
501 | }
|
---|
502 |
|
---|
503 | status = cli_get_session_key(mem_ctx, cli, &session_key);
|
---|
504 | if (!NT_STATUS_IS_OK(status)) {
|
---|
505 | printf("Failed to get Session Key: %s",
|
---|
506 | nt_errstr(status));
|
---|
507 | return ntstatus_to_werror(status);
|
---|
508 | }
|
---|
509 |
|
---|
510 | if (out_level == 1) {
|
---|
511 | DEBUG(1,("end[%d] tmp_highest_usn: %llu , highest_usn: %llu\n",y,
|
---|
512 | (long long)ctr1->new_highwatermark.tmp_highest_usn,
|
---|
513 | (long long)ctr1->new_highwatermark.highest_usn));
|
---|
514 | #if 0
|
---|
515 | libnet_dssync_decrypt_attributes(mem_ctx,
|
---|
516 | &session_key,
|
---|
517 | ctr1->first_object);
|
---|
518 | #endif
|
---|
519 | if (ctr1->more_data) {
|
---|
520 | req.req5.highwatermark = ctr1->new_highwatermark;
|
---|
521 | continue;
|
---|
522 | }
|
---|
523 | }
|
---|
524 |
|
---|
525 | if (level_out == 6) {
|
---|
526 | out_level = 6;
|
---|
527 | ctr6 = &ctr.ctr6;
|
---|
528 | } else if (level_out == 7
|
---|
529 | && ctr.ctr7.level == 6
|
---|
530 | && ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP) {
|
---|
531 | out_level = 6;
|
---|
532 | ctr6 = ctr.ctr7.ctr.mszip6.ctr6;
|
---|
533 | }
|
---|
534 |
|
---|
535 | if (out_level == 6) {
|
---|
536 | DEBUG(1,("end[%d] tmp_highest_usn: %llu , highest_usn: %llu\n",y,
|
---|
537 | (long long)ctr6->new_highwatermark.tmp_highest_usn,
|
---|
538 | (long long)ctr6->new_highwatermark.highest_usn));
|
---|
539 | #if 0
|
---|
540 | libnet_dssync_decrypt_attributes(mem_ctx,
|
---|
541 | &session_key,
|
---|
542 | ctr6->first_object);
|
---|
543 | #endif
|
---|
544 | if (ctr6->more_data) {
|
---|
545 | req.req8.highwatermark = ctr6->new_highwatermark;
|
---|
546 | continue;
|
---|
547 | }
|
---|
548 | }
|
---|
549 |
|
---|
550 | break;
|
---|
551 | }
|
---|
552 |
|
---|
553 | out:
|
---|
554 | return werr;
|
---|
555 | }
|
---|
556 |
|
---|
557 | /* List of commands exported by this module */
|
---|
558 |
|
---|
559 | struct cmd_set drsuapi_commands[] = {
|
---|
560 |
|
---|
561 | { "DRSUAPI" },
|
---|
562 | { "dscracknames", RPC_RTYPE_WERROR, NULL, cmd_drsuapi_cracknames, &ndr_table_drsuapi.syntax_id, NULL, "Crack Name", "" },
|
---|
563 | { "dsgetdcinfo", RPC_RTYPE_WERROR, NULL, cmd_drsuapi_getdcinfo, &ndr_table_drsuapi.syntax_id, NULL, "Get Domain Controller Info", "" },
|
---|
564 | { "dsgetncchanges", RPC_RTYPE_WERROR, NULL, cmd_drsuapi_getncchanges, &ndr_table_drsuapi.syntax_id, NULL, "Get NC Changes", "" },
|
---|
565 | { NULL }
|
---|
566 | };
|
---|