2 Unix SMB/CIFS implementation.
6 Copyright (C) Andrew Tridgell 2003
7 Copyright (C) Stefan (metze) Metzmacher 2004
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include "librpc/gen_ndr/ndr_drsuapi.h"
28 struct policy_handle bind_handle;
29 struct GUID bind_guid;
30 const char *domain_obj_dn;
31 const char *domain_guid_str;
32 const char *domain_dns_name;
33 struct GUID domain_guid;
34 struct drsuapi_DsGetDCInfo2 dcinfo;
37 static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
38 struct DsPrivate *priv)
41 struct drsuapi_DsBind r;
44 GUID_from_string(DRSUAPI_DS_BIND_GUID, &priv->bind_guid);
46 r.in.bind_guid = &priv->bind_guid;
47 r.in.bind_info = NULL;
48 r.out.bind_handle = &priv->bind_handle;
50 printf("testing DsBind\n");
52 status = dcerpc_drsuapi_DsBind(p, mem_ctx, &r);
53 if (!NT_STATUS_IS_OK(status)) {
54 const char *errstr = nt_errstr(status);
55 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
56 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
58 printf("dcerpc_drsuapi_DsBind failed - %s\n", errstr);
60 } else if (!W_ERROR_IS_OK(r.out.result)) {
61 printf("DsBind failed - %s\n", win_errstr(r.out.result));
68 static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
69 struct DsPrivate *priv, const char *dn,
70 const char *user_principal_name, const char *service_principal_name)
76 struct drsuapi_DsCrackNames r;
77 struct drsuapi_DsNameString names[1];
78 enum drsuapi_DsNameFormat formats[] = {
79 DRSUAPI_DS_NAME_FORMAT_FQDN_1779,
80 DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT,
81 DRSUAPI_DS_NAME_FORMAT_DISPLAY,
82 DRSUAPI_DS_NAME_FORMAT_GUID,
83 DRSUAPI_DS_NAME_FORMAT_CANONICAL,
84 DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL,
85 DRSUAPI_DS_NAME_FORMAT_CANONICAL_EX,
86 DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL,
87 DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY,
88 DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN
92 const char *n_matrix[ARRAY_SIZE(formats)][ARRAY_SIZE(formats)];
93 const char *n_from[ARRAY_SIZE(formats)];
96 r.in.bind_handle = &priv->bind_handle;
98 r.in.req.req1.unknown1 = 0x000004e4;
99 r.in.req.req1.unknown2 = 0x00000407;
100 r.in.req.req1.count = 1;
101 r.in.req.req1.names = names;
102 r.in.req.req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS;
106 for (i = 0; i < ARRAY_SIZE(formats); i++) {
107 r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
108 r.in.req.req1.format_desired = formats[i];
110 printf("testing DsCrackNames (matrix prep) with name '%s' from format: %d desired format:%d ",
111 names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired);
113 status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
114 if (!NT_STATUS_IS_OK(status)) {
115 const char *errstr = nt_errstr(status);
116 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
117 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
119 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
121 } else if (!W_ERROR_IS_OK(r.out.result)) {
122 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
129 switch (formats[i]) {
130 case DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL:
131 case DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL:
132 case DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY:
133 case DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN:
134 if (r.out.ctr.ctr1->array[0].status == DRSUAPI_DS_NAME_STATUS_OK) {
135 printf("Unexpected success: This name lookup should fail\n");
138 printf ("(expected) error\n");
141 if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
142 printf("Error: %d\n", r.out.ctr.ctr1->array[0].status);
147 switch (formats[i]) {
148 case DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL:
149 n_from[i] = user_principal_name;
151 case DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL:
152 n_from[i] = service_principal_name;
154 case DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY:
155 case DRSUAPI_DS_NAME_FORMAT_DNS_DOMAIN:
159 n_from[i] = r.out.ctr.ctr1->array[0].result_name;
160 printf("%s\n", n_from[i]);
164 for (i = 0; i < ARRAY_SIZE(formats); i++) {
165 for (j = 0; j < ARRAY_SIZE(formats); j++) {
166 r.in.req.req1.format_offered = formats[i];
167 r.in.req.req1.format_desired = formats[j];
169 n_matrix[i][j] = NULL;
172 names[0].str = n_from[i];
173 status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
174 if (!NT_STATUS_IS_OK(status)) {
175 const char *errstr = nt_errstr(status);
176 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
177 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
179 printf("testing DsCrackNames (matrix) with name '%s' from format: %d desired format:%d failed - %s",
180 names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired, errstr);
182 } else if (!W_ERROR_IS_OK(r.out.result)) {
183 printf("testing DsCrackNames (matrix) with name '%s' from format: %d desired format:%d failed - %s",
184 names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired,
185 win_errstr(r.out.result));
192 if (r.out.ctr.ctr1->array[0].status == DRSUAPI_DS_NAME_STATUS_OK) {
193 n_matrix[i][j] = r.out.ctr.ctr1->array[0].result_name;
195 n_matrix[i][j] = NULL;
200 for (i = 0; i < ARRAY_SIZE(formats); i++) {
201 for (j = 0; j < ARRAY_SIZE(formats); j++) {
202 if (n_matrix[i][j] == n_from[j]) {
204 /* We don't have a from name for these yet (and we can't map to them to find it out) */
205 } else if (n_matrix[i][j] == NULL && n_from[i] == NULL) {
207 /* we can't map to these two */
208 } else if (n_matrix[i][j] == NULL && formats[j] == DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL) {
209 } else if (n_matrix[i][j] == NULL && formats[j] == DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL) {
210 } else if (n_matrix[i][j] == NULL && n_from[j] != NULL) {
211 printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]);
213 } else if (n_matrix[i][j] != NULL && n_from[j] == NULL) {
214 printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]);
216 } else if (strcmp(n_matrix[i][j], n_from[j]) != 0) {
217 printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]);
225 static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
226 struct DsPrivate *priv)
229 struct drsuapi_DsCrackNames r;
230 struct drsuapi_DsNameString names[1];
232 const char *dns_domain;
233 const char *nt4_domain;
234 const char *FQDN_1779_name;
235 const char *user_principal_name;
236 const char *service_principal_name;
239 r.in.bind_handle = &priv->bind_handle;
241 r.in.req.req1.unknown1 = 0x000004e4;
242 r.in.req.req1.unknown2 = 0x00000407;
243 r.in.req.req1.count = 1;
244 r.in.req.req1.names = names;
245 r.in.req.req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS;
247 r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_CANONICAL;
248 r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT;
249 names[0].str = talloc_asprintf(mem_ctx, "%s/", lp_realm());
251 printf("testing DsCrackNames with name '%s' desired format:%d\n",
252 names[0].str, r.in.req.req1.format_desired);
254 status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
255 if (!NT_STATUS_IS_OK(status)) {
256 const char *errstr = nt_errstr(status);
257 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
258 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
260 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
262 } else if (!W_ERROR_IS_OK(r.out.result)) {
263 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
265 } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
266 printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
274 dns_domain = r.out.ctr.ctr1->array[0].dns_domain_name;
275 nt4_domain = r.out.ctr.ctr1->array[0].result_name;
277 r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_GUID;
279 printf("testing DsCrackNames with name '%s' desired format:%d\n",
280 names[0].str, r.in.req.req1.format_desired);
282 status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
283 if (!NT_STATUS_IS_OK(status)) {
284 const char *errstr = nt_errstr(status);
285 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
286 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
288 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
290 } else if (!W_ERROR_IS_OK(r.out.result)) {
291 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
293 } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
294 printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
302 priv->domain_dns_name = r.out.ctr.ctr1->array[0].dns_domain_name;
303 priv->domain_guid_str = r.out.ctr.ctr1->array[0].result_name;
304 GUID_from_string(priv->domain_guid_str, &priv->domain_guid);
307 r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_GUID;
308 r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT;
309 names[0].str = priv->domain_guid_str;
311 printf("testing DsCrackNames with name '%s' desired format:%d\n",
312 names[0].str, r.in.req.req1.format_desired);
314 status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
315 if (!NT_STATUS_IS_OK(status)) {
316 const char *errstr = nt_errstr(status);
317 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
318 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
320 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
322 } else if (!W_ERROR_IS_OK(r.out.result)) {
323 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
325 } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
326 printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
334 r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT;
335 r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
336 names[0].str = nt4_domain;
338 printf("testing DsCrackNames with name '%s' desired format:%d\n",
339 names[0].str, r.in.req.req1.format_desired);
341 status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
342 if (!NT_STATUS_IS_OK(status)) {
343 const char *errstr = nt_errstr(status);
344 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
345 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
347 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
349 } else if (!W_ERROR_IS_OK(r.out.result)) {
350 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
352 } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
353 printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
361 priv->domain_obj_dn = r.out.ctr.ctr1->array[0].result_name;
363 r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT;
364 r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
365 names[0].str = talloc_asprintf(mem_ctx, "%s%s$", nt4_domain, priv->dcinfo.netbios_name);
367 printf("testing DsCrackNames with name '%s' desired format:%d\n",
368 names[0].str, r.in.req.req1.format_desired);
370 status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
371 if (!NT_STATUS_IS_OK(status)) {
372 const char *errstr = nt_errstr(status);
373 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
374 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
376 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
378 } else if (!W_ERROR_IS_OK(r.out.result)) {
379 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
381 } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
382 printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
390 FQDN_1779_name = r.out.ctr.ctr1->array[0].result_name;
392 r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL;
393 r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
394 names[0].str = talloc_asprintf(mem_ctx, "%s$@%s", priv->dcinfo.netbios_name, dns_domain);
395 user_principal_name = names[0].str;
397 printf("testing DsCrackNames with name '%s' desired format:%d\n",
398 names[0].str, r.in.req.req1.format_desired);
400 status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
401 if (!NT_STATUS_IS_OK(status)) {
402 const char *errstr = nt_errstr(status);
403 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
404 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
406 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
408 } else if (!W_ERROR_IS_OK(r.out.result)) {
409 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
411 } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
412 printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
420 if (strcmp(r.out.ctr.ctr1->array[0].result_name, FQDN_1779_name) != 0) {
421 printf("DsCrackNames failed - %s != %s\n", r.out.ctr.ctr1->array[0].result_name, FQDN_1779_name);
425 r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL;
426 r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
427 names[0].str = talloc_asprintf(mem_ctx, "HOST/%s", priv->dcinfo.netbios_name);
428 service_principal_name = names[0].str;
430 printf("testing DsCrackNames with name '%s' desired format:%d\n",
431 names[0].str, r.in.req.req1.format_desired);
433 status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
434 if (!NT_STATUS_IS_OK(status)) {
435 const char *errstr = nt_errstr(status);
436 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
437 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
439 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
441 } else if (!W_ERROR_IS_OK(r.out.result)) {
442 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
444 } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
445 printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
453 if (strcmp(r.out.ctr.ctr1->array[0].result_name, FQDN_1779_name) != 0) {
454 printf("DsCrackNames failed - %s != %s\n", r.out.ctr.ctr1->array[0].result_name, FQDN_1779_name);
458 r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL;
459 r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
460 names[0].str = talloc_asprintf(mem_ctx, "cifs/%s.%s", priv->dcinfo.netbios_name, dns_domain);
462 printf("testing DsCrackNames with name '%s' desired format:%d\n",
463 names[0].str, r.in.req.req1.format_desired);
465 status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
466 if (!NT_STATUS_IS_OK(status)) {
467 const char *errstr = nt_errstr(status);
468 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
469 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
471 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
473 } else if (!W_ERROR_IS_OK(r.out.result)) {
474 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
476 } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
477 printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
485 if (strcmp(r.out.ctr.ctr1->array[0].result_name, FQDN_1779_name) != 0) {
486 printf("DsCrackNames failed - %s != %s\n", r.out.ctr.ctr1->array[0].result_name, FQDN_1779_name);
490 r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
491 r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_CANONICAL;
492 names[0].str = FQDN_1779_name;
494 printf("testing DsCrackNames with name '%s' desired format:%d\n",
495 names[0].str, r.in.req.req1.format_desired);
497 status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
498 if (!NT_STATUS_IS_OK(status)) {
499 const char *errstr = nt_errstr(status);
500 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
501 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
503 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
505 } else if (!W_ERROR_IS_OK(r.out.result)) {
506 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
514 r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_DISPLAY;
516 printf("testing DsCrackNames with name '%s' desired format:%d\n",
517 names[0].str, r.in.req.req1.format_desired);
519 status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
520 if (!NT_STATUS_IS_OK(status)) {
521 const char *errstr = nt_errstr(status);
522 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
523 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
525 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
527 } else if (!W_ERROR_IS_OK(r.out.result)) {
528 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
530 } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
531 printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
539 r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_GUID;
541 printf("testing DsCrackNames with name '%s' desired format:%d\n",
542 names[0].str, r.in.req.req1.format_desired);
544 status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
545 if (!NT_STATUS_IS_OK(status)) {
546 const char *errstr = nt_errstr(status);
547 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
548 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
550 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
552 } else if (!W_ERROR_IS_OK(r.out.result)) {
553 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
555 } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
556 printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
564 r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_GUID;
565 r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
566 names[0].str = GUID_string2(mem_ctx, &priv->dcinfo.site_guid);
568 printf("testing DsCrackNames with Site GUID '%s' desired format:%d\n",
569 names[0].str, r.in.req.req1.format_desired);
571 status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
572 if (!NT_STATUS_IS_OK(status)) {
573 const char *errstr = nt_errstr(status);
574 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
575 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
577 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
579 } else if (!W_ERROR_IS_OK(r.out.result)) {
580 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
582 } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
583 printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
591 r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT;
592 names[0].str = GUID_string2(mem_ctx, &priv->dcinfo.computer_guid);
594 printf("testing DsCrackNames with Computer GUID '%s' desired format:%d\n",
595 names[0].str, r.in.req.req1.format_desired);
597 status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
598 if (!NT_STATUS_IS_OK(status)) {
599 const char *errstr = nt_errstr(status);
600 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
601 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
603 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
605 } else if (!W_ERROR_IS_OK(r.out.result)) {
606 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
608 } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
609 printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
617 r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_GUID;
618 r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
619 names[0].str = GUID_string2(mem_ctx, &priv->dcinfo.server_guid);
621 printf("testing DsCrackNames with Server GUID '%s' desired format:%d\n",
622 names[0].str, r.in.req.req1.format_desired);
624 status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
625 if (!NT_STATUS_IS_OK(status)) {
626 const char *errstr = nt_errstr(status);
627 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
628 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
630 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
632 } else if (!W_ERROR_IS_OK(r.out.result)) {
633 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
635 } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
636 printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
644 r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_GUID;
645 r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
646 names[0].str = GUID_string2(mem_ctx, &priv->dcinfo.ntds_guid);
648 printf("testing DsCrackNames with NTDS GUID '%s' desired format:%d\n",
649 names[0].str, r.in.req.req1.format_desired);
651 status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
652 if (!NT_STATUS_IS_OK(status)) {
653 const char *errstr = nt_errstr(status);
654 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
655 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
657 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
659 } else if (!W_ERROR_IS_OK(r.out.result)) {
660 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
662 } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) {
663 printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status);
671 /* NEGATIVE test. This should parse, but not succeed */
672 r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_GUID;
673 r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
674 names[0].str = GUID_string2(mem_ctx, &priv->bind_guid);
676 printf("testing DsCrackNames with BIND GUID '%s' desired format:%d\n",
677 names[0].str, r.in.req.req1.format_desired);
679 status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
680 if (!NT_STATUS_IS_OK(status)) {
681 const char *errstr = nt_errstr(status);
682 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
683 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
685 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
687 } else if (!W_ERROR_IS_OK(r.out.result)) {
688 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
690 } else if (r.out.ctr.ctr1->array[0].status == DRSUAPI_DS_NAME_STATUS_OK) {
691 printf("DsCrackNames succeeded on name - %d\n", r.out.ctr.ctr1->array[0].status);
696 return test_DsCrackNamesMatrix(p, mem_ctx, priv, FQDN_1779_name, user_principal_name, service_principal_name);
702 static BOOL test_DsGetDCInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
703 struct DsPrivate *priv)
706 struct drsuapi_DsGetDomainControllerInfo r;
709 r.in.bind_handle = &priv->bind_handle;
712 r.in.req.req1.domain_name = talloc_strdup(mem_ctx, lp_realm());
713 r.in.req.req1.level = 1;
715 printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
716 r.in.req.req1.level, r.in.req.req1.domain_name);
718 status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r);
719 if (!NT_STATUS_IS_OK(status)) {
720 const char *errstr = nt_errstr(status);
721 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
722 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
724 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
725 " with dns domain failed - %s\n",
726 r.in.req.req1.level, errstr);
728 } else if (!W_ERROR_IS_OK(r.out.result)) {
729 printf("DsGetDomainControllerInfo level %d\n"
730 " with dns domain failed - %s\n",
731 r.in.req.req1.level, win_errstr(r.out.result));
735 r.in.req.req1.level = 2;
737 printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
738 r.in.req.req1.level, r.in.req.req1.domain_name);
740 status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r);
741 if (!NT_STATUS_IS_OK(status)) {
742 const char *errstr = nt_errstr(status);
743 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
744 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
746 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
747 " with dns domain failed - %s\n",
748 r.in.req.req1.level, errstr);
750 } else if (!W_ERROR_IS_OK(r.out.result)) {
751 printf("DsGetDomainControllerInfo level %d\n"
752 " with dns domain failed - %s\n",
753 r.in.req.req1.level, win_errstr(r.out.result));
756 if (r.out.ctr.ctr2.count > 0) {
757 priv->dcinfo = r.out.ctr.ctr2.array[0];
761 r.in.req.req1.level = -1;
763 printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
764 r.in.req.req1.level, r.in.req.req1.domain_name);
766 status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r);
767 if (!NT_STATUS_IS_OK(status)) {
768 const char *errstr = nt_errstr(status);
769 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
770 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
772 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
773 " with dns domain failed - %s\n",
774 r.in.req.req1.level, errstr);
776 } else if (!W_ERROR_IS_OK(r.out.result)) {
777 printf("DsGetDomainControllerInfo level %d\n"
778 " with dns domain failed - %s\n",
779 r.in.req.req1.level, win_errstr(r.out.result));
783 r.in.req.req1.domain_name = talloc_strdup(mem_ctx, lp_workgroup());
784 r.in.req.req1.level = 2;
786 printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
787 r.in.req.req1.level, r.in.req.req1.domain_name);
789 status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r);
790 if (!NT_STATUS_IS_OK(status)) {
791 const char *errstr = nt_errstr(status);
792 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
793 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
795 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
796 " with netbios domain failed - %s\n",
797 r.in.req.req1.level, errstr);
799 } else if (!W_ERROR_IS_OK(r.out.result)) {
800 printf("DsGetDomainControllerInfo level %d\n"
801 " with netbios domain failed - %s\n",
802 r.in.req.req1.level, win_errstr(r.out.result));
806 r.in.req.req1.domain_name = "__UNKNOWN_DOMAIN__";
807 r.in.req.req1.level = 2;
809 printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
810 r.in.req.req1.level, r.in.req.req1.domain_name);
812 status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r);
813 if (!NT_STATUS_IS_OK(status)) {
814 const char *errstr = nt_errstr(status);
815 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
816 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
818 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
819 " with invalid domain failed - %s\n",
820 r.in.req.req1.level, errstr);
822 } else if (!W_ERROR_EQUAL(r.out.result, WERR_DS_OBJ_NOT_FOUND)) {
823 printf("DsGetDomainControllerInfo level %d\n"
824 " with invalid domain not expected error (WERR_DS_OBJ_NOT_FOUND) - %s\n",
825 r.in.req.req1.level, win_errstr(r.out.result));
832 static BOOL test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
833 struct DsPrivate *priv)
836 struct drsuapi_DsWriteAccountSpn r;
837 struct drsuapi_DsNameString names[2];
840 r.in.bind_handle = &priv->bind_handle;
843 printf("testing DsWriteAccountSpn\n");
845 r.in.req.req1.operation = DRSUAPI_DS_SPN_OPERATION_ADD;
846 r.in.req.req1.unknown1 = 0;
847 r.in.req.req1.object_dn = priv->dcinfo.computer_dn;
848 r.in.req.req1.count = 2;
849 r.in.req.req1.spn_names = names;
850 names[0].str = talloc_asprintf(mem_ctx, "smbtortureSPN/%s",priv->dcinfo.netbios_name);
851 names[1].str = talloc_asprintf(mem_ctx, "smbtortureSPN/%s",priv->dcinfo.dns_name);
853 status = dcerpc_drsuapi_DsWriteAccountSpn(p, mem_ctx, &r);
854 if (!NT_STATUS_IS_OK(status)) {
855 const char *errstr = nt_errstr(status);
856 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
857 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
859 printf("dcerpc_drsuapi_DsWriteAccountSpn failed - %s\n", errstr);
861 } else if (!W_ERROR_IS_OK(r.out.result)) {
862 printf("DsWriteAccountSpn failed - %s\n", win_errstr(r.out.result));
866 r.in.req.req1.operation = DRSUAPI_DS_SPN_OPERATION_DELETE;
867 r.in.req.req1.unknown1 = 0;
869 status = dcerpc_drsuapi_DsWriteAccountSpn(p, mem_ctx, &r);
870 if (!NT_STATUS_IS_OK(status)) {
871 const char *errstr = nt_errstr(status);
872 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
873 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
875 printf("dcerpc_drsuapi_DsWriteAccountSpn failed - %s\n", errstr);
877 } else if (!W_ERROR_IS_OK(r.out.result)) {
878 printf("DsWriteAccountSpn failed - %s\n", win_errstr(r.out.result));
885 static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
886 struct DsPrivate *priv)
889 struct drsuapi_DsReplicaGetInfo r;
898 DRSUAPI_DS_REPLICA_GET_INFO,
899 DRSUAPI_DS_REPLICA_INFO_NEIGHBORS,
902 DRSUAPI_DS_REPLICA_GET_INFO,
903 DRSUAPI_DS_REPLICA_INFO_CURSORS,
906 DRSUAPI_DS_REPLICA_GET_INFO,
907 DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA,
910 DRSUAPI_DS_REPLICA_GET_INFO,
911 DRSUAPI_DS_REPLICA_INFO_KCC_DSA_CONNECT_FAILURES,
914 DRSUAPI_DS_REPLICA_GET_INFO,
915 DRSUAPI_DS_REPLICA_INFO_KCC_DSA_LINK_FAILURES,
918 DRSUAPI_DS_REPLICA_GET_INFO,
919 DRSUAPI_DS_REPLICA_INFO_PENDING_OPS,
922 DRSUAPI_DS_REPLICA_GET_INFO2,
923 DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA,
926 DRSUAPI_DS_REPLICA_GET_INFO2,
927 DRSUAPI_DS_REPLICA_INFO_CURSORS2,
930 DRSUAPI_DS_REPLICA_GET_INFO2,
931 DRSUAPI_DS_REPLICA_INFO_CURSORS3,
934 DRSUAPI_DS_REPLICA_GET_INFO2,
935 DRSUAPI_DS_REPLICA_INFO_OBJ_METADATA2,
938 DRSUAPI_DS_REPLICA_GET_INFO2,
939 DRSUAPI_DS_REPLICA_INFO_ATTRIBUTE_VALUE_METADATA2,
942 DRSUAPI_DS_REPLICA_GET_INFO2,
943 DRSUAPI_DS_REPLICA_INFO_NEIGHBORS02,
946 DRSUAPI_DS_REPLICA_GET_INFO2,
947 DRSUAPI_DS_REPLICA_INFO_CONNECTIONS04,
950 DRSUAPI_DS_REPLICA_GET_INFO2,
951 DRSUAPI_DS_REPLICA_INFO_CURSURS05,
954 DRSUAPI_DS_REPLICA_GET_INFO2,
955 DRSUAPI_DS_REPLICA_INFO_06,
960 r.in.bind_handle = &priv->bind_handle;
962 for (i=0; i < ARRAY_SIZE(array); i++) {
963 const char *object_dn;
965 printf("testing DsReplicaGetInfo level %d infotype %d\n",
966 array[i].level, array[i].infotype);
968 object_dn = (array[i].obj_dn ? array[i].obj_dn : priv->domain_obj_dn);
970 r.in.level = array[i].level;
972 case DRSUAPI_DS_REPLICA_GET_INFO:
973 r.in.req.req1.info_type = array[i].infotype;
974 r.in.req.req1.object_dn = object_dn;
975 ZERO_STRUCT(r.in.req.req1.guid1);
977 case DRSUAPI_DS_REPLICA_GET_INFO2:
978 r.in.req.req2.info_type = array[i].infotype;
979 r.in.req.req2.object_dn = object_dn;
980 ZERO_STRUCT(r.in.req.req1.guid1);
981 r.in.req.req2.unknown1 = 0;
982 r.in.req.req2.string1 = NULL;
983 r.in.req.req2.string2 = NULL;
984 r.in.req.req2.unknown2 = 0;
988 status = dcerpc_drsuapi_DsReplicaGetInfo(p, mem_ctx, &r);
989 if (!NT_STATUS_IS_OK(status)) {
990 const char *errstr = nt_errstr(status);
991 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
992 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
994 if (p->last_fault_code != DCERPC_FAULT_INVALID_TAG) {
995 printf("dcerpc_drsuapi_DsReplicaGetInfo failed - %s\n", errstr);
998 printf("DsReplicaGetInfo level %d and/or infotype %d not supported by server\n",
999 array[i].level, array[i].infotype);
1001 } else if (!W_ERROR_IS_OK(r.out.result)) {
1002 printf("DsReplicaGetInfo failed - %s\n", win_errstr(r.out.result));
1010 static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
1011 struct DsPrivate *priv)
1016 struct drsuapi_DsReplicaSync r;
1017 struct drsuapi_DsReplicaObjectIdentifier nc;
1018 struct GUID null_guid;
1019 struct dom_sid null_sid;
1028 if (!lp_parm_bool(-1, "torture", "dangerous", False)) {
1029 printf("DsReplicaSync disabled - enable dangerous tests to use\n");
1033 ZERO_STRUCT(null_guid);
1034 ZERO_STRUCT(null_sid);
1036 r.in.bind_handle = &priv->bind_handle;
1038 for (i=0; i < ARRAY_SIZE(array); i++) {
1039 printf("testing DsReplicaSync level %d\n",
1042 r.in.level = array[i].level;
1043 switch(r.in.level) {
1045 nc.guid = null_guid;
1047 nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:"";
1049 r.in.req.req1.naming_context = &nc;
1050 r.in.req.req1.guid1 = priv->dcinfo.ntds_guid;
1051 r.in.req.req1.string1 = NULL;
1052 r.in.req.req1.options = 16;
1056 status = dcerpc_drsuapi_DsReplicaSync(p, mem_ctx, &r);
1057 if (!NT_STATUS_IS_OK(status)) {
1058 const char *errstr = nt_errstr(status);
1059 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
1060 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
1062 printf("dcerpc_drsuapi_DsReplicaSync failed - %s\n", errstr);
1064 } else if (!W_ERROR_IS_OK(r.out.result)) {
1065 printf("DsReplicaSync failed - %s\n", win_errstr(r.out.result));
1073 static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
1074 struct DsPrivate *priv)
1079 struct drsuapi_DsReplicaUpdateRefs r;
1080 struct drsuapi_DsReplicaObjectIdentifier nc;
1081 struct GUID null_guid;
1082 struct dom_sid null_sid;
1091 ZERO_STRUCT(null_guid);
1092 ZERO_STRUCT(null_sid);
1094 r.in.bind_handle = &priv->bind_handle;
1096 for (i=0; i < ARRAY_SIZE(array); i++) {
1097 printf("testing DsReplicaUpdateRefs level %d\n",
1100 r.in.level = array[i].level;
1101 switch(r.in.level) {
1103 nc.guid = null_guid;
1105 nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:"";
1107 r.in.req.req1.naming_context = &nc;
1108 r.in.req.req1.dest_dsa_dns_name = talloc_asprintf(mem_ctx, "__some_dest_dsa_guid_string._msdn.%s",
1109 priv->domain_dns_name);
1110 r.in.req.req1.dest_dsa_guid = null_guid;
1111 r.in.req.req1.options = 0;
1115 status = dcerpc_drsuapi_DsReplicaUpdateRefs(p, mem_ctx, &r);
1116 if (!NT_STATUS_IS_OK(status)) {
1117 const char *errstr = nt_errstr(status);
1118 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
1119 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
1121 printf("dcerpc_drsuapi_DsReplicaUpdateRefs failed - %s\n", errstr);
1123 } else if (!W_ERROR_IS_OK(r.out.result)) {
1124 printf("DsReplicaUpdateRefs failed - %s\n", win_errstr(r.out.result));
1132 static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
1133 struct DsPrivate *priv)
1138 struct drsuapi_DsGetNCChanges r;
1139 struct drsuapi_DsReplicaObjectIdentifier nc;
1140 struct GUID null_guid;
1141 struct dom_sid null_sid;
1153 ZERO_STRUCT(null_guid);
1154 ZERO_STRUCT(null_sid);
1156 for (i=0; i < ARRAY_SIZE(array); i++) {
1157 printf("testing DsGetNCChanges level %d\n",
1160 r.in.bind_handle = &priv->bind_handle;
1161 r.in.level = array[i].level;
1163 switch (r.in.level) {
1165 nc.guid = null_guid;
1167 nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:"";
1169 r.in.req.req5.destination_dsa_guid = GUID_random();
1170 r.in.req.req5.source_dsa_guid = null_guid;
1171 r.in.req.req5.naming_context = &nc;
1172 r.in.req.req5.highwatermark.tmp_highest_usn = 0;
1173 r.in.req.req5.highwatermark.reserved_usn = 0;
1174 r.in.req.req5.highwatermark.highest_usn = 0;
1175 r.in.req.req5.uptodateness_vector = NULL;
1176 r.in.req.req5.replica_flags = 0;
1177 if (lp_parm_bool(-1, "drsuapi","compression", False)) {
1178 r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES;
1180 r.in.req.req5.unknown2 = 0;
1181 r.in.req.req5.unknown3 = 0;
1182 r.in.req.req5.unknown4 = 0;
1183 r.in.req.req5.h1 = 0;
1187 nc.guid = null_guid;
1189 nc.dn = priv->domain_obj_dn?priv->domain_obj_dn:"";
1191 r.in.req.req8.destination_dsa_guid = GUID_random();
1192 r.in.req.req8.source_dsa_guid = null_guid;
1193 r.in.req.req8.naming_context = &nc;
1194 r.in.req.req8.highwatermark.tmp_highest_usn = 0;
1195 r.in.req.req8.highwatermark.reserved_usn = 0;
1196 r.in.req.req8.highwatermark.highest_usn = 0;
1197 r.in.req.req8.uptodateness_vector = NULL;
1198 r.in.req.req8.replica_flags = 0
1199 | DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE
1200 | DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP
1201 | DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS
1202 | DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS
1203 | DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED
1204 | DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES
1206 r.in.req.req8.unknown2 = 402;
1207 r.in.req.req8.unknown3 = 402116;
1208 r.in.req.req8.unknown4 = 0;
1209 r.in.req.req8.h1 = 0;
1210 r.in.req.req8.unique_ptr1 = 0;
1211 r.in.req.req8.unique_ptr2 = 0;
1212 r.in.req.req8.ctr12.count = 0;
1213 r.in.req.req8.ctr12.array = NULL;
1218 status = dcerpc_drsuapi_DsGetNCChanges(p, mem_ctx, &r);
1219 if (!NT_STATUS_IS_OK(status)) {
1220 const char *errstr = nt_errstr(status);
1221 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
1222 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
1224 printf("dcerpc_drsuapi_DsGetNCChanges failed - %s\n", errstr);
1226 } else if (!W_ERROR_IS_OK(r.out.result)) {
1227 printf("DsGetNCChanges failed - %s\n", win_errstr(r.out.result));
1235 static BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
1236 struct DsPrivate *priv)
1239 struct drsuapi_DsUnbind r;
1242 r.in.bind_handle = &priv->bind_handle;
1243 r.out.bind_handle = &priv->bind_handle;
1245 printf("testing DsUnbind\n");
1247 status = dcerpc_drsuapi_DsUnbind(p, mem_ctx, &r);
1248 if (!NT_STATUS_IS_OK(status)) {
1249 const char *errstr = nt_errstr(status);
1250 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
1251 errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
1253 printf("dcerpc_drsuapi_DsUnbind failed - %s\n", errstr);
1255 } else if (!W_ERROR_IS_OK(r.out.result)) {
1256 printf("DsBind failed - %s\n", win_errstr(r.out.result));
1263 BOOL torture_rpc_drsuapi(void)
1266 struct dcerpc_pipe *p;
1267 TALLOC_CTX *mem_ctx;
1269 struct DsPrivate priv;
1271 mem_ctx = talloc_init("torture_rpc_drsuapi");
1273 status = torture_rpc_connection(mem_ctx,
1275 DCERPC_DRSUAPI_NAME,
1276 DCERPC_DRSUAPI_UUID,
1277 DCERPC_DRSUAPI_VERSION);
1278 if (!NT_STATUS_IS_OK(status)) {
1279 talloc_free(mem_ctx);
1283 printf("Connected to DRAUAPI pipe\n");
1287 ret &= test_DsBind(p, mem_ctx, &priv);
1289 ret &= test_DsGetDCInfo(p, mem_ctx, &priv);
1291 ret &= test_DsCrackNames(p, mem_ctx, &priv);
1293 ret &= test_DsWriteAccountSpn(p, mem_ctx, &priv);
1295 ret &= test_DsReplicaGetInfo(p, mem_ctx, &priv);
1297 ret &= test_DsReplicaSync(p, mem_ctx, &priv);
1299 ret &= test_DsReplicaUpdateRefs(p, mem_ctx, &priv);
1301 ret &= test_DsGetNCChanges(p, mem_ctx, &priv);
1303 ret &= test_DsUnbind(p, mem_ctx, &priv);
1305 talloc_free(mem_ctx);
1310 BOOL torture_rpc_drsuapi_cracknames(void)
1313 struct dcerpc_pipe *p;
1314 TALLOC_CTX *mem_ctx;
1316 struct DsPrivate priv;
1318 mem_ctx = talloc_init("torture_rpc_drsuapi");
1320 status = torture_rpc_connection(mem_ctx,
1322 DCERPC_DRSUAPI_NAME,
1323 DCERPC_DRSUAPI_UUID,
1324 DCERPC_DRSUAPI_VERSION);
1325 if (!NT_STATUS_IS_OK(status)) {
1326 talloc_free(mem_ctx);
1330 printf("Connected to DRAUAPI pipe\n");
1334 ret &= test_DsBind(p, mem_ctx, &priv);
1336 ret &= test_DsGetDCInfo(p, mem_ctx, &priv);
1338 ret &= test_DsCrackNames(p, mem_ctx, &priv);
1340 ret &= test_DsUnbind(p, mem_ctx, &priv);
1342 talloc_free(mem_ctx);