From 3c382db3a3a5ccfd5348f39a79556f157f814e76 Mon Sep 17 00:00:00 2001 From: Jim McDonough Date: Fri, 26 Jun 2009 15:24:57 -0400 Subject: Don't use ads realm name for non-ads case. #6481 Also check that the connection to ads worked. --- source3/libnet/libnet_join.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'source3') diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 86d2a02fd3..6967ae9c8d 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -2033,17 +2033,21 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx, if (r->in.delete_machine_account) { ADS_STATUS ads_status; - libnet_unjoin_connect_ads(mem_ctx, r); - ads_status = libnet_unjoin_remove_machine_acct(mem_ctx, r); + ads_status = libnet_unjoin_connect_ads(mem_ctx, r); + if (ADS_ERR_OK(ads_status)) { + /* dirty hack */ + r->out.dns_domain_name = + talloc_strdup(mem_ctx, + r->in.ads->server.realm); + ads_status = + libnet_unjoin_remove_machine_acct(mem_ctx, r); + } if (!ADS_ERR_OK(ads_status)) { libnet_unjoin_set_error_string(mem_ctx, r, "failed to remove machine account from AD: %s", ads_errstr(ads_status)); } else { r->out.deleted_machine_account = true; - /* dirty hack */ - r->out.dns_domain_name = talloc_strdup(mem_ctx, - r->in.ads->server.realm); W_ERROR_HAVE_NO_MEMORY(r->out.dns_domain_name); libnet_join_unjoindomain_remove_secrets(mem_ctx, r); return WERR_OK; @@ -2066,8 +2070,6 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx, } r->out.disabled_machine_account = true; - r->out.dns_domain_name = talloc_strdup(mem_ctx, - r->in.ads->server.realm); } /* If disable succeeded or was not requested at all, we -- cgit