summaryrefslogtreecommitdiff
path: root/source3/libnet
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-01-15 10:58:27 +0100
committerGünther Deschner <gd@samba.org>2008-01-15 11:02:56 +0100
commitf41cd6c8e46c6a280e61f77b0803133458274977 (patch)
treeb97b627a30dedc73504a1309cd316b2873fee429 /source3/libnet
parent0e8240f5a59d917723cfc6043f4f39172869857f (diff)
downloadsamba-f41cd6c8e46c6a280e61f77b0803133458274977.tar.gz
samba-f41cd6c8e46c6a280e61f77b0803133458274977.tar.bz2
samba-f41cd6c8e46c6a280e61f77b0803133458274977.zip
Use dsgetdcname() to find a dc when unjoining in libnetjoin.
Guenther (This used to be commit 1a5b72daa36073cc0604211248d869bf0d7546c6)
Diffstat (limited to 'source3/libnet')
-rw-r--r--source3/libnet/libnet_join.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c
index 19b3e58e00..6c50d9c09b 100644
--- a/source3/libnet/libnet_join.c
+++ b/source3/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,