2 Unix SMB/CIFS implementation.
4 Copyright (C) Stefan Metzmacher <metze@samba.org> 2006
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "libnet/libnet.h"
23 #include "libcli/composite/composite.h"
24 #include "libcli/cldap/cldap.h"
25 #include "lib/ldb/include/ldb.h"
26 #include "lib/ldb/include/ldb_errors.h"
27 #include "lib/db_wrap.h"
28 #include "dsdb/samdb/samdb.h"
29 #include "dsdb/common/flags.h"
30 #include "librpc/gen_ndr/ndr_drsuapi_c.h"
32 /*****************************************************************************
33 * Windows 2003 (w2k3) does the following steps when changing the server role
34 * from domain controller back to domain member
36 * We mostly do the same.
37 *****************************************************************************/
41 * - using nbt name<1C> request and a samlogon mailslot request
43 * - using a DNS SRV _ldap._tcp.dc._msdcs. request and a CLDAP netlogon request
45 * see: unbecomeDC_send_cldap() and unbecomeDC_recv_cldap()
49 * Open 1st LDAP connection to the DC using admin credentials
51 * see: unbecomeDC_ldap_connect()
55 * LDAP search 1st LDAP connection:
57 * see: unbecomeDC_ldap_rootdse()
62 * filter: (objectClass=*)
63 * attrs: defaultNamingContext
64 * configurationNamingContext
67 * defaultNamingContext: <domain_partition>
68 * configurationNamingContext:CN=Configuration,<domain_partition>
72 * LDAP search 1st LDAP connection:
74 * see: unbecomeDC_ldap_computer_object()
77 * basedn: <domain_partition>
79 * filter: (&(|(objectClass=user)(objectClass=computer))(sAMAccountName=<new_dc_account_name>))
80 * attrs: distinguishedName
83 * CN=<new_dc_netbios_name>,CN=Domain Controllers,<domain_partition>
84 * distinguishedName: CN=<new_dc_netbios_name>,CN=Domain Controllers,<domain_partition>
85 * userAccoountControl: 532480 <0x82000>
89 * LDAP search 1st LDAP connection:
91 * see: unbecomeDC_ldap_modify_computer()
94 * basedn: CN=<new_dc_netbios_name>,CN=Computers,<domain_partition>
96 * filter: (objectClass=*)
97 * attrs: userAccountControl
99 * CN=<new_dc_netbios_name>,CN=Computers,<domain_partition>
100 * userAccoountControl: 532480 <0x82000>
104 * LDAP modify 1st LDAP connection:
106 * see: unbecomeDC_ldap_modify_computer()
109 * CN=<new_dc_netbios_name>,CN=Computers,<domain_partition>
110 * userAccoountControl: 4096 <0x1000>
116 * LDAP search 1st LDAP connection:
118 * see: unbecomeDC_ldap_move_computer()
121 * basedn: <WKGUID=aa312825768811d1aded00c04fd8d5cd,<domain_partition>>
123 * filter: (objectClass=*)
126 * CN=Computers,<domain_partition>
130 * LDAP search 1st LDAP connection:
132 * not implemented because it doesn't give any new information
135 * basedn: CN=Computers,<domain_partition>
137 * filter: (objectClass=*)
138 * attrs: distinguishedName
140 * CN=Computers,<domain_partition>
141 * distinguishedName: CN=Computers,<domain_partition>
145 * LDAP modifyRDN 1st LDAP connection:
147 * see: unbecomeDC_ldap_move_computer()
150 * entry: CN=<new_dc_netbios_name>,CN=Domain Controllers,<domain_partition>
151 * newrdn: CN=<new_dc_netbios_name>
153 * newparent: CN=Computers,<domain_partition>
159 * LDAP unbind on the 1st LDAP connection
161 * not implemented, because it's not needed...
165 * Open 1st DRSUAPI connection to the DC using admin credentials
166 * DsBind with DRSUAPI_DS_BIND_GUID ("e24d201a-4fd6-11d1-a3da-0000f875ae0d")
168 * see: unbecomeDC_drsuapi_connect_send(), unbecomeDC_drsuapi_connect_recv(),
169 * unbecomeDC_drsuapi_bind_send() and unbecomeDC_drsuapi_bind_recv()
173 * DsRemoveDsServer to remove the
174 * CN=<machine_name>,CN=Servers,CN=<site_name>,CN=Configuration,<domain_partition>
175 * and CN=NTDS Settings,CN=<machine_name>,CN=Servers,CN=<site_name>,CN=Configuration,<domain_partition>
176 * on the 1st DRSUAPI connection
178 * see: unbecomeDC_drsuapi_remove_ds_server_send() and unbecomeDC_drsuapi_remove_ds_server_recv()
182 * DsUnbind on the 1st DRSUAPI connection
184 * not implemented, because it's not needed...
188 struct libnet_UnbecomeDC_state
{
189 struct composite_context
*creq
;
191 struct libnet_context
*libnet
;
194 struct cldap_socket
*sock
;
195 struct cldap_netlogon io
;
196 struct nbt_cldap_netlogon_5 netlogon5
;
200 struct ldb_context
*ldb
;
204 struct dcerpc_binding
*binding
;
205 struct dcerpc_pipe
*pipe
;
206 struct drsuapi_DsBind bind_r
;
207 struct GUID bind_guid
;
208 struct drsuapi_DsBindInfoCtr bind_info_ctr
;
209 struct drsuapi_DsBindInfo28 local_info28
;
210 struct drsuapi_DsBindInfo28 remote_info28
;
211 struct policy_handle bind_handle
;
212 struct drsuapi_DsRemoveDSServer rm_ds_srv_r
;
217 const char *dns_name
;
218 const char *netbios_name
;
227 const char *config_dn_str
;
235 const char *dns_name
;
236 const char *netbios_name
;
237 const char *site_name
;
242 const char *netbios_name
;
245 const char *dns_name
;
246 const char *site_name
;
247 const char *computer_dn_str
;
248 const char *server_dn_str
;
249 uint32_t user_account_control
;
253 static void unbecomeDC_recv_cldap(struct cldap_request
*req
);
255 static void unbecomeDC_send_cldap(struct libnet_UnbecomeDC_state
*s
)
257 struct composite_context
*c
= s
->creq
;
258 struct cldap_request
*req
;
260 s
->cldap
.io
.in
.dest_address
= s
->source_dsa
.address
;
261 s
->cldap
.io
.in
.realm
= s
->domain
.dns_name
;
262 s
->cldap
.io
.in
.host
= s
->dest_dsa
.netbios_name
;
263 s
->cldap
.io
.in
.user
= NULL
;
264 s
->cldap
.io
.in
.domain_guid
= NULL
;
265 s
->cldap
.io
.in
.domain_sid
= NULL
;
266 s
->cldap
.io
.in
.acct_control
= -1;
267 s
->cldap
.io
.in
.version
= 6;
269 s
->cldap
.sock
= cldap_socket_init(s
, s
->libnet
->event_ctx
);
270 if (composite_nomem(s
->cldap
.sock
, c
)) return;
272 req
= cldap_netlogon_send(s
->cldap
.sock
, &s
->cldap
.io
);
273 if (composite_nomem(req
, c
)) return;
274 req
->async
.fn
= unbecomeDC_recv_cldap
;
275 req
->async
.private = s
;
278 static void unbecomeDC_connect_ldap(struct libnet_UnbecomeDC_state
*s
);
280 static void unbecomeDC_recv_cldap(struct cldap_request
*req
)
282 struct libnet_UnbecomeDC_state
*s
= talloc_get_type(req
->async
.private,
283 struct libnet_UnbecomeDC_state
);
284 struct composite_context
*c
= s
->creq
;
286 c
->status
= cldap_netlogon_recv(req
, s
, &s
->cldap
.io
);
287 if (!composite_is_ok(c
)) return;
289 s
->cldap
.netlogon5
= s
->cldap
.io
.out
.netlogon
.logon5
;
291 s
->domain
.dns_name
= s
->cldap
.netlogon5
.dns_domain
;
292 s
->domain
.netbios_name
= s
->cldap
.netlogon5
.domain
;
293 s
->domain
.guid
= s
->cldap
.netlogon5
.domain_uuid
;
295 s
->source_dsa
.dns_name
= s
->cldap
.netlogon5
.pdc_dns_name
;
296 s
->source_dsa
.netbios_name
= s
->cldap
.netlogon5
.pdc_name
;
297 s
->source_dsa
.site_name
= s
->cldap
.netlogon5
.server_site
;
299 s
->dest_dsa
.site_name
= s
->cldap
.netlogon5
.client_site
;
301 unbecomeDC_connect_ldap(s
);
304 static NTSTATUS
unbecomeDC_ldap_connect(struct libnet_UnbecomeDC_state
*s
)
308 url
= talloc_asprintf(s
, "ldap://%s/", s
->source_dsa
.dns_name
);
309 NT_STATUS_HAVE_NO_MEMORY(url
);
311 s
->ldap
.ldb
= ldb_wrap_connect(s
, url
,
316 if (s
->ldap
.ldb
== NULL
) {
317 return NT_STATUS_UNEXPECTED_NETWORK_ERROR
;
323 static NTSTATUS
unbecomeDC_ldap_rootdse(struct libnet_UnbecomeDC_state
*s
)
326 struct ldb_result
*r
;
327 struct ldb_dn
*basedn
;
328 static const char *attrs
[] = {
329 "defaultNamingContext",
330 "configurationNamingContext",
334 basedn
= ldb_dn_new(s
, s
->ldap
.ldb
, NULL
);
335 NT_STATUS_HAVE_NO_MEMORY(basedn
);
337 ret
= ldb_search(s
->ldap
.ldb
, basedn
, LDB_SCOPE_BASE
,
338 "(objectClass=*)", attrs
, &r
);
340 if (ret
!= LDB_SUCCESS
) {
341 return NT_STATUS_LDAP(ret
);
342 } else if (r
->count
!= 1) {
344 return NT_STATUS_INVALID_NETWORK_RESPONSE
;
348 s
->domain
.dn_str
= ldb_msg_find_attr_as_string(r
->msgs
[0], "defaultNamingContext", NULL
);
349 if (!s
->domain
.dn_str
) return NT_STATUS_INVALID_NETWORK_RESPONSE
;
350 talloc_steal(s
, s
->domain
.dn_str
);
352 s
->forest
.config_dn_str
= ldb_msg_find_attr_as_string(r
->msgs
[0], "configurationNamingContext", NULL
);
353 if (!s
->forest
.config_dn_str
) return NT_STATUS_INVALID_NETWORK_RESPONSE
;
354 talloc_steal(s
, s
->forest
.config_dn_str
);
356 s
->dest_dsa
.server_dn_str
= talloc_asprintf(s
, "CN=%s,CN=Servers,CN=%s,CN=Sites,%s",
357 s
->dest_dsa
.netbios_name
,
358 s
->dest_dsa
.site_name
,
359 s
->forest
.config_dn_str
);
360 NT_STATUS_HAVE_NO_MEMORY(s
->dest_dsa
.server_dn_str
);
366 static NTSTATUS
unbecomeDC_ldap_computer_object(struct libnet_UnbecomeDC_state
*s
)
369 struct ldb_result
*r
;
370 struct ldb_dn
*basedn
;
372 static const char *attrs
[] = {
374 "userAccountControl",
378 basedn
= ldb_dn_new(s
, s
->ldap
.ldb
, s
->domain
.dn_str
);
379 NT_STATUS_HAVE_NO_MEMORY(basedn
);
381 filter
= talloc_asprintf(basedn
, "(&(|(objectClass=user)(objectClass=computer))(sAMAccountName=%s$))",
382 s
->dest_dsa
.netbios_name
);
383 NT_STATUS_HAVE_NO_MEMORY(filter
);
385 ret
= ldb_search(s
->ldap
.ldb
, basedn
, LDB_SCOPE_SUBTREE
,
388 if (ret
!= LDB_SUCCESS
) {
389 return NT_STATUS_LDAP(ret
);
390 } else if (r
->count
!= 1) {
392 return NT_STATUS_INVALID_NETWORK_RESPONSE
;
395 s
->dest_dsa
.computer_dn_str
= samdb_result_string(r
->msgs
[0], "distinguishedName", NULL
);
396 if (!s
->dest_dsa
.computer_dn_str
) return NT_STATUS_INVALID_NETWORK_RESPONSE
;
397 talloc_steal(s
, s
->dest_dsa
.computer_dn_str
);
399 s
->dest_dsa
.user_account_control
= samdb_result_uint(r
->msgs
[0], "userAccountControl", 0);
405 static NTSTATUS
unbecomeDC_ldap_modify_computer(struct libnet_UnbecomeDC_state
*s
)
408 struct ldb_message
*msg
;
409 uint32_t user_account_control
= UF_WORKSTATION_TRUST_ACCOUNT
;
412 /* as the value is already as we want it to be, we're done */
413 if (s
->dest_dsa
.user_account_control
== user_account_control
) {
417 /* make a 'modify' msg, and only for serverReference */
418 msg
= ldb_msg_new(s
);
419 NT_STATUS_HAVE_NO_MEMORY(msg
);
420 msg
->dn
= ldb_dn_new(msg
, s
->ldap
.ldb
, s
->dest_dsa
.computer_dn_str
);
421 NT_STATUS_HAVE_NO_MEMORY(msg
->dn
);
423 ret
= ldb_msg_add_fmt(msg
, "userAccountControl", "%u", user_account_control
);
426 return NT_STATUS_NO_MEMORY
;
429 /* mark all the message elements (should be just one)
430 as LDB_FLAG_MOD_REPLACE */
431 for (i
=0;i
<msg
->num_elements
;i
++) {
432 msg
->elements
[i
].flags
= LDB_FLAG_MOD_REPLACE
;
435 ret
= ldb_modify(s
->ldap
.ldb
, msg
);
437 if (ret
!= LDB_SUCCESS
) {
438 return NT_STATUS_LDAP(ret
);
441 s
->dest_dsa
.user_account_control
= user_account_control
;
446 static NTSTATUS
unbecomeDC_ldap_move_computer(struct libnet_UnbecomeDC_state
*s
)
449 struct ldb_result
*r
;
450 struct ldb_dn
*basedn
;
451 struct ldb_dn
*old_dn
;
452 struct ldb_dn
*new_dn
;
453 static const char *_1_1_attrs
[] = {
458 basedn
= ldb_dn_new_fmt(s
, s
->ldap
.ldb
, "<WKGUID=aa312825768811d1aded00c04fd8d5cd,%s>",
460 NT_STATUS_HAVE_NO_MEMORY(basedn
);
462 ret
= ldb_search(s
->ldap
.ldb
, basedn
, LDB_SCOPE_BASE
,
463 "(objectClass=*)", _1_1_attrs
, &r
);
465 if (ret
!= LDB_SUCCESS
) {
466 return NT_STATUS_LDAP(ret
);
467 } else if (r
->count
!= 1) {
469 return NT_STATUS_INVALID_NETWORK_RESPONSE
;
472 old_dn
= ldb_dn_new(r
, s
->ldap
.ldb
, s
->dest_dsa
.computer_dn_str
);
473 NT_STATUS_HAVE_NO_MEMORY(old_dn
);
475 new_dn
= r
->msgs
[0]->dn
;
477 if (!ldb_dn_add_child_fmt(new_dn
, "CN=%s", s
->dest_dsa
.netbios_name
)) {
479 return NT_STATUS_NO_MEMORY
;
482 if (ldb_dn_compare(old_dn
, new_dn
) == 0) {
483 /* we don't need to rename if the old and new dn match */
488 ret
= ldb_rename(s
->ldap
.ldb
, old_dn
, new_dn
);
489 if (ret
!= LDB_SUCCESS
) {
491 return NT_STATUS_LDAP(ret
);
494 s
->dest_dsa
.computer_dn_str
= ldb_dn_alloc_linearized(s
, new_dn
);
495 NT_STATUS_HAVE_NO_MEMORY(s
->dest_dsa
.computer_dn_str
);
502 static void unbecomeDC_drsuapi_connect_send(struct libnet_UnbecomeDC_state
*s
);
504 static void unbecomeDC_connect_ldap(struct libnet_UnbecomeDC_state
*s
)
506 struct composite_context
*c
= s
->creq
;
508 c
->status
= unbecomeDC_ldap_connect(s
);
509 if (!composite_is_ok(c
)) return;
511 c
->status
= unbecomeDC_ldap_rootdse(s
);
512 if (!composite_is_ok(c
)) return;
514 c
->status
= unbecomeDC_ldap_computer_object(s
);
515 if (!composite_is_ok(c
)) return;
517 c
->status
= unbecomeDC_ldap_modify_computer(s
);
518 if (!composite_is_ok(c
)) return;
520 c
->status
= unbecomeDC_ldap_move_computer(s
);
521 if (!composite_is_ok(c
)) return;
523 unbecomeDC_drsuapi_connect_send(s
);
526 static void unbecomeDC_drsuapi_connect_recv(struct composite_context
*creq
);
528 static void unbecomeDC_drsuapi_connect_send(struct libnet_UnbecomeDC_state
*s
)
530 struct composite_context
*c
= s
->creq
;
531 struct composite_context
*creq
;
534 binding_str
= talloc_asprintf(s
, "ncacn_ip_tcp:%s[seal]", s
->source_dsa
.dns_name
);
535 if (composite_nomem(binding_str
, c
)) return;
537 c
->status
= dcerpc_parse_binding(s
, binding_str
, &s
->drsuapi
.binding
);
538 talloc_free(binding_str
);
539 if (!composite_is_ok(c
)) return;
541 creq
= dcerpc_pipe_connect_b_send(s
, s
->drsuapi
.binding
, &dcerpc_table_drsuapi
,
542 s
->libnet
->cred
, s
->libnet
->event_ctx
);
543 composite_continue(c
, creq
, unbecomeDC_drsuapi_connect_recv
, s
);
546 static void unbecomeDC_drsuapi_bind_send(struct libnet_UnbecomeDC_state
*s
);
548 static void unbecomeDC_drsuapi_connect_recv(struct composite_context
*req
)
550 struct libnet_UnbecomeDC_state
*s
= talloc_get_type(req
->async
.private_data
,
551 struct libnet_UnbecomeDC_state
);
552 struct composite_context
*c
= s
->creq
;
554 c
->status
= dcerpc_pipe_connect_b_recv(req
, s
, &s
->drsuapi
.pipe
);
555 if (!composite_is_ok(c
)) return;
557 unbecomeDC_drsuapi_bind_send(s
);
560 static void unbecomeDC_drsuapi_bind_recv(struct rpc_request
*req
);
562 static void unbecomeDC_drsuapi_bind_send(struct libnet_UnbecomeDC_state
*s
)
564 struct composite_context
*c
= s
->creq
;
565 struct rpc_request
*req
;
566 struct drsuapi_DsBindInfo28
*bind_info28
;
568 GUID_from_string(DRSUAPI_DS_BIND_GUID
, &s
->drsuapi
.bind_guid
);
570 bind_info28
= &s
->drsuapi
.local_info28
;
571 bind_info28
->supported_extensions
= 0;
572 bind_info28
->site_guid
= GUID_zero();
573 bind_info28
->u1
= 508;
574 bind_info28
->repl_epoch
= 0;
576 s
->drsuapi
.bind_info_ctr
.length
= 28;
577 s
->drsuapi
.bind_info_ctr
.info
.info28
= *bind_info28
;
579 s
->drsuapi
.bind_r
.in
.bind_guid
= &s
->drsuapi
.bind_guid
;
580 s
->drsuapi
.bind_r
.in
.bind_info
= &s
->drsuapi
.bind_info_ctr
;
581 s
->drsuapi
.bind_r
.out
.bind_handle
= &s
->drsuapi
.bind_handle
;
583 req
= dcerpc_drsuapi_DsBind_send(s
->drsuapi
.pipe
, s
, &s
->drsuapi
.bind_r
);
584 composite_continue_rpc(c
, req
, unbecomeDC_drsuapi_bind_recv
, s
);
587 static void unbecomeDC_drsuapi_remove_ds_server_send(struct libnet_UnbecomeDC_state
*s
);
589 static void unbecomeDC_drsuapi_bind_recv(struct rpc_request
*req
)
591 struct libnet_UnbecomeDC_state
*s
= talloc_get_type(req
->async
.private,
592 struct libnet_UnbecomeDC_state
);
593 struct composite_context
*c
= s
->creq
;
595 c
->status
= dcerpc_ndr_request_recv(req
);
596 if (!composite_is_ok(c
)) return;
598 if (!W_ERROR_IS_OK(s
->drsuapi
.bind_r
.out
.result
)) {
599 composite_error(c
, werror_to_ntstatus(s
->drsuapi
.bind_r
.out
.result
));
603 ZERO_STRUCT(s
->drsuapi
.remote_info28
);
604 if (s
->drsuapi
.bind_r
.out
.bind_info
) {
605 switch (s
->drsuapi
.bind_r
.out
.bind_info
->length
) {
607 struct drsuapi_DsBindInfo24
*info24
;
608 info24
= &s
->drsuapi
.bind_r
.out
.bind_info
->info
.info24
;
609 s
->drsuapi
.remote_info28
.supported_extensions
= info24
->supported_extensions
;
610 s
->drsuapi
.remote_info28
.site_guid
= info24
->site_guid
;
611 s
->drsuapi
.remote_info28
.u1
= info24
->u1
;
612 s
->drsuapi
.remote_info28
.repl_epoch
= 0;
616 s
->drsuapi
.remote_info28
= s
->drsuapi
.bind_r
.out
.bind_info
->info
.info28
;
621 unbecomeDC_drsuapi_remove_ds_server_send(s
);
624 static void unbecomeDC_drsuapi_remove_ds_server_recv(struct rpc_request
*req
);
626 static void unbecomeDC_drsuapi_remove_ds_server_send(struct libnet_UnbecomeDC_state
*s
)
628 struct composite_context
*c
= s
->creq
;
629 struct rpc_request
*req
;
630 struct drsuapi_DsRemoveDSServer
*r
= &s
->drsuapi
.rm_ds_srv_r
;
632 r
->in
.bind_handle
= &s
->drsuapi
.bind_handle
;
634 r
->in
.req
.req1
.server_dn
= s
->dest_dsa
.server_dn_str
;
635 r
->in
.req
.req1
.domain_dn
= s
->domain
.dn_str
;
636 r
->in
.req
.req1
.unknown
= 0x00000001;
638 req
= dcerpc_drsuapi_DsRemoveDSServer_send(s
->drsuapi
.pipe
, s
, r
);
639 composite_continue_rpc(c
, req
, unbecomeDC_drsuapi_remove_ds_server_recv
, s
);
642 static void unbecomeDC_drsuapi_remove_ds_server_recv(struct rpc_request
*req
)
644 struct libnet_UnbecomeDC_state
*s
= talloc_get_type(req
->async
.private,
645 struct libnet_UnbecomeDC_state
);
646 struct composite_context
*c
= s
->creq
;
647 struct drsuapi_DsRemoveDSServer
*r
= &s
->drsuapi
.rm_ds_srv_r
;
649 c
->status
= dcerpc_ndr_request_recv(req
);
650 if (!composite_is_ok(c
)) return;
652 if (!W_ERROR_IS_OK(r
->out
.result
)) {
653 composite_error(c
, werror_to_ntstatus(r
->out
.result
));
657 if (r
->out
.level
!= 1) {
658 composite_error(c
, NT_STATUS_INVALID_NETWORK_RESPONSE
);
662 if (!W_ERROR_IS_OK(r
->out
.res
.res1
.status
)) {
663 composite_error(c
, werror_to_ntstatus(r
->out
.res
.res1
.status
));
670 struct composite_context
*libnet_UnbecomeDC_send(struct libnet_context
*ctx
, TALLOC_CTX
*mem_ctx
, struct libnet_UnbecomeDC
*r
)
672 struct composite_context
*c
;
673 struct libnet_UnbecomeDC_state
*s
;
676 c
= composite_create(mem_ctx
, ctx
->event_ctx
);
677 if (c
== NULL
) return NULL
;
679 s
= talloc_zero(c
, struct libnet_UnbecomeDC_state
);
680 if (composite_nomem(s
, c
)) return c
;
686 s
->domain
.dns_name
= talloc_strdup(s
, r
->in
.domain_dns_name
);
687 if (composite_nomem(s
->domain
.dns_name
, c
)) return c
;
688 s
->domain
.netbios_name
= talloc_strdup(s
, r
->in
.domain_netbios_name
);
689 if (composite_nomem(s
->domain
.netbios_name
, c
)) return c
;
691 /* Source DSA input */
692 s
->source_dsa
.address
= talloc_strdup(s
, r
->in
.source_dsa_address
);
693 if (composite_nomem(s
->source_dsa
.address
, c
)) return c
;
695 /* Destination DSA input */
696 s
->dest_dsa
.netbios_name
= talloc_strdup(s
, r
->in
.dest_dsa_netbios_name
);
697 if (composite_nomem(s
->dest_dsa
.netbios_name
, c
)) return c
;
699 /* Destination DSA dns_name construction */
700 tmp_name
= strlower_talloc(s
, s
->dest_dsa
.netbios_name
);
701 if (composite_nomem(tmp_name
, c
)) return c
;
702 s
->dest_dsa
.dns_name
= talloc_asprintf_append(tmp_name
, ".%s",
704 if (composite_nomem(s
->dest_dsa
.dns_name
, c
)) return c
;
706 unbecomeDC_send_cldap(s
);
710 NTSTATUS
libnet_UnbecomeDC_recv(struct composite_context
*c
, TALLOC_CTX
*mem_ctx
, struct libnet_UnbecomeDC
*r
)
714 status
= composite_wait(c
);
722 NTSTATUS
libnet_UnbecomeDC(struct libnet_context
*ctx
, TALLOC_CTX
*mem_ctx
, struct libnet_UnbecomeDC
*r
)
725 struct composite_context
*c
;
726 c
= libnet_UnbecomeDC_send(ctx
, mem_ctx
, r
);
727 status
= libnet_UnbecomeDC_recv(c
, mem_ctx
, r
);