summaryrefslogtreecommitdiff
path: root/source3/libnet
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-03-28 14:13:27 +0100
committerGünther Deschner <gd@samba.org>2008-03-28 14:15:20 +0100
commit14b6e9d46bd6b7939acdf66f8c8bc043579d39a6 (patch)
treee479989332842c7946dbec89928266843414fde1 /source3/libnet
parented27b352effb87e4394f73decd30eaebf26b36a9 (diff)
downloadsamba-14b6e9d46bd6b7939acdf66f8c8bc043579d39a6.tar.gz
samba-14b6e9d46bd6b7939acdf66f8c8bc043579d39a6.tar.bz2
samba-14b6e9d46bd6b7939acdf66f8c8bc043579d39a6.zip
Add Support for DOMAIN\DCNAME syntax in libnetjoin.
This format is used by Windows to enforce joining to a specific DC. Guenther (This used to be commit cc654892c0d76dea001cd8f7bd6f50cf9e89e9c9)
Diffstat (limited to 'source3/libnet')
-rw-r--r--source3/libnet/libnet_join.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c
index 6d5449ff57..f55d558c01 100644
--- a/source3/libnet/libnet_join.c
+++ b/source3/libnet/libnet_join.c
@@ -1314,6 +1314,48 @@ static WERROR libnet_unjoin_config(struct libnet_UnjoinCtx *r)
/****************************************************************
****************************************************************/
+static bool libnet_parse_domain_dc(TALLOC_CTX *mem_ctx,
+ const char *domain_str,
+ const char **domain_p,
+ const char **dc_p)
+{
+ char *domain = NULL;
+ char *dc = NULL;
+ const char *p = NULL;
+
+ if (!domain_str || !domain_p || !dc_p) {
+ return false;
+ }
+
+ p = strchr_m(domain_str, '\\');
+
+ if (p != NULL) {
+ domain = talloc_strndup(mem_ctx, domain_str,
+ PTR_DIFF(p, domain_str));
+ dc = talloc_strdup(mem_ctx, p+1);
+ if (!dc) {
+ return false;
+ }
+ } else {
+ domain = talloc_strdup(mem_ctx, domain_str);
+ dc = NULL;
+ }
+ if (!domain) {
+ return false;
+ }
+
+ *domain_p = domain;
+
+ if (!*dc_p && dc) {
+ *dc_p = dc;
+ }
+
+ return true;
+}
+
+/****************************************************************
+****************************************************************/
+
static WERROR libnet_join_pre_processing(TALLOC_CTX *mem_ctx,
struct libnet_JoinCtx *r)
{
@@ -1323,6 +1365,14 @@ static WERROR libnet_join_pre_processing(TALLOC_CTX *mem_ctx,
return WERR_INVALID_PARAM;
}
+ if (!libnet_parse_domain_dc(mem_ctx, r->in.domain_name,
+ &r->in.domain_name,
+ &r->in.dc_name)) {
+ libnet_join_set_error_string(mem_ctx, r,
+ "Failed to parse domain name");
+ 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 "
@@ -1654,6 +1704,14 @@ static WERROR libnet_unjoin_pre_processing(TALLOC_CTX *mem_ctx,
return WERR_INVALID_PARAM;
}
+ if (!libnet_parse_domain_dc(mem_ctx, r->in.domain_name,
+ &r->in.domain_name,
+ &r->in.dc_name)) {
+ libnet_unjoin_set_error_string(mem_ctx, r,
+ "Failed to parse domain name");
+ 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 "