[SCM] Samba Shared Repository - branch v3-2-test updated -
initial-v3-2-unstable-839-g6dd17e4
Günther Deschner
gd at samba.org
Fri Dec 21 23:39:17 GMT 2007
The branch, v3-2-test has been updated
via 6dd17e4840ee6c4bf0df3c3f76f9b232b3674d55 (commit)
from c890ebc3cad7222007e62227ec1f28d978310cbf (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit 6dd17e4840ee6c4bf0df3c3f76f9b232b3674d55
Author: Günther Deschner <gd at samba.org>
Date: Sat Dec 22 00:34:30 2007 +0100
Fix net_dom_join & net_dom_unjoin.
Guenther
-----------------------------------------------------------------------
Summary of changes:
source/utils/net_dom.c | 57 ++++++++++++++++++++++++++++++++----------------
1 files changed, 38 insertions(+), 19 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/utils/net_dom.c b/source/utils/net_dom.c
index 7b5f562..3a8338e 100644
--- a/source/utils/net_dom.c
+++ b/source/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;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list