diff options
author | Günther Deschner <gd@samba.org> | 2007-12-22 00:34:30 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2007-12-22 00:37:02 +0100 |
commit | 9fc2c21fa682073ce3144990f64fd81c83d60e4e (patch) | |
tree | 3952da371369f4996064cd13b119ef5de5e0e740 /source3/utils | |
parent | 30a788bd2027648de1a1bc0922f40c1c00b727bd (diff) | |
download | samba-9fc2c21fa682073ce3144990f64fd81c83d60e4e.tar.gz samba-9fc2c21fa682073ce3144990f64fd81c83d60e4e.tar.bz2 samba-9fc2c21fa682073ce3144990f64fd81c83d60e4e.zip |
Fix net_dom_join & net_dom_unjoin.
Guenther
(This used to be commit 6dd17e4840ee6c4bf0df3c3f76f9b232b3674d55)
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/net_dom.c | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/source3/utils/net_dom.c b/source3/utils/net_dom.c index 7b5f562727..3a8338ec70 100644 --- a/source3/utils/net_dom.c +++ b/source3/utils/net_dom.c @@ -43,6 +43,7 @@ int net_help_dom(int argc, const char **argv) static int net_dom_unjoin(int argc, const char **argv) { + struct libnetapi_ctx *ctx = NULL; const char *server_name = NULL; const char *account = NULL; const char *password = NULL; @@ -50,8 +51,8 @@ static int net_dom_unjoin(int argc, const char **argv) WKSSVC_JOIN_FLAGS_JOIN_TYPE; struct cli_state *cli = NULL; bool reboot = false; - NTSTATUS status; - NET_API_STATUS werr; + NTSTATUS ntstatus; + NET_API_STATUS status; int ret = -1; int i; @@ -82,17 +83,25 @@ static int net_dom_unjoin(int argc, const char **argv) } if (reboot) { - status = net_make_ipc_connection_ex(opt_workgroup, server_name, - NULL, 0, &cli); - if (!NT_STATUS_IS_OK(status)) { + ntstatus = net_make_ipc_connection_ex(opt_workgroup, server_name, + NULL, 0, &cli); + if (!NT_STATUS_IS_OK(ntstatus)) { return -1; } } - werr = NetUnjoinDomain(server_name, account, password, unjoin_flags); - if (werr != 0) { + status = libnetapi_init(&ctx); + if (status != 0) { + return -1; + } + + libnetapi_set_username(ctx, opt_user_name); + libnetapi_set_password(ctx, opt_password); + + status = NetUnjoinDomain(server_name, account, password, unjoin_flags); + if (status != 0) { printf("Failed to unjoin domain: %s\n", - get_friendly_nt_error_msg(werror_to_ntstatus(W_ERROR(werr)))); + libnetapi_errstr(ctx, status)); goto done; } @@ -121,11 +130,13 @@ static int net_dom_unjoin(int argc, const char **argv) cli_shutdown(cli); } + /* libnetapi_free(ctx); */ return ret; } static int net_dom_join(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; @@ -135,8 +146,8 @@ static int net_dom_join(int argc, const char **argv) WKSSVC_JOIN_FLAGS_JOIN_TYPE; struct cli_state *cli = NULL; bool reboot = false; - NTSTATUS status; - NET_API_STATUS werr; + NTSTATUS ntstatus; + NET_API_STATUS status; int ret = -1; int i; @@ -183,21 +194,28 @@ static int net_dom_join(int argc, const char **argv) } if (reboot) { - status = net_make_ipc_connection_ex(opt_workgroup, server_name, - NULL, 0, &cli); - if (!NT_STATUS_IS_OK(status)) { + ntstatus = net_make_ipc_connection_ex(opt_workgroup, server_name, + NULL, 0, &cli); + if (!NT_STATUS_IS_OK(ntstatus)) { return -1; } } /* check if domain is a domain or a workgroup */ - werr = NetJoinDomain(server_name, domain_name, account_ou, - Account, password, join_flags); - if (werr != 0) { - printf("Failed to join domain: %s (WERROR: %s)\n", - get_friendly_nt_error_msg(werror_to_ntstatus(W_ERROR(werr))), - dos_errstr(W_ERROR(werr))); + status = libnetapi_init(&ctx); + if (status != 0) { + return -1; + } + + libnetapi_set_username(ctx, opt_user_name); + libnetapi_set_password(ctx, 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_errstr(ctx, status)); goto done; } @@ -226,6 +244,7 @@ static int net_dom_join(int argc, const char **argv) cli_shutdown(cli); } + /* libnetapi_free(ctx); */ return ret; } |