From 335a277662d28b935c9d84a3d7a98276afdffd3e Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 13 Jan 2005 07:50:09 +0000 Subject: r4722: Start to add 'net join' to Samba4. Andrew Bartlett (This used to be commit a9b960609142e15ba5950eb1b22944eb6df18d9c) --- source4/utils/net/net_join.c | 108 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 source4/utils/net/net_join.c (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c new file mode 100644 index 0000000000..81e795a3ce --- /dev/null +++ b/source4/utils/net/net_join.c @@ -0,0 +1,108 @@ +/* + Samba Unix/Linux SMB client library + Distributed SMB/CIFS Server Management Utility + + Copyright (C) 2004 Stefan Metzmacher (metze@samba.org) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "utils/net/net.h" +#include "libnet/libnet.h" +#include "librpc/gen_ndr/ndr_samr.h" + +static int net_join_domain(struct net_context *ctx, int argc, const char **argv) +{ + NTSTATUS status; + struct libnet_context *libnetctx; + union libnet_JoinDomain r; + char *tmp; + const char *domain_name; + + switch (argc) { + case 0: /* no args -> fail */ + DEBUG(0,("net_join_domain: no args\n")); + return -1; + case 1: /* only DOMAIN */ + tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + break; + default: /* too mayn args -> fail */ + DEBUG(0,("net_join_domain: too many args [%d]\n",argc)); + return -1; + } + + domain_name = tmp; + + libnetctx = libnet_context_init(); + if (!libnetctx) { + return -1; + } + libnetctx->user.account_name = ctx->user.account_name; + libnetctx->user.domain_name = ctx->user.domain_name; + libnetctx->user.password = ctx->user.password; + + /* prepare password change */ + r.generic.level = LIBNET_JOIN_DOMAIN_GENERIC; + r.generic.in.domain_name = domain_name; + r.generic.in.account_name = talloc_asprintf(ctx->mem_ctx, "%s$", lp_netbios_name()); + r.generic.in.acct_type = ACB_SVRTRUST; + + /* do the domain join */ + status = libnet_JoinDomain(libnetctx, ctx->mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("net_join_domain: %s\n",r.generic.out.error_string)); + return -1; + } + + libnet_context_destroy(&libnetctx); + + return 0; +} + +static int net_join_domain_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_join_domain_usage: TODO\n"); + return 0; +} + +static int net_join_domain_help(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_join_domain_help: TODO\n"); + return 0; +} + +static const struct net_functable net_password_functable[] = { + {"domain", net_join_domain, net_join_domain_usage, net_join_domain_help}, + {NULL, NULL} +}; + +int net_join(struct net_context *ctx, int argc, const char **argv) +{ + + return net_run_function(ctx, argc, argv, net_password_functable, net_password_usage); +} + +int net_join_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_password_usage: TODO\n"); + return 0; +} + +int net_join_help(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_password_help: TODO\n"); + return 0; +} -- cgit From 8799d6b44c15a5e11c1e3528092fbca236561253 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 15 Jan 2005 22:13:18 +0000 Subject: r4762: Store the results of a 'net join' in the LDB. Like Samba3, the storage of the primary domain password is keyed off the domain name, so we can join multiple domains, and just swap 'workgroup =' around. Andrew Bartlett (This used to be commit 54a231780e028c6433cac296f2fbc64e39632dfd) --- source4/utils/net/net_join.c | 61 ++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 34 deletions(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 81e795a3ce..b88c11023e 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -2,7 +2,8 @@ Samba Unix/Linux SMB client library Distributed SMB/CIFS Server Management Utility - Copyright (C) 2004 Stefan Metzmacher (metze@samba.org) + Copyright (C) 2004 Stefan Metzmacher + Copyright (C) 2005 Andrew Bartlett This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,13 +25,15 @@ #include "libnet/libnet.h" #include "librpc/gen_ndr/ndr_samr.h" -static int net_join_domain(struct net_context *ctx, int argc, const char **argv) +int net_join(struct net_context *ctx, int argc, const char **argv) { + NTSTATUS status; struct libnet_context *libnetctx; - union libnet_JoinDomain r; + union libnet_Join r; char *tmp; const char *domain_name; + enum netr_SchannelType secure_channel_type = SEC_CHAN_WKSTA; switch (argc) { case 0: /* no args -> fail */ @@ -39,8 +42,19 @@ static int net_join_domain(struct net_context *ctx, int argc, const char **argv) case 1: /* only DOMAIN */ tmp = talloc_strdup(ctx->mem_ctx, argv[0]); break; - default: /* too mayn args -> fail */ - DEBUG(0,("net_join_domain: too many args [%d]\n",argc)); + case 2: /* DOMAIN and role */ + tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + if (strcasecmp(argv[1], "BDC") == 0) { + secure_channel_type = SEC_CHAN_BDC; + } else if (strcasecmp(argv[1], "MEMBER") == 0) { + secure_channel_type = SEC_CHAN_WKSTA; + } else { + DEBUG(0, ("net_join: 2nd argument must be MEMBER or BDC\n")); + return -1; + } + break; + default: /* too many args -> fail */ + DEBUG(0,("net_join: too many args [%d]\n",argc)); return -1; } @@ -55,15 +69,17 @@ static int net_join_domain(struct net_context *ctx, int argc, const char **argv) libnetctx->user.password = ctx->user.password; /* prepare password change */ - r.generic.level = LIBNET_JOIN_DOMAIN_GENERIC; - r.generic.in.domain_name = domain_name; - r.generic.in.account_name = talloc_asprintf(ctx->mem_ctx, "%s$", lp_netbios_name()); - r.generic.in.acct_type = ACB_SVRTRUST; + r.generic.level = LIBNET_JOIN_GENERIC; + r.generic.in.domain_name = domain_name; + r.generic.in.secure_channel_type = secure_channel_type; + r.generic.out.error_string = NULL; /* do the domain join */ - status = libnet_JoinDomain(libnetctx, ctx->mem_ctx, &r); + status = libnet_Join(libnetctx, ctx->mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - DEBUG(0,("net_join_domain: %s\n",r.generic.out.error_string)); + DEBUG(0,("libnet_Join returned %s: %s\n", + nt_errstr(status), + r.generic.out.error_string)); return -1; } @@ -72,29 +88,6 @@ static int net_join_domain(struct net_context *ctx, int argc, const char **argv) return 0; } -static int net_join_domain_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net_join_domain_usage: TODO\n"); - return 0; -} - -static int net_join_domain_help(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net_join_domain_help: TODO\n"); - return 0; -} - -static const struct net_functable net_password_functable[] = { - {"domain", net_join_domain, net_join_domain_usage, net_join_domain_help}, - {NULL, NULL} -}; - -int net_join(struct net_context *ctx, int argc, const char **argv) -{ - - return net_run_function(ctx, argc, argv, net_password_functable, net_password_usage); -} - int net_join_usage(struct net_context *ctx, int argc, const char **argv) { d_printf("net_password_usage: TODO\n"); -- cgit From 1ad9bed79de62bc5a29fe4c3193b1cc0b78def0e Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Mon, 14 Feb 2005 00:58:30 +0000 Subject: r5380: Removed extra newline. rafal (This used to be commit d8fa9baf24852d87fcffee8bf353604b4507683d) --- source4/utils/net/net_join.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index b88c11023e..cb093ef9ff 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -27,7 +27,6 @@ int net_join(struct net_context *ctx, int argc, const char **argv) { - NTSTATUS status; struct libnet_context *libnetctx; union libnet_Join r; -- cgit From 530d46f6748a17ca8500a861f53c0d4f451b2005 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Tue, 15 Feb 2005 01:11:20 +0000 Subject: r5400: Slightly better handling of help messages in net tool. rafal (This used to be commit 5cebb4feedf7d6542c497fe55763d66f51b1c989) --- source4/utils/net/net_join.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index cb093ef9ff..6183da87b5 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -36,8 +36,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) switch (argc) { case 0: /* no args -> fail */ - DEBUG(0,("net_join_domain: no args\n")); - return -1; + return net_join_usage(ctx, argc, argv); case 1: /* only DOMAIN */ tmp = talloc_strdup(ctx->mem_ctx, argv[0]); break; @@ -49,12 +48,11 @@ int net_join(struct net_context *ctx, int argc, const char **argv) secure_channel_type = SEC_CHAN_WKSTA; } else { DEBUG(0, ("net_join: 2nd argument must be MEMBER or BDC\n")); - return -1; + return net_join_usage(ctx, argc, argv); } break; default: /* too many args -> fail */ - DEBUG(0,("net_join: too many args [%d]\n",argc)); - return -1; + return net_join_usage(ctx, argc, argv); } domain_name = tmp; @@ -89,12 +87,12 @@ int net_join(struct net_context *ctx, int argc, const char **argv) int net_join_usage(struct net_context *ctx, int argc, const char **argv) { - d_printf("net_password_usage: TODO\n"); + d_printf("net join [BDC | MEMBER] [options]\n"); return 0; } int net_join_help(struct net_context *ctx, int argc, const char **argv) { - d_printf("net_password_help: TODO\n"); + d_printf("Joins domain as either member or backup domain controller.\n"); return 0; } -- cgit From 02075be0bbc2095073f8898350fded64a7c97c79 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 21 Mar 2005 02:08:38 +0000 Subject: r5917: First step in using the new cli_credentials structure. This patch puts support for it into popt_common, adds a few utility functions (in lib/credentials.c) and the callback functions for the command-line (lib/cmdline/credentials.c). Comments are welcome :-) (This used to be commit 1d49b57c50fe8c2683ea23e9df41ce8ad774db98) --- source4/utils/net/net_join.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 6183da87b5..3a0a52cab5 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -61,9 +61,9 @@ int net_join(struct net_context *ctx, int argc, const char **argv) if (!libnetctx) { return -1; } - libnetctx->user.account_name = ctx->user.account_name; - libnetctx->user.domain_name = ctx->user.domain_name; - libnetctx->user.password = ctx->user.password; + libnetctx->user.account_name= cli_credentials_get_username(ctx->credentials); + libnetctx->user.domain_name = cli_credentials_get_domain(ctx->credentials); + libnetctx->user.password = cli_credentials_get_password(ctx->credentials); /* prepare password change */ r.generic.level = LIBNET_JOIN_GENERIC; -- cgit From 34cde065139fdc76f6aa529426cfc1f68a394d54 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 21 Mar 2005 18:42:32 +0000 Subject: r5924: Use cli_credentials in libnet/. (This used to be commit e5bc6f4f1716568ae7022d61b5b35ee047b58414) --- source4/utils/net/net_join.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 3a0a52cab5..212b8270ff 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -61,9 +61,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) if (!libnetctx) { return -1; } - libnetctx->user.account_name= cli_credentials_get_username(ctx->credentials); - libnetctx->user.domain_name = cli_credentials_get_domain(ctx->credentials); - libnetctx->user.password = cli_credentials_get_password(ctx->credentials); + libnetctx->credentials = ctx->credentials; /* prepare password change */ r.generic.level = LIBNET_JOIN_GENERIC; -- cgit From 0a40093ef39a46b9df82d6d0486b70b354d9dde5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 3 Jun 2005 21:30:07 +0000 Subject: r7249: Cope with struct member rename (This used to be commit e7549f33f5fb06d8b2a8f31745545cc7b9c8d4f9) --- source4/utils/net/net_join.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 212b8270ff..717a9364a5 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -61,7 +61,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) if (!libnetctx) { return -1; } - libnetctx->credentials = ctx->credentials; + libnetctx->cred = ctx->credentials; /* prepare password change */ r.generic.level = LIBNET_JOIN_GENERIC; -- cgit From af237084ecd4f9928c6c282b9c5c73598d5c73d6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 16 Jun 2005 11:36:09 +0000 Subject: r7633: this patch started as an attempt to make the dcerpc code use a given event_context for the socket_connect() call, so that when things that use dcerpc are running alongside anything else it doesn't block the whole process during a connect. Then of course I needed to change any code that created a dcerpc connection (such as the auth code) to also take an event context, and anything that called that and so on .... thus the size of the patch. There were 3 places where I punted: - abartlet wanted me to add a gensec_set_event_context() call instead of adding it to the gensec init calls. Andrew, my apologies for not doing this. I didn't do it as adding a new parameter allowed me to catch all the callers with the compiler. Now that its done, we could go back and use gensec_set_event_context() - the ejs code calls auth initialisation, which means it should pass in the event context from the web server. I punted on that. Needs fixing. - I used a NULL event context in dcom_get_pipe(). This is equivalent to what we did already, but should be fixed to use a callers event context. Jelmer, can you think of a clean way to do that? I also cleaned up a couple of things: - libnet_context_destroy() makes no sense. I removed it. - removed some unused vars in various places (This used to be commit 3a3025485bdb8f600ab528c0b4b4eef0c65e3fc9) --- source4/utils/net/net_join.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 717a9364a5..7f9ab0c635 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -57,7 +57,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) domain_name = tmp; - libnetctx = libnet_context_init(); + libnetctx = libnet_context_init(NULL); if (!libnetctx) { return -1; } @@ -78,7 +78,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) return -1; } - libnet_context_destroy(&libnetctx); + talloc_free(libnetctx); return 0; } -- cgit From 6cec8025b05595d60c23d70f34db9e65ca21b89d Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 29 Jul 2005 10:58:05 +0000 Subject: r8847: Rework the Samba4 'net join' code. I'm trying to get this closer to what WinXP does when joining an AD domain, but in the meantime this removes the excess unions, and uses the LSA pipe in same way XP does. Andrew Bartlett (This used to be commit d2789c426090c325f6535cdce380ac0f4e22c3c7) --- source4/utils/net/net_join.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 7f9ab0c635..a1455ef036 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -29,7 +29,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) { NTSTATUS status; struct libnet_context *libnetctx; - union libnet_Join r; + struct libnet_Join r; char *tmp; const char *domain_name; enum netr_SchannelType secure_channel_type = SEC_CHAN_WKSTA; @@ -64,17 +64,16 @@ int net_join(struct net_context *ctx, int argc, const char **argv) libnetctx->cred = ctx->credentials; /* prepare password change */ - r.generic.level = LIBNET_JOIN_GENERIC; - r.generic.in.domain_name = domain_name; - r.generic.in.secure_channel_type = secure_channel_type; - r.generic.out.error_string = NULL; + r.in.domain_name = domain_name; + r.in.secure_channel_type = secure_channel_type; + r.out.error_string = NULL; /* do the domain join */ status = libnet_Join(libnetctx, ctx->mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("libnet_Join returned %s: %s\n", nt_errstr(status), - r.generic.out.error_string)); + r.out.error_string)); return -1; } -- cgit From 5a522b31003d50cf476ead83fb322abeb1525957 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sun, 25 Sep 2005 12:26:07 +0000 Subject: r10486: This is a merge of Brad Henry's 'net join' rework, to better perform an ADS join, particularly as a DC. This represents the bulk of his Google SOC work, and I'm very pleased to intergrate it into the tree. (Metze will intergrate the DRSUAPI work later). Both metze and myself have also put a lot of time into this patch, and in mentoring Brad in general. In return, Brad has been a very good student, and has taken the comments well. Since it's last appearance on samba-technical@, I have made correctness and valgrind fixups, as well as adding a new 'BINDING' mode to the libnet_rpc routines. This allows the exact binding string to be passed down from the torture code, including options and exact target host. Andrew Bartlett (This used to be commit d6fa105fdabbeb83a9b0e50dad49d1649afdb2a4) --- source4/utils/net/net_join.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index a1455ef036..cb2ed3006b 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -29,7 +29,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) { NTSTATUS status; struct libnet_context *libnetctx; - struct libnet_Join r; + struct libnet_Join *r; char *tmp; const char *domain_name; enum netr_SchannelType secure_channel_type = SEC_CHAN_WKSTA; @@ -62,23 +62,29 @@ int net_join(struct net_context *ctx, int argc, const char **argv) return -1; } libnetctx->cred = ctx->credentials; - + r = talloc(ctx->mem_ctx, struct libnet_Join); + if (!r) { + return -1; + } /* prepare password change */ - r.in.domain_name = domain_name; - r.in.secure_channel_type = secure_channel_type; - r.out.error_string = NULL; + r->in.netbios_name = lp_netbios_name(); + r->in.domain_name = domain_name; + r->in.secure_channel_type = secure_channel_type; + r->in.level = LIBNET_JOIN_AUTOMATIC; + r->out.error_string = NULL; /* do the domain join */ - status = libnet_Join(libnetctx, ctx->mem_ctx, &r); + status = libnet_Join(libnetctx, r, r); + if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("libnet_Join returned %s: %s\n", nt_errstr(status), - r.out.error_string)); + r->out.error_string)); + talloc_free(r); + talloc_free(libnetctx); return -1; } - talloc_free(libnetctx); - return 0; } -- cgit From c690be462d6dcfc8bdad6749ae055f11d810c89f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 4 Oct 2005 12:02:52 +0000 Subject: r10711: An error of 'user exists' is not an error, just an indication of how the join was processed. Andrew Bartlett (This used to be commit 0d93f11c894927a9ab69f7a31b9fbedde9d698b6) --- source4/utils/net/net_join.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index cb2ed3006b..8e9eb4d93e 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -76,7 +76,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) /* do the domain join */ status = libnet_Join(libnetctx, r, r); - if (!NT_STATUS_IS_OK(status)) { + if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { DEBUG(0,("libnet_Join returned %s: %s\n", nt_errstr(status), r->out.error_string)); -- cgit From 8e0948bbad959f8809a19e40e6777705013f866c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 22 Dec 2005 06:47:00 +0000 Subject: r12421: Handle the case where we are a joining as different account types far better. Andrew Bartlett (This used to be commit 0ce82e8a41f0fdea9928e3e341680232cc640e18) --- source4/utils/net/net_join.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 8e9eb4d93e..bec82c72d1 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -76,10 +76,9 @@ int net_join(struct net_context *ctx, int argc, const char **argv) /* do the domain join */ status = libnet_Join(libnetctx, r, r); - if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { - DEBUG(0,("libnet_Join returned %s: %s\n", - nt_errstr(status), - r->out.error_string)); + if (!NT_STATUS_IS_OK(status)) { + d_printf("Joining domain failed: %s\n", + r->out.error_string ? r->out.error_string : nt_errstr(status)); talloc_free(r); talloc_free(libnetctx); return -1; -- cgit From 758873b9fb46c0c0059a95c6bdeb23b17f2c80c9 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 22 Dec 2005 06:58:26 +0000 Subject: r12423: Remove DEBUG(0) printouts in favor of more information to the caller. I assume this works better with SWAT and the like anyway. Andrew Bartlett (This used to be commit b11975703d5e32f6f3ad10079106b1345fa56b5c) --- source4/utils/net/net_join.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index bec82c72d1..8140108ceb 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -66,7 +66,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) if (!r) { return -1; } - /* prepare password change */ + /* prepare parameters for the join */ r->in.netbios_name = lp_netbios_name(); r->in.domain_name = domain_name; r->in.secure_channel_type = secure_channel_type; @@ -83,6 +83,8 @@ int net_join(struct net_context *ctx, int argc, const char **argv) talloc_free(libnetctx); return -1; } + d_printf("Joined domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx->mem_ctx, r->out.domain_sid)); + talloc_free(libnetctx); return 0; } -- cgit From d4de4c2d210d2e8c9b5aedf70695594809ad6a0b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 13:16:54 +0000 Subject: r12608: Remove some unused #include lines. (This used to be commit 70e7449318aa0e9d2639c76730a7d1683b2f4981) --- source4/utils/net/net_join.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 8140108ceb..eaa53f4c7b 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -23,7 +23,6 @@ #include "includes.h" #include "utils/net/net.h" #include "libnet/libnet.h" -#include "librpc/gen_ndr/ndr_samr.h" int net_join(struct net_context *ctx, int argc, const char **argv) { -- cgit From d790d8d6edbb7744cc6d3f7ca33e05a358038a42 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 13 Jan 2006 02:58:35 +0000 Subject: r12886: Rename 'secure_channel_type' parameter to domain join as 'join_type'. Andrew Bartlett (This used to be commit a3b3e09a9acc66dff7baf1a4ba0ea913bccdbd7d) --- source4/utils/net/net_join.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index eaa53f4c7b..407de6e89d 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -68,7 +68,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) /* prepare parameters for the join */ r->in.netbios_name = lp_netbios_name(); r->in.domain_name = domain_name; - r->in.secure_channel_type = secure_channel_type; + r->in.join_type = secure_channel_type; r->in.level = LIBNET_JOIN_AUTOMATIC; r->out.error_string = NULL; -- cgit From 05ea1558586438fb3a1865ce402cb4502de9dd49 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 26 Jan 2006 01:59:07 +0000 Subject: r13149: DEBUG is a bad choice for 'net', it should print to stderr Andrew Bartlett (This used to be commit 4dd6afa6d167fd04c1c3d4b4529b1cecf27eacaa) --- source4/utils/net/net_join.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 407de6e89d..9463b88dd7 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -46,7 +46,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) } else if (strcasecmp(argv[1], "MEMBER") == 0) { secure_channel_type = SEC_CHAN_WKSTA; } else { - DEBUG(0, ("net_join: 2nd argument must be MEMBER or BDC\n")); + d_fprintf(stderr, "net_join: 2nd argument must be MEMBER or BDC\n"); return net_join_usage(ctx, argc, argv); } break; @@ -76,8 +76,8 @@ int net_join(struct net_context *ctx, int argc, const char **argv) status = libnet_Join(libnetctx, r, r); if (!NT_STATUS_IS_OK(status)) { - d_printf("Joining domain failed: %s\n", - r->out.error_string ? r->out.error_string : nt_errstr(status)); + d_fprintf(stderr, "Joining domain failed: %s\n", + r->out.error_string ? r->out.error_string : nt_errstr(status)); talloc_free(r); talloc_free(libnetctx); return -1; -- cgit From 8528016978b084213ef53d66e1b6e831b1a01acc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 16 Mar 2006 00:23:11 +0000 Subject: r14464: Don't include ndr_BASENAME.h files unless strictly required, instead try to include just the BASENAME.h files (containing only structs) (This used to be commit 3dd477ca5147f28a962b8437e2611a8222d706bd) --- source4/utils/net/net_join.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 9463b88dd7..e94794db16 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -23,6 +23,7 @@ #include "includes.h" #include "utils/net/net.h" #include "libnet/libnet.h" +#include "librpc/gen_ndr/ndr_security.h" int net_join(struct net_context *ctx, int argc, const char **argv) { -- cgit From e002300f238dd0937dd9f768e366c006945e8baa Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 29 Apr 2006 17:34:49 +0000 Subject: r15328: Move some functions around, remove dependencies. Remove some autogenerated headers (which had prototypes now autogenerated by pidl) Remove ndr_security.h from a few places - it's no longer necessary (This used to be commit c19c2b51d3e1ad347120b06a22bda5ec586c22e8) --- source4/utils/net/net_join.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index e94794db16..2df57e63cc 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -23,7 +23,7 @@ #include "includes.h" #include "utils/net/net.h" #include "libnet/libnet.h" -#include "librpc/gen_ndr/ndr_security.h" +#include "libcli/security/security.h" int net_join(struct net_context *ctx, int argc, const char **argv) { -- cgit From 5bfc0d63170521ad8d451ffcfbb30ee5b140dfbb Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 23 Oct 2006 06:05:41 +0000 Subject: r19463: Make it clear what argument is incorrect Andrew Bartlett (This used to be commit a28a17c50853ccd4d7b2122497d3d18f0a6feed9) --- source4/utils/net/net_join.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 2df57e63cc..0495e9850f 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -47,7 +47,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) } else if (strcasecmp(argv[1], "MEMBER") == 0) { secure_channel_type = SEC_CHAN_WKSTA; } else { - d_fprintf(stderr, "net_join: 2nd argument must be MEMBER or BDC\n"); + d_fprintf(stderr, "net_join: Invalid 2nd argument (%s) must be MEMBER or BDC\n", argv[1]); return net_join_usage(ctx, argc, argv); } break; -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/utils/net/net_join.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 0495e9850f..98bf19d234 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -7,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,8 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From ffeee68e4b72dd94fee57366bd8d38b8c284c3d4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 8 Sep 2007 12:42:09 +0000 Subject: r25026: Move param/param.h out of includes.h (This used to be commit abe8349f9b4387961ff3665d8c589d61cd2edf31) --- source4/utils/net/net_join.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 98bf19d234..59b35d70fa 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -23,6 +23,7 @@ #include "utils/net/net.h" #include "libnet/libnet.h" #include "libcli/security/security.h" +#include "param/param.h" int net_join(struct net_context *ctx, int argc, const char **argv) { -- cgit From 37d53832a4623653f706e77985a79d84bd7c6694 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 28 Sep 2007 01:17:46 +0000 Subject: r25398: Parse loadparm context to all lp_*() functions. (This used to be commit 3fcc960839c6e5ca4de2c3c042f12f369ac5f238) --- source4/utils/net/net_join.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 59b35d70fa..1352fb7d9b 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -67,7 +67,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) return -1; } /* prepare parameters for the join */ - r->in.netbios_name = lp_netbios_name(); + r->in.netbios_name = lp_netbios_name(global_loadparm); r->in.domain_name = domain_name; r->in.join_type = secure_channel_type; r->in.level = LIBNET_JOIN_AUTOMATIC; -- cgit From a693e6f1c71d9772b52cf40a85b0504cea837240 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 4 Dec 2007 19:33:00 +0100 Subject: r26295: Remove use of global_loadparm for net and wb_pam_auth. (This used to be commit 47696b42987ea67ae1c6c09a4bec5858e5db4542) --- source4/utils/net/net_join.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 1352fb7d9b..6d833f8e93 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -67,7 +67,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) return -1; } /* prepare parameters for the join */ - r->in.netbios_name = lp_netbios_name(global_loadparm); + r->in.netbios_name = lp_netbios_name(ctx->lp_ctx); r->in.domain_name = domain_name; r->in.join_type = secure_channel_type; r->in.level = LIBNET_JOIN_AUTOMATIC; -- cgit From 4c4323009fa83f00ed319de59a3aad48fcd65994 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Dec 2007 02:37:04 +0100 Subject: r26327: Explicit loadparm_context for RPC client functions. (This used to be commit eeb2251d22b3d6e0379444a73af69d1014692b07) --- source4/utils/net/net_join.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 6d833f8e93..08a4fbd4a1 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -57,7 +57,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) domain_name = tmp; - libnetctx = libnet_context_init(NULL); + libnetctx = libnet_context_init(NULL, ctx->lp_ctx); if (!libnetctx) { return -1; } -- cgit From 8a982108a4f115e350c4246276f2ec886934c7fe Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 9 Apr 2008 14:59:32 +1000 Subject: Link the new vampire code togeather. This adds in the newly attached secrets handling, as well as an interface to the command line 'net' tool. Andrew Bartlett (This used to be commit 1282e3c39479aa580124206814b493370d10690a) --- source4/utils/net/net_join.c | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 08a4fbd4a1..abdcbf6027 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -100,3 +100,70 @@ int net_join_help(struct net_context *ctx, int argc, const char **argv) d_printf("Joins domain as either member or backup domain controller.\n"); return 0; } + +int net_vampire(struct net_context *ctx, int argc, const char **argv) +{ + NTSTATUS status; + struct libnet_context *libnetctx; + struct libnet_Vampire *r; + char *tmp, *targetdir = NULL; + const char *domain_name; + + switch (argc) { + case 0: /* no args -> fail */ + return net_vampire_usage(ctx, argc, argv); + case 1: /* only DOMAIN */ + tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + break; + case 2: /* domain and target dir */ + tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + targetdir = talloc_strdup(ctx->mem_ctx, argv[1]); + break; + default: /* too many args -> fail */ + return net_vampire_usage(ctx, argc, argv); + } + + domain_name = tmp; + + libnetctx = libnet_context_init(NULL, ctx->lp_ctx); + if (!libnetctx) { + return -1; + } + libnetctx->cred = ctx->credentials; + r = talloc(ctx->mem_ctx, struct libnet_Vampire); + if (!r) { + return -1; + } + /* prepare parameters for the vampire */ + r->in.netbios_name = lp_netbios_name(ctx->lp_ctx); + r->in.domain_name = domain_name; + r->in.targetdir = targetdir; + r->out.error_string = NULL; + + /* do the domain vampire */ + status = libnet_Vampire(libnetctx, r, r); + + if (!NT_STATUS_IS_OK(status)) { + d_fprintf(stderr, "Vampire of domain failed: %s\n", + r->out.error_string ? r->out.error_string : nt_errstr(status)); + talloc_free(r); + talloc_free(libnetctx); + return -1; + } + d_printf("Vampired domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx->mem_ctx, r->out.domain_sid)); + + talloc_free(libnetctx); + return 0; +} + +int net_vampire_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net vampire [options]\n"); + return 0; +} + +int net_vampire_help(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("Vampires domain as either member or backup domain controller.\n"); + return 0; +} -- cgit From 4f51b0246db3242ee02ee16905cba13a5dc5633a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 14 Apr 2008 12:43:37 -0400 Subject: Fix problems with event context not being the parent. (This used to be commit 957c4d893acf9e6db06a3fc3a4687ab6bb238635) --- source4/utils/net/net_join.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index abdcbf6027..2102257c6c 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -24,6 +24,7 @@ #include "libnet/libnet.h" #include "libcli/security/security.h" #include "param/param.h" +#include "lib/events/events.h" int net_join(struct net_context *ctx, int argc, const char **argv) { @@ -38,10 +39,10 @@ int net_join(struct net_context *ctx, int argc, const char **argv) case 0: /* no args -> fail */ return net_join_usage(ctx, argc, argv); case 1: /* only DOMAIN */ - tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + tmp = talloc_strdup(ctx, argv[0]); break; case 2: /* DOMAIN and role */ - tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + tmp = talloc_strdup(ctx, argv[0]); if (strcasecmp(argv[1], "BDC") == 0) { secure_channel_type = SEC_CHAN_BDC; } else if (strcasecmp(argv[1], "MEMBER") == 0) { @@ -57,12 +58,12 @@ int net_join(struct net_context *ctx, int argc, const char **argv) domain_name = tmp; - libnetctx = libnet_context_init(NULL, ctx->lp_ctx); + libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); if (!libnetctx) { return -1; } libnetctx->cred = ctx->credentials; - r = talloc(ctx->mem_ctx, struct libnet_Join); + r = talloc(ctx, struct libnet_Join); if (!r) { return -1; } @@ -83,7 +84,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) talloc_free(libnetctx); return -1; } - d_printf("Joined domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx->mem_ctx, r->out.domain_sid)); + d_printf("Joined domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx, r->out.domain_sid)); talloc_free(libnetctx); return 0; -- cgit From 2bc26db97fea4562415956269d05ea65e5710045 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 14 Apr 2008 20:39:12 +0200 Subject: Fix the build. (This used to be commit a70cbd63d9c398ddcbbaa595ee29343335e89aa7) --- source4/utils/net/net_join.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 2102257c6c..37b3c21fcf 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -114,11 +114,11 @@ int net_vampire(struct net_context *ctx, int argc, const char **argv) case 0: /* no args -> fail */ return net_vampire_usage(ctx, argc, argv); case 1: /* only DOMAIN */ - tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + tmp = talloc_strdup(ctx, argv[0]); break; case 2: /* domain and target dir */ - tmp = talloc_strdup(ctx->mem_ctx, argv[0]); - targetdir = talloc_strdup(ctx->mem_ctx, argv[1]); + tmp = talloc_strdup(ctx, argv[0]); + targetdir = talloc_strdup(ctx, argv[1]); break; default: /* too many args -> fail */ return net_vampire_usage(ctx, argc, argv); @@ -131,7 +131,7 @@ int net_vampire(struct net_context *ctx, int argc, const char **argv) return -1; } libnetctx->cred = ctx->credentials; - r = talloc(ctx->mem_ctx, struct libnet_Vampire); + r = talloc(ctx, struct libnet_Vampire); if (!r) { return -1; } @@ -151,7 +151,7 @@ int net_vampire(struct net_context *ctx, int argc, const char **argv) talloc_free(libnetctx); return -1; } - d_printf("Vampired domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx->mem_ctx, r->out.domain_sid)); + d_printf("Vampired domain %s (%s)\n", r->out.domain_name, dom_sid_string(ctx, r->out.domain_sid)); talloc_free(libnetctx); return 0; -- cgit From a5d52174bd993b32d01d26a795a56df4a92eba45 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 16 Apr 2008 22:30:15 +0200 Subject: Avoid event_find_context() when the event context is already available in the net utility. (This used to be commit d40804777edf41889bd461f63f7a07cc1cc60e27) --- source4/utils/net/net_join.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net/net_join.c') diff --git a/source4/utils/net/net_join.c b/source4/utils/net/net_join.c index 37b3c21fcf..ad63340089 100644 --- a/source4/utils/net/net_join.c +++ b/source4/utils/net/net_join.c @@ -58,7 +58,7 @@ int net_join(struct net_context *ctx, int argc, const char **argv) domain_name = tmp; - libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!libnetctx) { return -1; } -- cgit