summaryrefslogtreecommitdiff
path: root/source3/utils/net.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-07-13 11:42:53 +0000
committerAndrew Tridgell <tridge@samba.org>2002-07-13 11:42:53 +0000
commit351831683d6d1d7040fe36b04331746e95aaac87 (patch)
tree23fae4612eb8bc4817e5fc2fbf1cb65ef769a6f1 /source3/utils/net.c
parentd7bdcee189dabc1301284655751b8022dde03ebb (diff)
downloadsamba-351831683d6d1d7040fe36b04331746e95aaac87.tar.gz
samba-351831683d6d1d7040fe36b04331746e95aaac87.tar.bz2
samba-351831683d6d1d7040fe36b04331746e95aaac87.zip
added --machine-pass option to net. This allows you to authenticate as
the current machine account and password. This is useful both for diagnostics and domain leave. (This used to be commit 73b246981fd5b27cc1d835946b89e82f5b78f332)
Diffstat (limited to 'source3/utils/net.c')
-rw-r--r--source3/utils/net.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/source3/utils/net.c b/source3/utils/net.c
index a3610d0907..27826a3d53 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -370,6 +370,7 @@ static struct functable net_func[] = {
poptContext pc;
static char *servicesf = dyn_CONFIGFILE;
static char *debuglevel = NULL;
+ int opt_machine_pass = 0;
struct poptOption long_options[] = {
{"help", 'h', POPT_ARG_NONE, 0, 'h'},
@@ -391,6 +392,7 @@ static struct functable net_func[] = {
{"reboot", 'r', POPT_ARG_NONE, &opt_reboot},
{"force", 'f', POPT_ARG_NONE, &opt_force},
{"timeout", 't', POPT_ARG_INT, &opt_timeout},
+ {"machine-pass",'P', POPT_ARG_NONE, &opt_machine_pass},
{ 0, 0, 0, 0}
};
@@ -426,6 +428,7 @@ static struct functable net_func[] = {
default:
d_printf("\nInvalid option %c (%d)\n", (char)opt, opt);
net_help(argc, argv);
+ exit(1);
}
}
@@ -445,7 +448,7 @@ static struct functable net_func[] = {
break;
}
}
-
+
if (!opt_requester_name) {
static fstring myname;
get_myname(myname);
@@ -477,6 +480,23 @@ static struct functable net_func[] = {
load_interfaces();
+ if (opt_machine_pass) {
+ /* it is very useful to be able to make ads queries as the
+ machine account for testing purposes and for domain leave */
+
+ if (!secrets_init()) {
+ d_printf("ERROR: Unable to open secrets database\n");
+ exit(1);
+ }
+
+ asprintf(&opt_user_name,"%s$", global_myname);
+ opt_password = secrets_fetch_machine_password();
+ if (!opt_password) {
+ d_printf("ERROR: Unable to fetch machine password\n");
+ exit(1);
+ }
+ }
+
rc = net_run_function(argc_new-1, argv_new+1, net_func, net_help);
DEBUG(2,("return code = %d\n", rc));