diff options
author | Günther Deschner <gd@samba.org> | 2008-01-12 02:22:44 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2008-01-12 02:25:57 +0100 |
commit | afb163efb76da39aa24f2c71be44ac50419dd27d (patch) | |
tree | 77fa2c8b054b57743fdfceef171236583421f589 /source3/libnet | |
parent | d4e5cadc1a9917190819bdebd0c14e8f3767503c (diff) | |
download | samba-afb163efb76da39aa24f2c71be44ac50419dd27d.tar.gz samba-afb163efb76da39aa24f2c71be44ac50419dd27d.tar.bz2 samba-afb163efb76da39aa24f2c71be44ac50419dd27d.zip |
Call dsgetdcname when we have no specific dc defined for joining.
Guenther
(This used to be commit 40e8caa2d81168be3e48ececf5746d8f659a96d6)
Diffstat (limited to 'source3/libnet')
-rw-r--r-- | source3/libnet/libnet_join.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index a46b827257..6ec89de15c 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -1064,12 +1064,39 @@ static WERROR libnet_DomainJoin(TALLOC_CTX *mem_ctx, NTSTATUS status; #ifdef WITH_ADS ADS_STATUS ads_status; +#endif /* WITH_ADS */ + 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_join_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); + } + +#ifdef WITH_ADS if (r->in.account_ou) { + ads_status = libnet_join_connect_ads(mem_ctx, r); if (!ADS_ERR_OK(ads_status)) { return WERR_DEFAULT_JOIN_REQUIRED; } + ads_status = libnet_join_precreate_machine_acct(mem_ctx, r); if (!ADS_ERR_OK(ads_status)) { libnet_join_set_error_string(mem_ctx, r, |