From c703304f557021c78ba0ad24e9b2e7b42147b8fd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 17 Jul 2008 22:44:24 +0200 Subject: netapi: add caching of samr policy handles. Guenther (This used to be commit bf8453da9af1be788955204cc581c5143a854072) --- source3/lib/netapi/group.c | 73 ++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 38 deletions(-) (limited to 'source3/lib/netapi/group.c') diff --git a/source3/lib/netapi/group.c b/source3/lib/netapi/group.c index f856ec0a13..15580b3c22 100644 --- a/source3/lib/netapi/group.c +++ b/source3/lib/netapi/group.c @@ -204,11 +204,10 @@ WERROR NetGroupAdd_r(struct libnetapi_ctx *ctx, if (is_valid_policy_hnd(&group_handle)) { rpccli_samr_Close(pipe_cli, ctx, &group_handle); } - if (is_valid_policy_hnd(&domain_handle)) { - rpccli_samr_Close(pipe_cli, ctx, &domain_handle); - } - if (is_valid_policy_hnd(&connect_handle)) { - rpccli_samr_Close(pipe_cli, ctx, &connect_handle); + + if (ctx->disable_policy_handle_cache) { + libnetapi_samr_close_domain_handle(ctx, &domain_handle); + libnetapi_samr_close_connect_handle(ctx, &connect_handle); } return werr; @@ -374,11 +373,10 @@ WERROR NetGroupDel_r(struct libnetapi_ctx *ctx, if (is_valid_policy_hnd(&group_handle)) { rpccli_samr_Close(pipe_cli, ctx, &group_handle); } - if (is_valid_policy_hnd(&domain_handle)) { - rpccli_samr_Close(pipe_cli, ctx, &domain_handle); - } - if (is_valid_policy_hnd(&connect_handle)) { - rpccli_samr_Close(pipe_cli, ctx, &connect_handle); + + if (ctx->disable_policy_handle_cache) { + libnetapi_samr_close_domain_handle(ctx, &domain_handle); + libnetapi_samr_close_connect_handle(ctx, &connect_handle); } return werr; @@ -562,11 +560,10 @@ WERROR NetGroupSetInfo_r(struct libnetapi_ctx *ctx, if (is_valid_policy_hnd(&group_handle)) { rpccli_samr_Close(pipe_cli, ctx, &group_handle); } - if (is_valid_policy_hnd(&domain_handle)) { - rpccli_samr_Close(pipe_cli, ctx, &domain_handle); - } - if (is_valid_policy_hnd(&connect_handle)) { - rpccli_samr_Close(pipe_cli, ctx, &connect_handle); + + if (ctx->disable_policy_handle_cache) { + libnetapi_samr_close_domain_handle(ctx, &domain_handle); + libnetapi_samr_close_connect_handle(ctx, &connect_handle); } return werr; @@ -750,11 +747,10 @@ WERROR NetGroupGetInfo_r(struct libnetapi_ctx *ctx, if (is_valid_policy_hnd(&group_handle)) { rpccli_samr_Close(pipe_cli, ctx, &group_handle); } - if (is_valid_policy_hnd(&domain_handle)) { - rpccli_samr_Close(pipe_cli, ctx, &domain_handle); - } - if (is_valid_policy_hnd(&connect_handle)) { - rpccli_samr_Close(pipe_cli, ctx, &connect_handle); + + if (ctx->disable_policy_handle_cache) { + libnetapi_samr_close_domain_handle(ctx, &domain_handle); + libnetapi_samr_close_connect_handle(ctx, &connect_handle); } return werr; @@ -880,11 +876,10 @@ WERROR NetGroupAddUser_r(struct libnetapi_ctx *ctx, if (is_valid_policy_hnd(&group_handle)) { rpccli_samr_Close(pipe_cli, ctx, &group_handle); } - if (is_valid_policy_hnd(&domain_handle)) { - rpccli_samr_Close(pipe_cli, ctx, &domain_handle); - } - if (is_valid_policy_hnd(&connect_handle)) { - rpccli_samr_Close(pipe_cli, ctx, &connect_handle); + + if (ctx->disable_policy_handle_cache) { + libnetapi_samr_close_domain_handle(ctx, &domain_handle); + libnetapi_samr_close_connect_handle(ctx, &connect_handle); } return werr; @@ -1009,11 +1004,10 @@ WERROR NetGroupDelUser_r(struct libnetapi_ctx *ctx, if (is_valid_policy_hnd(&group_handle)) { rpccli_samr_Close(pipe_cli, ctx, &group_handle); } - if (is_valid_policy_hnd(&domain_handle)) { - rpccli_samr_Close(pipe_cli, ctx, &domain_handle); - } - if (is_valid_policy_hnd(&connect_handle)) { - rpccli_samr_Close(pipe_cli, ctx, &connect_handle); + + if (ctx->disable_policy_handle_cache) { + libnetapi_samr_close_domain_handle(ctx, &domain_handle); + libnetapi_samr_close_connect_handle(ctx, &connect_handle); } return werr; @@ -1195,7 +1189,7 @@ WERROR NetGroupEnum_r(struct libnetapi_ctx *ctx, uint32_t total_size = 0; uint32_t returned_size = 0; - NTSTATUS status; + NTSTATUS status = NT_STATUS_OK; WERROR werr, tmp_werr; ZERO_STRUCT(connect_handle); @@ -1283,14 +1277,17 @@ WERROR NetGroupEnum_r(struct libnetapi_ctx *ctx, if (!cli) { return werr; } -#if 0 - if (is_valid_policy_hnd(&domain_handle)) { - rpccli_samr_Close(pipe_cli, ctx, &domain_handle); - } - if (is_valid_policy_hnd(&connect_handle)) { - rpccli_samr_Close(pipe_cli, ctx, &connect_handle); + + /* if last query */ + if (NT_STATUS_IS_OK(status) || + NT_STATUS_IS_ERR(status)) { + + if (ctx->disable_policy_handle_cache) { + libnetapi_samr_close_domain_handle(ctx, &domain_handle); + libnetapi_samr_close_connect_handle(ctx, &connect_handle); + } } -#endif + return werr; } -- cgit