r3512: - support DsCrackName GUID strings ('{faedf4f9-0de8-4582-b8b6-c475efefbe5a}')
[samba.git] / source4 / torture / rpc / drsuapi.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    DRSUapi tests
5
6    Copyright (C) Andrew Tridgell 2003
7    Copyright (C) Stefan (metze) Metzmacher 2004
8    
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.
13    
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.
18    
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.
22 */
23
24 #include "includes.h"
25 #include "librpc/gen_ndr/ndr_drsuapi.h"
26
27 struct DsPrivate {
28         struct policy_handle bind_handle;
29         struct GUID domain_guid;
30         struct GUID site_guid;
31         struct GUID computer_guid;
32         struct GUID server_guid;
33         struct GUID ntds_guid;
34 };
35
36 static BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 
37                       struct DsPrivate *priv)
38 {
39         NTSTATUS status;
40         struct drsuapi_DsBind r;
41         BOOL ret = True;
42
43         r.in.server_guid = NULL;
44         r.in.bind_info = NULL;
45         r.out.bind_handle = &priv->bind_handle;
46
47         printf("testing DsBind\n");
48
49         status = dcerpc_drsuapi_DsBind(p, mem_ctx, &r);
50         if (!NT_STATUS_IS_OK(status)) {
51                 const char *errstr = nt_errstr(status);
52                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
53                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
54                 }
55                 printf("dcerpc_drsuapi_DsBind failed - %s\n", errstr);
56                 ret = False;
57         } else if (!W_ERROR_IS_OK(r.out.result)) {
58                 printf("DsBind failed - %s\n", win_errstr(r.out.result));
59                 ret = False;
60         }
61
62         return ret;
63 }
64
65 static BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 
66                       struct DsPrivate *priv)
67 {
68         NTSTATUS status;
69         struct drsuapi_DsCrackNames r;
70         struct drsuapi_DsNameString names[1];
71         BOOL ret = True;
72         const char *dns_domain;
73         const char *nt4_domain;
74         const char *FQDN_1779_domain;
75         const char *FQDN_1779_name;
76
77         ZERO_STRUCT(r);
78         r.in.bind_handle                = &priv->bind_handle;
79         r.in.level                      = 1;
80         r.in.req.req1.unknown1          = 0x000004e4;
81         r.in.req.req1.unknown2          = 0x00000407;
82         r.in.req.req1.count             = 1;
83         r.in.req.req1.names             = names;
84         r.in.req.req1.format_flags      = DRSUAPI_DS_NAME_FLAG_NO_FLAGS;
85
86         r.in.req.req1.format_offered    = DRSUAPI_DS_NAME_FORMAT_CANONICAL;
87         r.in.req.req1.format_desired    = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT;
88         names[0].str = talloc_asprintf(mem_ctx, "%s/", lp_realm());
89
90         printf("testing DsCrackNames with name '%s' desired format:%d\n",
91                         names[0].str, r.in.req.req1.format_desired);
92
93         status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
94         if (!NT_STATUS_IS_OK(status)) {
95                 const char *errstr = nt_errstr(status);
96                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
97                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
98                 }
99                 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
100                 ret = False;
101         } else if (!W_ERROR_IS_OK(r.out.result)) {
102                 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
103                 ret = False;
104         }
105
106         if (!ret) {
107                 return ret;
108         }
109
110         dns_domain = r.out.ctr.ctr1->array[0].dns_domain_name;
111         nt4_domain = r.out.ctr.ctr1->array[0].result_name;
112
113         r.in.req.req1.format_offered    = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT;
114         r.in.req.req1.format_desired    = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
115         names[0].str = nt4_domain;
116
117         printf("testing DsCrackNames with name '%s' desired format:%d\n",
118                         names[0].str, r.in.req.req1.format_desired);
119
120         status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
121         if (!NT_STATUS_IS_OK(status)) {
122                 const char *errstr = nt_errstr(status);
123                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
124                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
125                 }
126                 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
127                 ret = False;
128         } else if (!W_ERROR_IS_OK(r.out.result)) {
129                 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
130                 ret = False;
131         }
132
133         if (!ret) {
134                 return ret;
135         }
136
137         FQDN_1779_domain = r.out.ctr.ctr1->array[0].result_name;
138
139         r.in.req.req1.format_offered    = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT;
140         r.in.req.req1.format_desired    = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
141         names[0].str = talloc_asprintf(mem_ctx, "%s%s$", nt4_domain, dcerpc_server_name(p));
142
143         printf("testing DsCrackNames with name '%s' desired format:%d\n",
144                         names[0].str, r.in.req.req1.format_desired);
145
146         status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
147         if (!NT_STATUS_IS_OK(status)) {
148                 const char *errstr = nt_errstr(status);
149                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
150                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
151                 }
152                 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
153                 ret = False;
154         } else if (!W_ERROR_IS_OK(r.out.result)) {
155                 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
156                 ret = False;
157         }
158
159         if (!ret) {
160                 return ret;
161         }
162
163         FQDN_1779_name = r.out.ctr.ctr1->array[0].result_name;
164
165         r.in.req.req1.format_offered    = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
166         r.in.req.req1.format_desired    = DRSUAPI_DS_NAME_FORMAT_CANONICAL;
167         names[0].str = FQDN_1779_name;
168
169         printf("testing DsCrackNames with name '%s' desired format:%d\n",
170                         names[0].str, r.in.req.req1.format_desired);
171
172         status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
173         if (!NT_STATUS_IS_OK(status)) {
174                 const char *errstr = nt_errstr(status);
175                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
176                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
177                 }
178                 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
179                 ret = False;
180         } else if (!W_ERROR_IS_OK(r.out.result)) {
181                 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
182                 ret = False;
183         }
184
185         if (!ret) {
186                 return ret;
187         }
188
189         r.in.req.req1.format_desired    = DRSUAPI_DS_NAME_FORMAT_DISPLAY;
190
191         printf("testing DsCrackNames with name '%s' desired format:%d\n",
192                         names[0].str, r.in.req.req1.format_desired);
193
194         status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
195         if (!NT_STATUS_IS_OK(status)) {
196                 const char *errstr = nt_errstr(status);
197                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
198                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
199                 }
200                 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
201                 ret = False;
202         } else if (!W_ERROR_IS_OK(r.out.result)) {
203                 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
204                 ret = False;
205         }
206
207         if (!ret) {
208                 return ret;
209         }
210
211         r.in.req.req1.format_desired    = DRSUAPI_DS_NAME_FORMAT_GUID;
212
213         printf("testing DsCrackNames with name '%s' desired format:%d\n",
214                         names[0].str, r.in.req.req1.format_desired);
215
216         status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
217         if (!NT_STATUS_IS_OK(status)) {
218                 const char *errstr = nt_errstr(status);
219                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
220                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
221                 }
222                 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
223                 ret = False;
224         } else if (!W_ERROR_IS_OK(r.out.result)) {
225                 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
226                 ret = False;
227         }
228
229         if (!ret) {
230                 return ret;
231         }
232
233         r.in.req.req1.format_desired    = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL;
234
235         printf("testing DsCrackNames with name '%s' desired format:%d\n",
236                         names[0].str, r.in.req.req1.format_desired);
237
238         status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
239         if (!NT_STATUS_IS_OK(status)) {
240                 const char *errstr = nt_errstr(status);
241                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
242                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
243                 }
244                 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
245                 ret = False;
246         } else if (!W_ERROR_IS_OK(r.out.result)) {
247                 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
248                 ret = False;
249         }
250
251         if (!ret) {
252                 return ret;
253         }
254
255         r.in.req.req1.format_desired    = DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL;
256
257         printf("testing DsCrackNames with name '%s' desired format:%d\n",
258                         names[0].str, r.in.req.req1.format_desired);
259
260         status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
261         if (!NT_STATUS_IS_OK(status)) {
262                 const char *errstr = nt_errstr(status);
263                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
264                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
265                 }
266                 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
267                 ret = False;
268         } else if (!W_ERROR_IS_OK(r.out.result)) {
269                 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
270                 ret = False;
271         }
272
273         if (!ret) {
274                 return ret;
275         }
276
277         r.in.req.req1.format_offered    = DRSUAPI_DS_NAME_FORMAT_GUID;
278         r.in.req.req1.format_desired    = DRSUAPI_DS_NAME_FORMAT_FQDN_1779;
279         names[0].str = GUID_string2(mem_ctx, &priv->site_guid);
280
281         printf("testing DsCrackNames with Site GUID '%s' desired format:%d\n",
282                         names[0].str, r.in.req.req1.format_desired);
283
284         status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
285         if (!NT_STATUS_IS_OK(status)) {
286                 const char *errstr = nt_errstr(status);
287                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
288                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
289                 }
290                 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
291                 ret = False;
292         } else if (!W_ERROR_IS_OK(r.out.result)) {
293                 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
294                 ret = False;
295         }
296
297         if (!ret) {
298                 return ret;
299         }
300
301         names[0].str = GUID_string2(mem_ctx, &priv->computer_guid);
302
303         printf("testing DsCrackNames with Computer GUID '%s' desired format:%d\n",
304                         names[0].str, r.in.req.req1.format_desired);
305
306         status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
307         if (!NT_STATUS_IS_OK(status)) {
308                 const char *errstr = nt_errstr(status);
309                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
310                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
311                 }
312                 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
313                 ret = False;
314         } else if (!W_ERROR_IS_OK(r.out.result)) {
315                 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
316                 ret = False;
317         }
318
319         if (!ret) {
320                 return ret;
321         }
322
323         names[0].str = GUID_string2(mem_ctx, &priv->server_guid);
324
325         printf("testing DsCrackNames with Server GUID '%s' desired format:%d\n",
326                         names[0].str, r.in.req.req1.format_desired);
327
328         status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
329         if (!NT_STATUS_IS_OK(status)) {
330                 const char *errstr = nt_errstr(status);
331                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
332                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
333                 }
334                 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
335                 ret = False;
336         } else if (!W_ERROR_IS_OK(r.out.result)) {
337                 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
338                 ret = False;
339         }
340
341         if (!ret) {
342                 return ret;
343         }
344
345         names[0].str = GUID_string2(mem_ctx, &priv->ntds_guid);
346
347         printf("testing DsCrackNames with NTDS GUID '%s' desired format:%d\n",
348                         names[0].str, r.in.req.req1.format_desired);
349
350         status = dcerpc_drsuapi_DsCrackNames(p, mem_ctx, &r);
351         if (!NT_STATUS_IS_OK(status)) {
352                 const char *errstr = nt_errstr(status);
353                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
354                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
355                 }
356                 printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr);
357                 ret = False;
358         } else if (!W_ERROR_IS_OK(r.out.result)) {
359                 printf("DsCrackNames failed - %s\n", win_errstr(r.out.result));
360                 ret = False;
361         }
362
363         if (!ret) {
364                 return ret;
365         }
366
367         return ret;
368 }
369
370 static BOOL test_DsGetDCInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 
371                       struct DsPrivate *priv)
372 {
373         NTSTATUS status;
374         struct drsuapi_DsGetDomainControllerInfo r;
375         BOOL ret = True;
376
377         r.in.bind_handle = &priv->bind_handle;
378         r.in.level = 1;
379
380         r.in.req.req1.domain_name = talloc_strdup(mem_ctx, lp_realm());
381         r.in.req.req1.level = 1;
382
383         printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
384                         r.in.req.req1.level, r.in.req.req1.domain_name);
385
386         status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r);
387         if (!NT_STATUS_IS_OK(status)) {
388                 const char *errstr = nt_errstr(status);
389                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
390                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
391                 }
392                 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
393                         "    with dns domain failed - %s\n",
394                         r.in.req.req1.level, errstr);
395                 ret = False;
396         } else if (!W_ERROR_IS_OK(r.out.result)) {
397                 printf("DsGetDomainControllerInfo level %d\n"
398                         "    with dns domain failed - %s\n",
399                         r.in.req.req1.level, win_errstr(r.out.result));
400                 ret = False;
401         }
402
403         r.in.req.req1.level = 2;
404
405         printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
406                         r.in.req.req1.level, r.in.req.req1.domain_name);
407
408         status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r);
409         if (!NT_STATUS_IS_OK(status)) {
410                 const char *errstr = nt_errstr(status);
411                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
412                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
413                 }
414                 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
415                         "    with dns domain failed - %s\n",
416                         r.in.req.req1.level, errstr);
417                 ret = False;
418         } else if (!W_ERROR_IS_OK(r.out.result)) {
419                 printf("DsGetDomainControllerInfo level %d\n"
420                         "    with dns domain failed - %s\n",
421                         r.in.req.req1.level, win_errstr(r.out.result));
422                 ret = False;
423         } else {
424                 if (r.out.ctr.ctr2.count > 0) {
425                         priv->site_guid         = r.out.ctr.ctr2.array[0].site_guid;
426                         priv->computer_guid     = r.out.ctr.ctr2.array[0].computer_guid;
427                         priv->server_guid       = r.out.ctr.ctr2.array[0].server_guid;
428                         priv->ntds_guid         = r.out.ctr.ctr2.array[0].ntds_guid;
429                 }
430         }
431
432         r.in.req.req1.level = -1;
433
434         printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
435                         r.in.req.req1.level, r.in.req.req1.domain_name);
436
437         status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r);
438         if (!NT_STATUS_IS_OK(status)) {
439                 const char *errstr = nt_errstr(status);
440                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
441                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
442                 }
443                 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
444                         "    with dns domain failed - %s\n",
445                         r.in.req.req1.level, errstr);
446                 ret = False;
447         } else if (!W_ERROR_IS_OK(r.out.result)) {
448                 printf("DsGetDomainControllerInfo level %d\n"
449                         "    with dns domain failed - %s\n",
450                         r.in.req.req1.level, win_errstr(r.out.result));
451                 ret = False;
452         }
453
454         r.in.req.req1.domain_name = talloc_strdup(mem_ctx, lp_workgroup());
455         r.in.req.req1.level = 2;
456
457         printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
458                         r.in.req.req1.level, r.in.req.req1.domain_name);
459
460         status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r);
461         if (!NT_STATUS_IS_OK(status)) {
462                 const char *errstr = nt_errstr(status);
463                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
464                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
465                 }
466                 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
467                         "    with netbios domain failed - %s\n",
468                         r.in.req.req1.level, errstr);
469                 ret = False;
470         } else if (!W_ERROR_IS_OK(r.out.result)) {
471                 printf("DsGetDomainControllerInfo level %d\n"
472                         "    with netbios domain failed - %s\n",
473                         r.in.req.req1.level, win_errstr(r.out.result));
474                 ret = False;
475         }
476
477         r.in.req.req1.domain_name = "__UNKNOWN_DOMAIN__";
478         r.in.req.req1.level = 2;
479
480         printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n",
481                         r.in.req.req1.level, r.in.req.req1.domain_name);
482
483         status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r);
484         if (!NT_STATUS_IS_OK(status)) {
485                 const char *errstr = nt_errstr(status);
486                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
487                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
488                 }
489                 printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n"
490                         "    with invalid domain failed - %s\n",
491                         r.in.req.req1.level, errstr);
492                 ret = False;
493         } else if (!W_ERROR_EQUAL(r.out.result, WERR_DS_OBJ_NOT_FOUND)) {
494                 printf("DsGetDomainControllerInfo level %d\n"
495                         "    with invalid domain not expected error (WERR_DS_OBJ_NOT_FOUND) - %s\n",
496                         r.in.req.req1.level, win_errstr(r.out.result));
497                 ret = False;
498         }
499
500         return ret;
501 }
502
503 static BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 
504                         struct DsPrivate *priv)
505 {
506         NTSTATUS status;
507         struct drsuapi_DsUnbind r;
508         BOOL ret = True;
509
510         r.in.bind_handle = &priv->bind_handle;
511         r.out.bind_handle = &priv->bind_handle;
512
513         printf("testing DsUnbind\n");
514
515         status = dcerpc_drsuapi_DsUnbind(p, mem_ctx, &r);
516         if (!NT_STATUS_IS_OK(status)) {
517                 const char *errstr = nt_errstr(status);
518                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
519                         errstr = dcerpc_errstr(mem_ctx, p->last_fault_code);
520                 }
521                 printf("dcerpc_drsuapi_DsUnbind failed - %s\n", errstr);
522                 ret = False;
523         } else if (!W_ERROR_IS_OK(r.out.result)) {
524                 printf("DsBind failed - %s\n", win_errstr(r.out.result));
525                 ret = False;
526         }
527
528         return ret;
529 }
530
531 BOOL torture_rpc_drsuapi(void)
532 {
533         NTSTATUS status;
534         struct dcerpc_pipe *p;
535         TALLOC_CTX *mem_ctx;
536         BOOL ret = True;
537         struct DsPrivate priv;
538
539         status = torture_rpc_connection(&p, 
540                                         DCERPC_DRSUAPI_NAME,
541                                         DCERPC_DRSUAPI_UUID,
542                                         DCERPC_DRSUAPI_VERSION);
543         if (!NT_STATUS_IS_OK(status)) {
544                 return False;
545         }
546
547         printf("Connected to DRAUAPI pipe\n");
548
549         mem_ctx = talloc_init("torture_rpc_drsuapi");
550
551         if (!test_DsBind(p, mem_ctx, &priv)) {
552                 ret = False;
553         }
554
555         if (!test_DsGetDCInfo(p, mem_ctx, &priv)) {
556                 ret = False;
557         }
558
559         if (!test_DsCrackNames(p, mem_ctx, &priv)) {
560                 ret = False;
561         }
562
563         if (!test_DsUnbind(p, mem_ctx, &priv)) {
564                 ret = False;
565         }
566
567 #if 0
568         if (!test_scan(p, mem_ctx)) {
569                 ret = False;
570         }
571 #endif
572         talloc_destroy(mem_ctx);
573
574         torture_rpc_close(p);
575
576         return ret;
577 }