From 9530c26c4c1a6c6616675c5be2c48089c79d0203 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 16 May 2008 11:52:48 +0200 Subject: net: use the netapi_ctx from the net_context struct. Guenther (This used to be commit ff8a9655ccd40bc2ca3ef0403308193d956c4adf) --- source3/utils/net_dom.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'source3') 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); } -- cgit