1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

Use dsgetdcname() to find a dc when unjoining in libnetjoin.

Guenther
(This used to be commit 1a5b72daa3)
This commit is contained in:
Günther Deschner 2008-01-15 10:58:27 +01:00
parent 0e8240f5a5
commit f41cd6c8e4

View File

@ -1250,6 +1250,29 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx,
{ {
NTSTATUS status; 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); status = libnet_join_unjoindomain_rpc(mem_ctx, r);
if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status)) {
libnet_unjoin_set_error_string(mem_ctx, r, libnet_unjoin_set_error_string(mem_ctx, r,