From: Günther Deschner Date: Tue, 15 Jan 2008 09:58:27 +0000 (+0100) Subject: Use dsgetdcname() to find a dc when unjoining in libnetjoin. X-Git-Tag: samba-3.2.0pre2~42^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1a5b72daa36073cc0604211248d869bf0d7546c6;p=thirdparty%2Fsamba.git Use dsgetdcname() to find a dc when unjoining in libnetjoin. Guenther --- diff --git a/source/libnet/libnet_join.c b/source/libnet/libnet_join.c index 19b3e58e00f..6c50d9c09b5 100644 --- a/source/libnet/libnet_join.c +++ b/source/libnet/libnet_join.c @@ -1250,6 +1250,29 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx, { NTSTATUS status; + if (!r->in.dc_name) { + struct DS_DOMAIN_CONTROLLER_INFO *info; + status = dsgetdcname(mem_ctx, + NULL, + r->in.domain_name, + NULL, + NULL, + DS_DIRECTORY_SERVICE_REQUIRED | + DS_WRITABLE_REQUIRED | + DS_RETURN_DNS_NAME, + &info); + if (!NT_STATUS_IS_OK(status)) { + libnet_unjoin_set_error_string(mem_ctx, r, + "failed to find DC: %s", + nt_errstr(status)); + return WERR_DOMAIN_CONTROLLER_NOT_FOUND; + } + + r->in.dc_name = talloc_strdup(mem_ctx, + info->domain_controller_name); + W_ERROR_HAVE_NO_MEMORY(r->in.dc_name); + } + status = libnet_join_unjoindomain_rpc(mem_ctx, r); if (!NT_STATUS_IS_OK(status)) { libnet_unjoin_set_error_string(mem_ctx, r,