mirror of
https://github.com/samba-team/samba.git
synced 2025-01-13 13:18:06 +03:00
Use libnetapi_open_ipc_connection in libnetapi.
Guenther
(This used to be commit d9f19fc615
)
This commit is contained in:
parent
deb6362f1f
commit
aeb7f7db40
@ -45,19 +45,8 @@ WERROR NetGetDCName_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 |
|
||||
CLI_FULL_CONNECTION_ANONYMOUS_FALLBACK,
|
||||
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;
|
||||
}
|
||||
|
||||
@ -74,9 +63,6 @@ WERROR NetGetDCName_r(struct libnetapi_ctx *ctx,
|
||||
(const char **)r->out.buffer,
|
||||
&werr);
|
||||
done:
|
||||
if (cli) {
|
||||
cli_shutdown(cli);
|
||||
}
|
||||
|
||||
return werr;
|
||||
}
|
||||
@ -101,19 +87,8 @@ WERROR NetGetAnyDCName_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 |
|
||||
CLI_FULL_CONNECTION_ANONYMOUS_FALLBACK,
|
||||
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;
|
||||
}
|
||||
|
||||
@ -133,9 +108,6 @@ WERROR NetGetAnyDCName_r(struct libnetapi_ctx *ctx,
|
||||
goto done;
|
||||
}
|
||||
done:
|
||||
if (cli) {
|
||||
cli_shutdown(cli);
|
||||
}
|
||||
|
||||
return werr;
|
||||
|
||||
@ -175,19 +147,8 @@ WERROR DsGetDcName_r(struct libnetapi_ctx *ctx,
|
||||
struct cli_state *cli = NULL;
|
||||
struct rpc_pipe_client *pipe_cli = NULL;
|
||||
|
||||
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 |
|
||||
CLI_FULL_CONNECTION_ANONYMOUS_FALLBACK,
|
||||
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;
|
||||
}
|
||||
|
||||
@ -213,9 +174,5 @@ WERROR DsGetDcName_r(struct libnetapi_ctx *ctx,
|
||||
}
|
||||
|
||||
done:
|
||||
if (cli) {
|
||||
cli_shutdown(cli);
|
||||
}
|
||||
|
||||
return werr;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "includes.h"
|
||||
#include "lib/netapi/netapi.h"
|
||||
#include "lib/netapi/netapi_private.h"
|
||||
|
||||
extern bool AllowDebugChange;
|
||||
|
||||
@ -113,6 +114,7 @@ NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx)
|
||||
|
||||
NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx)
|
||||
{
|
||||
libnetapi_shutdown_cm(ctx);
|
||||
|
||||
if (ctx->krb5_cc_env) {
|
||||
char *env = getenv(KRB5_ENV_CCNAME);
|
||||
|
@ -70,18 +70,8 @@ WERROR NetServerGetInfo_r(struct libnetapi_ctx *ctx,
|
||||
WERROR werr;
|
||||
union srvsvc_NetSrvInfo info;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -109,10 +99,6 @@ WERROR NetServerGetInfo_r(struct libnetapi_ctx *ctx,
|
||||
}
|
||||
|
||||
done:
|
||||
if (cli) {
|
||||
cli_shutdown(cli);
|
||||
}
|
||||
|
||||
return werr;
|
||||
}
|
||||
|
||||
@ -186,18 +172,8 @@ WERROR NetServerSetInfo_r(struct libnetapi_ctx *ctx,
|
||||
WERROR werr;
|
||||
union srvsvc_NetSrvInfo info;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -229,9 +205,5 @@ WERROR NetServerSetInfo_r(struct libnetapi_ctx *ctx,
|
||||
}
|
||||
|
||||
done:
|
||||
if (cli) {
|
||||
cli_shutdown(cli);
|
||||
}
|
||||
|
||||
return werr;
|
||||
}
|
||||
|
@ -180,18 +180,8 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx,
|
||||
goto done;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -353,8 +343,6 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx,
|
||||
rpccli_samr_Close(pipe_cli, ctx, &connect_handle);
|
||||
}
|
||||
|
||||
cli_shutdown(cli);
|
||||
|
||||
return werr;
|
||||
}
|
||||
|
||||
@ -385,18 +373,8 @@ WERROR NetUserDel_r(struct libnetapi_ctx *ctx,
|
||||
ZERO_STRUCT(domain_handle);
|
||||
ZERO_STRUCT(user_handle);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -534,8 +512,6 @@ WERROR NetUserDel_r(struct libnetapi_ctx *ctx,
|
||||
rpccli_samr_Close(pipe_cli, ctx, &connect_handle);
|
||||
}
|
||||
|
||||
cli_shutdown(cli);
|
||||
|
||||
return werr;
|
||||
}
|
||||
|
||||
@ -621,18 +597,8 @@ WERROR NetUserEnum_r(struct libnetapi_ctx *ctx,
|
||||
return WERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -721,6 +687,10 @@ WERROR NetUserEnum_r(struct libnetapi_ctx *ctx,
|
||||
r->out.buffer);
|
||||
|
||||
done:
|
||||
if (!cli) {
|
||||
return werr;
|
||||
}
|
||||
|
||||
if (is_valid_policy_hnd(&domain_handle)) {
|
||||
rpccli_samr_Close(pipe_cli, ctx, &domain_handle);
|
||||
}
|
||||
@ -728,10 +698,6 @@ WERROR NetUserEnum_r(struct libnetapi_ctx *ctx,
|
||||
rpccli_samr_Close(pipe_cli, ctx, &connect_handle);
|
||||
}
|
||||
|
||||
if (cli) {
|
||||
cli_shutdown(cli);
|
||||
}
|
||||
|
||||
return werr;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user