diff options
author | Günther Deschner <gd@samba.org> | 2008-04-10 22:04:04 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2008-04-10 22:04:04 +0200 |
commit | aeb7f7db4014695eb6510cc7a713db4c6228bd1f (patch) | |
tree | 01fa3c8dc3429ba5622b66ba516f370c20a5c735 /source3/lib/netapi | |
parent | deb6362f1f1ac12d6e2a245370ca36accc9506b1 (diff) | |
download | samba-aeb7f7db4014695eb6510cc7a713db4c6228bd1f.tar.gz samba-aeb7f7db4014695eb6510cc7a713db4c6228bd1f.tar.bz2 samba-aeb7f7db4014695eb6510cc7a713db4c6228bd1f.zip |
Use libnetapi_open_ipc_connection in libnetapi.
Guenther
(This used to be commit d9f19fc61586d606393368799dee9757c169d602)
Diffstat (limited to 'source3/lib/netapi')
-rw-r--r-- | source3/lib/netapi/getdc.c | 55 | ||||
-rw-r--r-- | source3/lib/netapi/joindomain.c | 66 | ||||
-rw-r--r-- | source3/lib/netapi/netapi.c | 2 | ||||
-rw-r--r-- | source3/lib/netapi/serverinfo.c | 36 | ||||
-rw-r--r-- | source3/lib/netapi/user.c | 54 |
5 files changed, 33 insertions, 180 deletions
diff --git a/source3/lib/netapi/getdc.c b/source3/lib/netapi/getdc.c index 944cfb24f3..8f882941b3 100644 --- a/source3/lib/netapi/getdc.c +++ b/source3/lib/netapi/getdc.c @@ -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; } 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; } diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index fbec2757f0..2478a8dda1 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -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); diff --git a/source3/lib/netapi/serverinfo.c b/source3/lib/netapi/serverinfo.c index fb5d9402cf..238b9ca308 100644 --- a/source3/lib/netapi/serverinfo.c +++ b/source3/lib/netapi/serverinfo.c @@ -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; } diff --git a/source3/lib/netapi/user.c b/source3/lib/netapi/user.c index 54157a8f82..d9505bc067 100644 --- a/source3/lib/netapi/user.c +++ b/source3/lib/netapi/user.c @@ -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; } |