summaryrefslogtreecommitdiff
path: root/source3/lib/netapi/joindomain.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/netapi/joindomain.c')
-rw-r--r--source3/lib/netapi/joindomain.c66
1 files changed, 11 insertions, 55 deletions
diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c
index 96c2f3d1fc..056d8d27e2 100644
--- a/source3/lib/netapi/joindomain.c
+++ b/source3/lib/netapi/joindomain.c
@@ -103,18 +103,8 @@ WERROR NetJoinDomain_r(struct libnetapi_ctx *ctx,
WERROR werr;
unsigned int old_timeout = 0;
- status = cli_full_connection(&cli, NULL, r->in.server,
- NULL, 0,
- "IPC$", "IPC",
- ctx->username,
- ctx->workgroup,
- ctx->password,
- CLI_FULL_CONNECTION_USE_KERBEROS |
- CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS,
- Undefined, NULL);
-
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_open_ipc_connection(ctx, r->in.server, &cli);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -152,7 +142,6 @@ WERROR NetJoinDomain_r(struct libnetapi_ctx *ctx,
if (old_timeout) {
cli_set_timeout(cli, old_timeout);
}
- cli_shutdown(cli);
}
return werr;
@@ -245,18 +234,8 @@ WERROR NetUnjoinDomain_r(struct libnetapi_ctx *ctx,
WERROR werr;
unsigned int old_timeout = 0;
- status = cli_full_connection(&cli, NULL, r->in.server_name,
- NULL, 0,
- "IPC$", "IPC",
- ctx->username,
- ctx->workgroup,
- ctx->password,
- CLI_FULL_CONNECTION_USE_KERBEROS |
- CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS,
- Undefined, NULL);
-
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_open_ipc_connection(ctx, r->in.server_name, &cli);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -289,8 +268,9 @@ WERROR NetUnjoinDomain_r(struct libnetapi_ctx *ctx,
done:
if (cli) {
- cli_set_timeout(cli, old_timeout);
- cli_shutdown(cli);
+ if (old_timeout) {
+ cli_set_timeout(cli, old_timeout);
+ }
}
return werr;
@@ -307,18 +287,8 @@ WERROR NetGetJoinInformation_r(struct libnetapi_ctx *ctx,
NTSTATUS status;
WERROR werr;
- status = cli_full_connection(&cli, NULL, r->in.server_name,
- NULL, 0,
- "IPC$", "IPC",
- ctx->username,
- ctx->workgroup,
- ctx->password,
- CLI_FULL_CONNECTION_USE_KERBEROS |
- CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS,
- Undefined, NULL);
-
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_open_ipc_connection(ctx, r->in.server_name, &cli);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -340,10 +310,6 @@ WERROR NetGetJoinInformation_r(struct libnetapi_ctx *ctx,
}
done:
- if (cli) {
- cli_shutdown(cli);
- }
-
return werr;
}
@@ -451,18 +417,8 @@ WERROR NetGetJoinableOUs_r(struct libnetapi_ctx *ctx,
NTSTATUS status;
WERROR werr;
- status = cli_full_connection(&cli, NULL, r->in.server_name,
- NULL, 0,
- "IPC$", "IPC",
- ctx->username,
- ctx->workgroup,
- ctx->password,
- CLI_FULL_CONNECTION_USE_KERBEROS |
- CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS,
- Undefined, NULL);
-
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_open_ipc_connection(ctx, r->in.server_name, &cli);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}