diff options
Diffstat (limited to 'source4/utils/net/net.c')
-rw-r--r-- | source4/utils/net/net.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/source4/utils/net/net.c b/source4/utils/net/net.c index 05dbb35f41..89f4e77735 100644 --- a/source4/utils/net/net.c +++ b/source4/utils/net/net.c @@ -156,6 +156,7 @@ static int binary_net(int argc, const char **argv) const char **argv_new; TALLOC_CTX *mem_ctx; struct net_context *ctx; + const char *domain; poptContext pc; struct poptOption long_options[] = { POPT_AUTOHELP @@ -172,16 +173,6 @@ static int binary_net(int argc, const char **argv) setbuffer(stdout, NULL, 0); #endif - mem_ctx = talloc_init("net_context"); - ctx = talloc_p(mem_ctx, struct net_context); - if (!ctx) { - d_printf("talloc_init(net_context) failed\n"); - exit(1); - } - - ZERO_STRUCTP(ctx); - ctx->mem_ctx = mem_ctx; - pc = poptGetContext("net", argc, (const char **) argv, long_options, POPT_CONTEXT_KEEP_FIRST); @@ -213,6 +204,25 @@ static int binary_net(int argc, const char **argv) return 1; } + if (cmdline_auth_info.domain[0]) { + domain = cmdline_auth_info.domain; + } else { + domain = lp_workgroup(); + } + + mem_ctx = talloc_init("net_context"); + ctx = talloc_p(mem_ctx, struct net_context); + if (!ctx) { + d_printf("talloc_init(net_context) failed\n"); + exit(1); + } + + ZERO_STRUCTP(ctx); + ctx->mem_ctx = mem_ctx; + ctx->user.account_name = talloc_strdup(ctx->mem_ctx, cmdline_auth_info.username); + ctx->user.domain_name = talloc_strdup(ctx->mem_ctx, domain); + ctx->user.password = talloc_strdup(ctx->mem_ctx, cmdline_auth_info.password); + rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage); if (rc != 0) { |