summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/netapi/group.c73
-rw-r--r--source3/lib/netapi/localgroup.c88
-rw-r--r--source3/lib/netapi/netapi.h1
-rw-r--r--source3/lib/netapi/user.c56
4 files changed, 112 insertions, 106 deletions
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;
}
diff --git a/source3/lib/netapi/localgroup.c b/source3/lib/netapi/localgroup.c
index 2c1e9dfc4c..faf57cc5fa 100644
--- a/source3/lib/netapi/localgroup.c
+++ b/source3/lib/netapi/localgroup.c
@@ -187,7 +187,9 @@ WERROR NetLocalGroupAdd_r(struct libnetapi_ctx *ctx,
SAMR_ALIAS_ACCESS_LOOKUP_INFO,
&alias_handle);
- rpccli_samr_Close(pipe_cli, ctx, &builtin_handle);
+ if (ctx->disable_policy_handle_cache) {
+ libnetapi_samr_close_builtin_handle(ctx, &builtin_handle);
+ }
if (W_ERROR_IS_OK(werr)) {
werr = WERR_ALIAS_EXISTS;
@@ -244,14 +246,11 @@ WERROR NetLocalGroupAdd_r(struct libnetapi_ctx *ctx,
if (is_valid_policy_hnd(&alias_handle)) {
rpccli_samr_Close(pipe_cli, ctx, &alias_handle);
}
- if (is_valid_policy_hnd(&domain_handle)) {
- rpccli_samr_Close(pipe_cli, ctx, &domain_handle);
- }
- if (is_valid_policy_hnd(&builtin_handle)) {
- rpccli_samr_Close(pipe_cli, ctx, &builtin_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_builtin_handle(ctx, &builtin_handle);
+ libnetapi_samr_close_connect_handle(ctx, &connect_handle);
}
return werr;
@@ -315,7 +314,9 @@ WERROR NetLocalGroupDel_r(struct libnetapi_ctx *ctx,
SEC_STD_DELETE,
&alias_handle);
- rpccli_samr_Close(pipe_cli, ctx, &builtin_handle);
+ if (ctx->disable_policy_handle_cache) {
+ libnetapi_samr_close_builtin_handle(ctx, &builtin_handle);
+ }
if (W_ERROR_IS_OK(werr)) {
goto delete_alias;
@@ -339,7 +340,9 @@ WERROR NetLocalGroupDel_r(struct libnetapi_ctx *ctx,
SEC_STD_DELETE,
&alias_handle);
- rpccli_samr_Close(pipe_cli, ctx, &domain_handle);
+ if (ctx->disable_policy_handle_cache) {
+ libnetapi_samr_close_domain_handle(ctx, &domain_handle);
+ }
if (!W_ERROR_IS_OK(werr)) {
goto done;
@@ -366,14 +369,11 @@ WERROR NetLocalGroupDel_r(struct libnetapi_ctx *ctx,
if (is_valid_policy_hnd(&alias_handle)) {
rpccli_samr_Close(pipe_cli, ctx, &alias_handle);
}
- if (is_valid_policy_hnd(&domain_handle)) {
- rpccli_samr_Close(pipe_cli, ctx, &domain_handle);
- }
- if (is_valid_policy_hnd(&builtin_handle)) {
- rpccli_samr_Close(pipe_cli, ctx, &builtin_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_builtin_handle(ctx, &builtin_handle);
+ libnetapi_samr_close_connect_handle(ctx, &connect_handle);
}
return werr;
@@ -493,7 +493,9 @@ WERROR NetLocalGroupGetInfo_r(struct libnetapi_ctx *ctx,
SAMR_ALIAS_ACCESS_LOOKUP_INFO,
&alias_handle);
- rpccli_samr_Close(pipe_cli, ctx, &builtin_handle);
+ if (ctx->disable_policy_handle_cache) {
+ libnetapi_samr_close_builtin_handle(ctx, &builtin_handle);
+ }
if (W_ERROR_IS_OK(werr)) {
goto query_alias;
@@ -517,7 +519,9 @@ WERROR NetLocalGroupGetInfo_r(struct libnetapi_ctx *ctx,
SAMR_ALIAS_ACCESS_LOOKUP_INFO,
&alias_handle);
- rpccli_samr_Close(pipe_cli, ctx, &domain_handle);
+ if (ctx->disable_policy_handle_cache) {
+ libnetapi_samr_close_domain_handle(ctx, &domain_handle);
+ }
if (!W_ERROR_IS_OK(werr)) {
goto done;
@@ -547,14 +551,11 @@ WERROR NetLocalGroupGetInfo_r(struct libnetapi_ctx *ctx,
if (is_valid_policy_hnd(&alias_handle)) {
rpccli_samr_Close(pipe_cli, ctx, &alias_handle);
}
- if (is_valid_policy_hnd(&domain_handle)) {
- rpccli_samr_Close(pipe_cli, ctx, &domain_handle);
- }
- if (is_valid_policy_hnd(&builtin_handle)) {
- rpccli_samr_Close(pipe_cli, ctx, &builtin_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_builtin_handle(ctx, &builtin_handle);
+ libnetapi_samr_close_connect_handle(ctx, &connect_handle);
}
return werr;
@@ -672,7 +673,9 @@ WERROR NetLocalGroupSetInfo_r(struct libnetapi_ctx *ctx,
SAMR_ALIAS_ACCESS_SET_INFO,
&alias_handle);
- rpccli_samr_Close(pipe_cli, ctx, &builtin_handle);
+ if (ctx->disable_policy_handle_cache) {
+ libnetapi_samr_close_builtin_handle(ctx, &builtin_handle);
+ }
if (W_ERROR_IS_OK(werr)) {
goto set_alias;
@@ -698,7 +701,9 @@ WERROR NetLocalGroupSetInfo_r(struct libnetapi_ctx *ctx,
goto done;
}
- rpccli_samr_Close(pipe_cli, ctx, &domain_handle);
+ if (ctx->disable_policy_handle_cache) {
+ libnetapi_samr_close_domain_handle(ctx, &domain_handle);
+ }
set_alias:
@@ -727,14 +732,11 @@ WERROR NetLocalGroupSetInfo_r(struct libnetapi_ctx *ctx,
if (is_valid_policy_hnd(&alias_handle)) {
rpccli_samr_Close(pipe_cli, ctx, &alias_handle);
}
- if (is_valid_policy_hnd(&domain_handle)) {
- rpccli_samr_Close(pipe_cli, ctx, &domain_handle);
- }
- if (is_valid_policy_hnd(&builtin_handle)) {
- rpccli_samr_Close(pipe_cli, ctx, &builtin_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_builtin_handle(ctx, &builtin_handle);
+ libnetapi_samr_close_connect_handle(ctx, &connect_handle);
}
return werr;
@@ -915,9 +917,11 @@ WERROR NetLocalGroupEnum_r(struct libnetapi_ctx *ctx,
return werr;
}
- libnetapi_samr_close_domain_handle(ctx, &domain_handle);
- libnetapi_samr_close_builtin_handle(ctx, &builtin_handle);
- libnetapi_samr_close_connect_handle(ctx, &connect_handle);
+ if (ctx->disable_policy_handle_cache) {
+ libnetapi_samr_close_domain_handle(ctx, &domain_handle);
+ libnetapi_samr_close_builtin_handle(ctx, &builtin_handle);
+ libnetapi_samr_close_connect_handle(ctx, &connect_handle);
+ }
return werr;
}
diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h
index 300bae59ea..7d32ffcbae 100644
--- a/source3/lib/netapi/netapi.h
+++ b/source3/lib/netapi/netapi.h
@@ -331,6 +331,7 @@ struct libnetapi_ctx {
char *password;
char *krb5_cc_env;
int use_kerberos;
+ int disable_policy_handle_cache;
void *private_data;
};
diff --git a/source3/lib/netapi/user.c b/source3/lib/netapi/user.c
index 2c18cd0282..8d69536848 100644
--- a/source3/lib/netapi/user.c
+++ b/source3/lib/netapi/user.c
@@ -284,11 +284,10 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx,
if (is_valid_policy_hnd(&user_handle)) {
rpccli_samr_Close(pipe_cli, ctx, &user_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;
@@ -410,14 +409,11 @@ WERROR NetUserDel_r(struct libnetapi_ctx *ctx,
if (is_valid_policy_hnd(&user_handle)) {
rpccli_samr_Close(pipe_cli, ctx, &user_handle);
}
- if (is_valid_policy_hnd(&builtin_handle)) {
- rpccli_samr_Close(pipe_cli, ctx, &builtin_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_builtin_handle(ctx, &builtin_handle);
+ libnetapi_samr_close_domain_handle(ctx, &domain_handle);
+ libnetapi_samr_close_connect_handle(ctx, &connect_handle);
}
return werr;
@@ -786,11 +782,14 @@ WERROR NetUserEnum_r(struct libnetapi_ctx *ctx,
return werr;
}
- 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);
+ }
}
return werr;
@@ -982,7 +981,7 @@ WERROR NetQueryDisplayInformation_r(struct libnetapi_ctx *ctx,
uint32_t total_size = 0;
uint32_t returned_size = 0;
- NTSTATUS status;
+ NTSTATUS status = NT_STATUS_OK;
WERROR werr;
ZERO_STRUCT(connect_handle);
@@ -1044,11 +1043,14 @@ WERROR NetQueryDisplayInformation_r(struct libnetapi_ctx *ctx,
return werr;
}
- 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);
+ }
}
return werr;
@@ -1189,8 +1191,10 @@ WERROR NetUserGetInfo_r(struct libnetapi_ctx *ctx,
rpccli_samr_Close(pipe_cli, ctx, &user_handle);
}
- libnetapi_samr_close_domain_handle(ctx, &domain_handle);
- libnetapi_samr_close_connect_handle(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;
}