s4-samr: merge samr_LookupNames from s3 idl. (fixme: python)
[ira/wip.git] / source4 / torture / rpc / testjoin.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    utility code to join/leave a domain
5
6    Copyright (C) Andrew Tridgell 2004
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 /*
23   this code is used by other torture modules to join/leave a domain
24   as either a member, bdc or thru a trust relationship
25 */
26
27 #include "includes.h"
28 #include "torture/torture.h"
29 #include "system/time.h"
30 #include "../lib/crypto/crypto.h"
31 #include "libnet/libnet.h"
32 #include "lib/cmdline/popt_common.h"
33 #include "lib/ldb/include/ldb.h"
34 #include "librpc/gen_ndr/ndr_samr_c.h"
35
36 #include "libcli/auth/libcli_auth.h"
37 #include "torture/rpc/rpc.h"
38 #include "libcli/security/security.h"
39 #include "param/param.h"
40
41 struct test_join {
42         struct dcerpc_pipe *p;
43         struct policy_handle user_handle;
44         struct libnet_JoinDomain *libnet_r;
45         struct dom_sid *dom_sid;
46         const char *dom_netbios_name;
47         const char *dom_dns_name;
48         struct dom_sid *user_sid;
49         struct GUID user_guid;
50         const char *netbios_name;
51 };
52
53
54 static NTSTATUS DeleteUser_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 
55                                   struct policy_handle *handle, const char *name)
56 {
57         NTSTATUS status;
58         struct samr_DeleteUser d;
59         struct policy_handle user_handle;
60         uint32_t rid;
61         struct samr_LookupNames n;
62         struct samr_Ids rids, types;
63         struct lsa_String sname;
64         struct samr_OpenUser r;
65
66         sname.string = name;
67
68         n.in.domain_handle = handle;
69         n.in.num_names = 1;
70         n.in.names = &sname;
71         n.out.rids = &rids;
72         n.out.types = &types;
73
74         status = dcerpc_samr_LookupNames(p, mem_ctx, &n);
75         if (NT_STATUS_IS_OK(status)) {
76                 rid = n.out.rids->ids[0];
77         } else {
78                 return status;
79         }
80
81         r.in.domain_handle = handle;
82         r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
83         r.in.rid = rid;
84         r.out.user_handle = &user_handle;
85
86         status = dcerpc_samr_OpenUser(p, mem_ctx, &r);
87         if (!NT_STATUS_IS_OK(status)) {
88                 printf("OpenUser(%s) failed - %s\n", name, nt_errstr(status));
89                 return status;
90         }
91
92         d.in.user_handle = &user_handle;
93         d.out.user_handle = &user_handle;
94         status = dcerpc_samr_DeleteUser(p, mem_ctx, &d);
95         if (!NT_STATUS_IS_OK(status)) {
96                 return status;
97         }
98
99         return NT_STATUS_OK;
100 }
101
102 /*
103   create a test user in the domain
104   an opaque pointer is returned. Pass it to torture_leave_domain() 
105   when finished
106 */
107
108 struct test_join *torture_create_testuser(struct torture_context *torture,
109                                           const char *username, 
110                                           const char *domain,
111                                           uint16_t acct_type,
112                                           const char **random_password)
113 {
114         NTSTATUS status;
115         struct samr_Connect c;
116         struct samr_CreateUser2 r;
117         struct samr_OpenDomain o;
118         struct samr_LookupDomain l;
119         struct samr_GetUserPwInfo pwp;
120         struct samr_PwInfo info;
121         struct samr_SetUserInfo s;
122         union samr_UserInfo u;
123         struct policy_handle handle;
124         struct policy_handle domain_handle;
125         uint32_t access_granted;
126         uint32_t rid;
127         DATA_BLOB session_key;
128         struct lsa_String name;
129         
130         int policy_min_pw_len = 0;
131         struct test_join *join;
132         char *random_pw;
133         const char *dc_binding = torture_setting_string(torture, "dc_binding", NULL);
134
135         join = talloc(NULL, struct test_join);
136         if (join == NULL) {
137                 return NULL;
138         }
139
140         ZERO_STRUCTP(join);
141
142         printf("Connecting to SAMR\n");
143         
144         if (dc_binding) {
145                 status = dcerpc_pipe_connect(join,
146                                              &join->p,
147                                              dc_binding,
148                                              &ndr_table_samr,
149                                              cmdline_credentials, NULL, torture->lp_ctx);
150                                              
151         } else {
152                 status = torture_rpc_connection(torture, 
153                                                 &join->p, 
154                                                 &ndr_table_samr);
155         }
156         if (!NT_STATUS_IS_OK(status)) {
157                 return NULL;
158         }
159
160         c.in.system_name = NULL;
161         c.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
162         c.out.connect_handle = &handle;
163
164         status = dcerpc_samr_Connect(join->p, join, &c);
165         if (!NT_STATUS_IS_OK(status)) {
166                 const char *errstr = nt_errstr(status);
167                 if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
168                         errstr = dcerpc_errstr(join, join->p->last_fault_code);
169                 }
170                 printf("samr_Connect failed - %s\n", errstr);
171                 return NULL;
172         }
173
174         printf("Opening domain %s\n", domain);
175
176         name.string = domain;
177         l.in.connect_handle = &handle;
178         l.in.domain_name = &name;
179
180         status = dcerpc_samr_LookupDomain(join->p, join, &l);
181         if (!NT_STATUS_IS_OK(status)) {
182                 printf("LookupDomain failed - %s\n", nt_errstr(status));
183                 goto failed;
184         }
185
186         talloc_steal(join, l.out.sid);
187         join->dom_sid = l.out.sid;
188         join->dom_netbios_name = talloc_strdup(join, domain);
189         if (!join->dom_netbios_name) goto failed;
190
191         o.in.connect_handle = &handle;
192         o.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
193         o.in.sid = l.out.sid;
194         o.out.domain_handle = &domain_handle;
195
196         status = dcerpc_samr_OpenDomain(join->p, join, &o);
197         if (!NT_STATUS_IS_OK(status)) {
198                 printf("OpenDomain failed - %s\n", nt_errstr(status));
199                 goto failed;
200         }
201
202         printf("Creating account %s\n", username);
203
204 again:
205         name.string = username;
206         r.in.domain_handle = &domain_handle;
207         r.in.account_name = &name;
208         r.in.acct_flags = acct_type;
209         r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
210         r.out.user_handle = &join->user_handle;
211         r.out.access_granted = &access_granted;
212         r.out.rid = &rid;
213
214         status = dcerpc_samr_CreateUser2(join->p, join, &r);
215
216         if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
217                 status = DeleteUser_byname(join->p, join, &domain_handle, name.string);
218                 if (NT_STATUS_IS_OK(status)) {
219                         goto again;
220                 }
221         }
222
223         if (!NT_STATUS_IS_OK(status)) {
224                 printf("CreateUser2 failed - %s\n", nt_errstr(status));
225                 goto failed;
226         }
227
228         join->user_sid = dom_sid_add_rid(join, join->dom_sid, rid);
229
230         pwp.in.user_handle = &join->user_handle;
231         pwp.out.info = &info;
232
233         status = dcerpc_samr_GetUserPwInfo(join->p, join, &pwp);
234         if (NT_STATUS_IS_OK(status)) {
235                 policy_min_pw_len = pwp.out.info->min_password_length;
236         }
237
238         random_pw = generate_random_str(join, MAX(8, policy_min_pw_len));
239
240         printf("Setting account password '%s'\n", random_pw);
241
242         ZERO_STRUCT(u);
243         s.in.user_handle = &join->user_handle;
244         s.in.info = &u;
245         s.in.level = 24;
246
247         encode_pw_buffer(u.info24.password.data, random_pw, STR_UNICODE);
248         u.info24.pw_len = strlen(random_pw);
249
250         status = dcerpc_fetch_session_key(join->p, &session_key);
251         if (!NT_STATUS_IS_OK(status)) {
252                 printf("SetUserInfo level %u - no session key - %s\n",
253                        s.in.level, nt_errstr(status));
254                 torture_leave_domain(torture, join);
255                 goto failed;
256         }
257
258         arcfour_crypt_blob(u.info24.password.data, 516, &session_key);
259
260         status = dcerpc_samr_SetUserInfo(join->p, join, &s);
261         if (!NT_STATUS_IS_OK(status)) {
262                 printf("SetUserInfo failed - %s\n", nt_errstr(status));
263                 goto failed;
264         }
265
266         ZERO_STRUCT(u);
267         s.in.user_handle = &join->user_handle;
268         s.in.info = &u;
269         s.in.level = 21;
270
271         u.info21.acct_flags = acct_type | ACB_PWNOEXP;
272         u.info21.fields_present = SAMR_FIELD_ACCT_FLAGS | SAMR_FIELD_DESCRIPTION | SAMR_FIELD_COMMENT | SAMR_FIELD_FULL_NAME;
273
274         u.info21.comment.string = talloc_asprintf(join, 
275                                                   "Tortured by Samba4: %s", 
276                                                   timestring(join, time(NULL)));
277         
278         u.info21.full_name.string = talloc_asprintf(join, 
279                                                     "Torture account for Samba4: %s", 
280                                                     timestring(join, time(NULL)));
281         
282         u.info21.description.string = talloc_asprintf(join, 
283                                          "Samba4 torture account created by host %s: %s", 
284                                          lp_netbios_name(torture->lp_ctx), 
285                                          timestring(join, time(NULL)));
286
287         printf("Resetting ACB flags, force pw change time\n");
288
289         status = dcerpc_samr_SetUserInfo(join->p, join, &s);
290         if (!NT_STATUS_IS_OK(status)) {
291                 printf("SetUserInfo failed - %s\n", nt_errstr(status));
292                 goto failed;
293         }
294
295         if (random_password) {
296                 *random_password = random_pw;
297         }
298
299         return join;
300
301 failed:
302         torture_leave_domain(torture, join);
303         return NULL;
304 }
305
306
307 _PUBLIC_ struct test_join *torture_join_domain(struct torture_context *tctx,
308                                                const char *machine_name, 
309                                       uint32_t acct_flags,
310                                       struct cli_credentials **machine_credentials)
311 {
312         NTSTATUS status;
313         struct libnet_context *libnet_ctx;
314         struct libnet_JoinDomain *libnet_r;
315         struct test_join *tj;
316         struct samr_SetUserInfo s;
317         union samr_UserInfo u;
318         
319         tj = talloc(tctx, struct test_join);
320         if (!tj) return NULL;
321
322         libnet_r = talloc(tj, struct libnet_JoinDomain);
323         if (!libnet_r) {
324                 talloc_free(tj);
325                 return NULL;
326         }
327         
328         libnet_ctx = libnet_context_init(tctx->ev, tctx->lp_ctx);       
329         if (!libnet_ctx) {
330                 talloc_free(tj);
331                 return NULL;
332         }
333         
334         tj->libnet_r = libnet_r;
335                 
336         libnet_ctx->cred = cmdline_credentials;
337         libnet_r->in.binding = torture_setting_string(tctx, "binding", NULL);
338         if (!libnet_r->in.binding) {
339                 libnet_r->in.binding = talloc_asprintf(libnet_r, "ncacn_np:%s", torture_setting_string(tctx, "host", NULL));
340         }
341         libnet_r->in.level = LIBNET_JOINDOMAIN_SPECIFIED;
342         libnet_r->in.netbios_name = machine_name;
343         libnet_r->in.account_name = talloc_asprintf(libnet_r, "%s$", machine_name);
344         if (!libnet_r->in.account_name) {
345                 talloc_free(tj);
346                 return NULL;
347         }
348         
349         libnet_r->in.acct_type = acct_flags;
350         libnet_r->in.recreate_account = true;
351
352         status = libnet_JoinDomain(libnet_ctx, libnet_r, libnet_r);
353         if (!NT_STATUS_IS_OK(status)) {
354                 if (libnet_r->out.error_string) {
355                         DEBUG(0, ("Domain join failed - %s\n", libnet_r->out.error_string));
356                 } else {
357                         DEBUG(0, ("Domain join failed - %s\n", nt_errstr(status)));
358                 }
359                 talloc_free(tj);
360                 return NULL;
361         }
362         tj->p = libnet_r->out.samr_pipe;
363         tj->user_handle = *libnet_r->out.user_handle;
364         tj->dom_sid = libnet_r->out.domain_sid;
365         talloc_steal(tj, libnet_r->out.domain_sid);
366         tj->dom_netbios_name    = libnet_r->out.domain_name;
367         talloc_steal(tj, libnet_r->out.domain_name);
368         tj->dom_dns_name        = libnet_r->out.realm;
369         talloc_steal(tj, libnet_r->out.realm);
370         tj->user_guid = libnet_r->out.account_guid;
371         tj->netbios_name = talloc_strdup(tj, machine_name);
372         if (!tj->netbios_name) {
373                 talloc_free(tj);
374                 return NULL;
375         }
376
377         ZERO_STRUCT(u);
378         s.in.user_handle = &tj->user_handle;
379         s.in.info = &u;
380         s.in.level = 21;
381
382         u.info21.fields_present = SAMR_FIELD_DESCRIPTION | SAMR_FIELD_COMMENT | SAMR_FIELD_FULL_NAME;
383         u.info21.comment.string = talloc_asprintf(tj, 
384                                                   "Tortured by Samba4: %s", 
385                                                   timestring(tj, time(NULL)));
386         u.info21.full_name.string = talloc_asprintf(tj, 
387                                                     "Torture account for Samba4: %s", 
388                                                     timestring(tj, time(NULL)));
389         
390         u.info21.description.string = talloc_asprintf(tj, 
391                                                       "Samba4 torture account created by host %s: %s", 
392                                                       lp_netbios_name(tctx->lp_ctx), timestring(tj, time(NULL)));
393
394         status = dcerpc_samr_SetUserInfo(tj->p, tj, &s);
395         if (!NT_STATUS_IS_OK(status)) {
396                 printf("SetUserInfo (non-critical) failed - %s\n", nt_errstr(status));
397         }
398
399         *machine_credentials = cli_credentials_init(tj);
400         cli_credentials_set_conf(*machine_credentials, tctx->lp_ctx);
401         cli_credentials_set_workstation(*machine_credentials, machine_name, CRED_SPECIFIED);
402         cli_credentials_set_domain(*machine_credentials, libnet_r->out.domain_name, CRED_SPECIFIED);
403         if (libnet_r->out.realm) {
404                 cli_credentials_set_realm(*machine_credentials, libnet_r->out.realm, CRED_SPECIFIED);
405         }
406         cli_credentials_set_username(*machine_credentials, libnet_r->in.account_name, CRED_SPECIFIED);
407         cli_credentials_set_password(*machine_credentials, libnet_r->out.join_password, CRED_SPECIFIED);
408         cli_credentials_set_kvno(*machine_credentials, libnet_r->out.kvno);
409         if (acct_flags & ACB_SVRTRUST) {
410                 cli_credentials_set_secure_channel_type(*machine_credentials,
411                                                         SEC_CHAN_BDC);
412         } else if (acct_flags & ACB_WSTRUST) {
413                 cli_credentials_set_secure_channel_type(*machine_credentials,
414                                                         SEC_CHAN_WKSTA);
415         } else {
416                 DEBUG(0, ("Invalid account type specificed to torture_join_domain\n"));
417                 talloc_free(*machine_credentials);
418                 return NULL;
419         }
420
421         return tj;
422 }
423
424 struct dcerpc_pipe *torture_join_samr_pipe(struct test_join *join) 
425 {
426         return join->p;
427 }
428
429 struct policy_handle *torture_join_samr_user_policy(struct test_join *join) 
430 {
431         return &join->user_handle;
432 }
433
434 static NTSTATUS torture_leave_ads_domain(struct torture_context *torture,
435                                          TALLOC_CTX *mem_ctx,
436                                          struct libnet_JoinDomain *libnet_r)
437 {
438         int rtn;
439         TALLOC_CTX *tmp_ctx;
440
441         struct ldb_dn *server_dn;
442         struct ldb_context *ldb_ctx;
443
444         char *remote_ldb_url; 
445          
446         /* Check if we are a domain controller. If not, exit. */
447         if (!libnet_r->out.server_dn_str) {
448                 return NT_STATUS_OK;
449         }
450
451         tmp_ctx = talloc_named(mem_ctx, 0, "torture_leave temporary context");
452         if (!tmp_ctx) {
453                 libnet_r->out.error_string = NULL;
454                 return NT_STATUS_NO_MEMORY;
455         }
456
457         ldb_ctx = ldb_init(tmp_ctx, torture->ev);
458         if (!ldb_ctx) {
459                 libnet_r->out.error_string = NULL;
460                 talloc_free(tmp_ctx);
461                 return NT_STATUS_NO_MEMORY;
462         }
463
464         /* Remove CN=Servers,... entry from the AD. */ 
465         server_dn = ldb_dn_new(tmp_ctx, ldb_ctx, libnet_r->out.server_dn_str);
466         if (! ldb_dn_validate(server_dn)) {
467                 libnet_r->out.error_string = NULL;
468                 talloc_free(tmp_ctx);
469                 return NT_STATUS_NO_MEMORY;
470         }
471
472         remote_ldb_url = talloc_asprintf(tmp_ctx, "ldap://%s", libnet_r->out.samr_binding->host);
473         if (!remote_ldb_url) {
474                 libnet_r->out.error_string = NULL;
475                 talloc_free(tmp_ctx);
476                 return NT_STATUS_NO_MEMORY;
477         }
478
479         ldb_set_opaque(ldb_ctx, "credentials", cmdline_credentials);
480         ldb_set_opaque(ldb_ctx, "loadparm", cmdline_lp_ctx);
481
482         rtn = ldb_connect(ldb_ctx, remote_ldb_url, 0, NULL);
483         if (rtn != 0) {
484                 libnet_r->out.error_string = NULL;
485                 talloc_free(tmp_ctx);
486                 return NT_STATUS_UNSUCCESSFUL;
487         }
488
489         rtn = ldb_delete(ldb_ctx, server_dn);
490         if (rtn != 0) {
491                 libnet_r->out.error_string = NULL;
492                 talloc_free(tmp_ctx);
493                 return NT_STATUS_UNSUCCESSFUL;
494         }
495
496         DEBUG(0, ("%s removed successfully.\n", libnet_r->out.server_dn_str));
497
498         talloc_free(tmp_ctx); 
499         return NT_STATUS_OK;
500 }
501
502 /*
503   leave the domain, deleting the machine acct
504 */
505
506 _PUBLIC_ void torture_leave_domain(struct torture_context *torture, struct test_join *join)
507 {
508         struct samr_DeleteUser d;
509         NTSTATUS status;
510
511         if (!join) {
512                 return;
513         }
514         d.in.user_handle = &join->user_handle;
515         d.out.user_handle = &join->user_handle;
516
517         /* Delete machine account */
518         status = dcerpc_samr_DeleteUser(join->p, join, &d);
519         if (!NT_STATUS_IS_OK(status)) {
520                 printf("Delete of machine account %s failed\n",
521                        join->netbios_name);
522         } else {
523                 printf("Delete of machine account %s was successful.\n",
524                        join->netbios_name);
525         }
526
527         if (join->libnet_r) {
528                 status = torture_leave_ads_domain(torture, join, join->libnet_r);
529         }
530         
531         talloc_free(join);
532 }
533
534 /*
535   return the dom sid for a test join
536 */
537 _PUBLIC_ const struct dom_sid *torture_join_sid(struct test_join *join)
538 {
539         return join->dom_sid;
540 }
541
542 const struct dom_sid *torture_join_user_sid(struct test_join *join)
543 {
544         return join->user_sid;
545 }
546
547 const char *torture_join_netbios_name(struct test_join *join)
548 {
549         return join->netbios_name;
550 }
551
552 const struct GUID *torture_join_user_guid(struct test_join *join)
553 {
554         return &join->user_guid;
555 }
556
557 const char *torture_join_dom_netbios_name(struct test_join *join)
558 {
559         return join->dom_netbios_name;
560 }
561
562 const char *torture_join_dom_dns_name(struct test_join *join)
563 {
564         return join->dom_dns_name;
565 }
566
567 const char *torture_join_server_dn_str(struct test_join *join)
568 {
569         if (join->libnet_r) {
570                 return join->libnet_r->out.server_dn_str;
571         }
572         return NULL;
573 }
574
575
576 #if 0 /* Left as the documentation of the join process, but see new implementation in libnet_become_dc.c */
577 struct test_join_ads_dc {
578         struct test_join *join;
579 };
580
581 struct test_join_ads_dc *torture_join_domain_ads_dc(const char *machine_name, 
582                                                     const char *domain,
583                                                     struct cli_credentials **machine_credentials)
584 {
585         struct test_join_ads_dc *join;
586
587         join = talloc(NULL, struct test_join_ads_dc);
588         if (join == NULL) {
589                 return NULL;
590         }
591
592         join->join = torture_join_domain(machine_name, 
593                                         ACB_SVRTRUST,
594                                         machine_credentials);
595
596         if (!join->join) {
597                 return NULL;
598         }
599
600 /* W2K: */
601         /* W2K: modify userAccountControl from 4096 to 532480 */
602         
603         /* W2K: modify RDN to OU=Domain Controllers and skip the $ from server name */
604
605         /* ask objectVersion of Schema Partition */
606
607         /* ask rIDManagerReferenz of the Domain Partition */
608
609         /* ask fsMORoleOwner of the RID-Manager$ object
610          * returns CN=NTDS Settings,CN=<DC>,CN=Servers,CN=Default-First-Site-Name, ...
611          */
612
613         /* ask for dnsHostName of CN=<DC>,CN=Servers,CN=Default-First-Site-Name, ... */
614
615         /* ask for objectGUID of CN=NTDS Settings,CN=<DC>,CN=Servers,CN=Default-First-Site-Name, ... */
616
617         /* ask for * of CN=Default-First-Site-Name, ... */
618
619         /* search (&(|(objectClass=user)(objectClass=computer))(sAMAccountName=<machine_name>$)) in Domain Partition 
620          * attributes : distinguishedName, userAccountControl
621          */
622
623         /* ask * for CN=<machine_name>,CN=Servers,CN=Default-First-Site-Name,... 
624          * should fail with noSuchObject
625          */
626
627         /* add CN=<machine_name>,CN=Servers,CN=Default-First-Site-Name,... 
628          *
629          * objectClass = server
630          * systemFlags = 50000000
631          * serverReferenz = CN=<machine_name>,OU=Domain Controllers,...
632          */
633
634         /* ask for * of CN=NTDS Settings,CN=<machine_name>,CN=Servers,CN=Default-First-Site-Name, ...
635          * should fail with noSuchObject
636          */
637
638         /* search for (ncname=<domain_nc>) in CN=Partitions,CN=Configuration,... 
639          * attributes: ncName, dnsRoot
640          */
641
642         /* modify add CN=<machine_name>,CN=Servers,CN=Default-First-Site-Name,...
643          * serverReferenz = CN=<machine_name>,OU=Domain Controllers,...
644          * should fail with attributeOrValueExists
645          */
646
647         /* modify replace CN=<machine_name>,CN=Servers,CN=Default-First-Site-Name,...
648          * serverReferenz = CN=<machine_name>,OU=Domain Controllers,...
649          */
650
651         /* DsAddEntry to create the CN=NTDS Settings,CN=<machine_name>,CN=Servers,CN=Default-First-Site-Name, ...
652          *
653          */
654
655         /* replicate CN=Schema,CN=Configuration,...
656          * using DRSUAPI_DS_BIND_GUID_W2K ("6abec3d1-3054-41c8-a362-5a0c5b7d5d71")
657          *
658          */
659
660         /* replicate CN=Configuration,...
661          * using DRSUAPI_DS_BIND_GUID_W2K ("6abec3d1-3054-41c8-a362-5a0c5b7d5d71")
662          *
663          */
664
665         /* replicate Domain Partition
666          * using DRSUAPI_DS_BIND_GUID_W2K ("6abec3d1-3054-41c8-a362-5a0c5b7d5d71")
667          *
668          */
669
670         /* call DsReplicaUpdateRefs() for all partitions like this:
671          *     req1: struct drsuapi_DsReplicaUpdateRefsRequest1
672          *           naming_context           : *
673          *                 naming_context: struct drsuapi_DsReplicaObjectIdentifier
674          *                     __ndr_size               : 0x000000ae (174)
675          *                     __ndr_size_sid           : 0x00000000 (0)
676          *                     guid                     : 00000000-0000-0000-0000-000000000000
677          *                     sid                      : S-0-0
678          *                     dn                       : 'CN=Schema,CN=Configuration,DC=w2k3,DC=vmnet1,DC=vm,DC=base'
679          *           dest_dsa_dns_name        : *
680          *                 dest_dsa_dns_name        : '4a0df188-a0b8-47ea-bbe5-e614723f16dd._msdcs.w2k3.vmnet1.vm.base'
681          *           dest_dsa_guid            : 4a0df188-a0b8-47ea-bbe5-e614723f16dd
682          *           options                  : 0x0000001c (28)
683          *                 0: DRSUAPI_DS_REPLICA_UPDATE_ASYNCHRONOUS_OPERATION
684          *                 0: DRSUAPI_DS_REPLICA_UPDATE_WRITEABLE
685          *                 1: DRSUAPI_DS_REPLICA_UPDATE_ADD_REFERENCE
686          *                 1: DRSUAPI_DS_REPLICA_UPDATE_DELETE_REFERENCE
687          *                 1: DRSUAPI_DS_REPLICA_UPDATE_0x00000010      
688          *
689          * 4a0df188-a0b8-47ea-bbe5-e614723f16dd is the objectGUID the DsAddEntry() returned for the
690          * CN=NTDS Settings,CN=<machine_name>,CN=Servers,CN=Default-First-Site-Name, ...
691          */
692
693 /* W2K3: see libnet/libnet_become_dc.c */
694         return join;
695 }
696
697 #endif