From ae1e1085a1c6e2a3f1a2821cd22a6caed63d3b05 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 14 Apr 2008 23:07:55 +0200 Subject: libnetjoin/net: Fix lp_config_backend_is_registry() handling. Thanks obnox, now we can net ads join and net ads leave with zero configuration changes if "config backend = registry". Guenther (This used to be commit 9003881773de787a51ceadcdc2cb1e95f6979763) --- source3/libnet/libnet_join.c | 70 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 14 deletions(-) (limited to 'source3/libnet') diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 90cb64c5d6..16a7ea4566 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -1414,13 +1414,6 @@ static WERROR libnet_join_pre_processing(TALLOC_CTX *mem_ctx, return WERR_INVALID_PARAM; } - if (r->in.modify_config && !lp_config_backend_is_registry()) { - libnet_join_set_error_string(mem_ctx, r, - "Configuration manipulation requested but not " - "supported by backend"); - return WERR_NOT_SUPPORTED; - } - if (IS_DC) { return WERR_SETUP_DOMAIN_CONTROLLER; } @@ -1564,6 +1557,57 @@ WERROR libnet_init_UnjoinCtx(TALLOC_CTX *mem_ctx, /**************************************************************** ****************************************************************/ +static WERROR libnet_join_check_config(TALLOC_CTX *mem_ctx, + struct libnet_JoinCtx *r) +{ + /* check if configuration is already set correctly */ + + switch (r->out.domain_is_ad) { + case false: + if ((strequal(lp_workgroup(), + r->out.netbios_domain_name)) && + (lp_security() == SEC_DOMAIN)) { + /* nothing to be done */ + return WERR_OK; + } + break; + case true: + if ((strequal(lp_workgroup(), + r->out.netbios_domain_name)) && + (strequal(lp_realm(), + r->out.dns_domain_name)) && + ((lp_security() == SEC_ADS) || + (lp_security() == SEC_DOMAIN))) { + /* nothing to be done */ + return WERR_OK; + } + break; + } + + /* check if we are supposed to manipulate configuration */ + + if (!r->in.modify_config) { + libnet_join_set_error_string(mem_ctx, r, + "Invalid configuration and configuration modification " + "was not requested"); + return WERR_CAN_NOT_COMPLETE; + } + + /* check if we are able to manipulate configuration */ + + if (!lp_config_backend_is_registry()) { + libnet_join_set_error_string(mem_ctx, r, + "Configuration manipulation requested but not " + "supported by backend"); + return WERR_NOT_SUPPORTED; + } + + return WERR_OK; +} + +/**************************************************************** +****************************************************************/ + static WERROR libnet_DomainJoin(TALLOC_CTX *mem_ctx, struct libnet_JoinCtx *r) { @@ -1626,6 +1670,11 @@ static WERROR libnet_DomainJoin(TALLOC_CTX *mem_ctx, return ntstatus_to_werror(status); } + werr = libnet_join_check_config(mem_ctx, r); + if (!W_ERROR_IS_OK(werr)) { + goto done; + } + status = libnet_join_joindomain_rpc(mem_ctx, r, cli); if (!NT_STATUS_IS_OK(status)) { libnet_join_set_error_string(mem_ctx, r, @@ -1804,13 +1853,6 @@ static WERROR libnet_unjoin_pre_processing(TALLOC_CTX *mem_ctx, return WERR_INVALID_PARAM; } - if (r->in.modify_config && !lp_config_backend_is_registry()) { - libnet_unjoin_set_error_string(mem_ctx, r, - "Configuration manipulation requested but not " - "supported by backend"); - return WERR_NOT_SUPPORTED; - } - if (IS_DC) { return WERR_SETUP_DOMAIN_CONTROLLER; } -- cgit