summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-05-16 11:52:48 +0200
committerGünther Deschner <gd@samba.org>2008-05-16 11:58:24 +0200
commit9530c26c4c1a6c6616675c5be2c48089c79d0203 (patch)
tree344e107f7ddecd5f1b19e2b387d90be55e98735d /source3/utils
parent175cca17299421df74831eec9ab2f43994087e5c (diff)
downloadsamba-9530c26c4c1a6c6616675c5be2c48089c79d0203.tar.gz
samba-9530c26c4c1a6c6616675c5be2c48089c79d0203.tar.bz2
samba-9530c26c4c1a6c6616675c5be2c48089c79d0203.zip
net: use the netapi_ctx from the net_context struct.
Guenther (This used to be commit ff8a9655ccd40bc2ca3ef0403308193d956c4adf)
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_dom.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/source3/utils/net_dom.c b/source3/utils/net_dom.c
index 86dad658d6..1a876a7ba3 100644
--- a/source3/utils/net_dom.c
+++ b/source3/utils/net_dom.c
@@ -42,7 +42,6 @@ int net_help_dom(struct net_context *c, int argc, const char **argv)
static int net_dom_unjoin(struct net_context *c, int argc, const char **argv)
{
- struct libnetapi_ctx *ctx = NULL;
const char *server_name = NULL;
const char *account = NULL;
const char *password = NULL;
@@ -90,18 +89,10 @@ static int net_dom_unjoin(struct net_context *c, int argc, const char **argv)
}
}
- status = libnetapi_init(&ctx);
- if (status != 0) {
- return -1;
- }
-
- libnetapi_set_username(ctx, c->opt_user_name);
- libnetapi_set_password(ctx, c->opt_password);
-
status = NetUnjoinDomain(server_name, account, password, unjoin_flags);
if (status != 0) {
printf("Failed to unjoin domain: %s\n",
- libnetapi_get_error_string(ctx, status));
+ libnetapi_get_error_string(c->netapi_ctx, status));
goto done;
}
@@ -136,7 +127,6 @@ static int net_dom_unjoin(struct net_context *c, int argc, const char **argv)
static int net_dom_join(struct net_context *c, int argc, const char **argv)
{
- struct libnetapi_ctx *ctx = NULL;
const char *server_name = NULL;
const char *domain_name = NULL;
const char *account_ou = NULL;
@@ -204,19 +194,11 @@ static int net_dom_join(struct net_context *c, int argc, const char **argv)
/* check if domain is a domain or a workgroup */
- status = libnetapi_init(&ctx);
- if (status != 0) {
- return -1;
- }
-
- libnetapi_set_username(ctx, c->opt_user_name);
- libnetapi_set_password(ctx, c->opt_password);
-
status = NetJoinDomain(server_name, domain_name, account_ou,
Account, password, join_flags);
if (status != 0) {
printf("Failed to join domain: %s\n",
- libnetapi_get_error_string(ctx, status));
+ libnetapi_get_error_string(c->netapi_ctx, status));
goto done;
}
@@ -251,6 +233,8 @@ static int net_dom_join(struct net_context *c, int argc, const char **argv)
int net_dom(struct net_context *c, int argc, const char **argv)
{
+ NET_API_STATUS status;
+
struct functable func[] = {
{"JOIN", net_dom_join},
{"UNJOIN", net_dom_unjoin},
@@ -258,5 +242,13 @@ int net_dom(struct net_context *c, int argc, const char **argv)
{NULL, NULL}
};
+ status = libnetapi_init(&c->netapi_ctx);
+ if (status != 0) {
+ return -1;
+ }
+
+ libnetapi_set_username(c->netapi_ctx, c->opt_user_name);
+ libnetapi_set_password(c->netapi_ctx, c->opt_password);
+
return net_run_function(c, argc, argv, func, net_dom_usage);
}