summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/netapi/group.c104
-rw-r--r--source3/lib/netapi/localgroup.c75
-rw-r--r--source3/lib/netapi/netapi_private.h14
-rw-r--r--source3/lib/netapi/samr.c25
-rw-r--r--source3/lib/netapi/user.c80
5 files changed, 145 insertions, 153 deletions
diff --git a/source3/lib/netapi/group.c b/source3/lib/netapi/group.c
index 7f905f0185..f56c92175b 100644
--- a/source3/lib/netapi/group.c
+++ b/source3/lib/netapi/group.c
@@ -81,16 +81,15 @@ WERROR NetGroupAdd_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = libnetapi_samr_open_domain(ctx, pipe_cli,
- SAMR_ACCESS_ENUM_DOMAINS |
- SAMR_ACCESS_OPEN_DOMAIN,
- SAMR_DOMAIN_ACCESS_CREATE_GROUP |
- SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
- &connect_handle,
- &domain_handle,
- &domain_sid);
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_samr_open_domain(ctx, pipe_cli,
+ SAMR_ACCESS_ENUM_DOMAINS |
+ SAMR_ACCESS_OPEN_DOMAIN,
+ SAMR_DOMAIN_ACCESS_CREATE_GROUP |
+ SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
+ &connect_handle,
+ &domain_handle,
+ &domain_sid);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -262,15 +261,14 @@ WERROR NetGroupDel_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = libnetapi_samr_open_domain(ctx, pipe_cli,
- SAMR_ACCESS_ENUM_DOMAINS |
- SAMR_ACCESS_OPEN_DOMAIN,
- SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
- &connect_handle,
- &domain_handle,
- &domain_sid);
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_samr_open_domain(ctx, pipe_cli,
+ SAMR_ACCESS_ENUM_DOMAINS |
+ SAMR_ACCESS_OPEN_DOMAIN,
+ SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
+ &connect_handle,
+ &domain_handle,
+ &domain_sid);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -435,15 +433,14 @@ WERROR NetGroupSetInfo_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = libnetapi_samr_open_domain(ctx, pipe_cli,
- SAMR_ACCESS_ENUM_DOMAINS |
- SAMR_ACCESS_OPEN_DOMAIN,
- SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
- &connect_handle,
- &domain_handle,
- &domain_sid);
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_samr_open_domain(ctx, pipe_cli,
+ SAMR_ACCESS_ENUM_DOMAINS |
+ SAMR_ACCESS_OPEN_DOMAIN,
+ SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
+ &connect_handle,
+ &domain_handle,
+ &domain_sid);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -677,15 +674,14 @@ WERROR NetGroupGetInfo_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = libnetapi_samr_open_domain(ctx, pipe_cli,
- SAMR_ACCESS_ENUM_DOMAINS |
- SAMR_ACCESS_OPEN_DOMAIN,
- SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
- &connect_handle,
- &domain_handle,
- &domain_sid);
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_samr_open_domain(ctx, pipe_cli,
+ SAMR_ACCESS_ENUM_DOMAINS |
+ SAMR_ACCESS_OPEN_DOMAIN,
+ SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
+ &connect_handle,
+ &domain_handle,
+ &domain_sid);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -794,15 +790,14 @@ WERROR NetGroupAddUser_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = libnetapi_samr_open_domain(ctx, pipe_cli,
- SAMR_ACCESS_ENUM_DOMAINS |
- SAMR_ACCESS_OPEN_DOMAIN,
- SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
- &connect_handle,
- &domain_handle,
- &domain_sid);
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_samr_open_domain(ctx, pipe_cli,
+ SAMR_ACCESS_ENUM_DOMAINS |
+ SAMR_ACCESS_OPEN_DOMAIN,
+ SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
+ &connect_handle,
+ &domain_handle,
+ &domain_sid);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -925,15 +920,14 @@ WERROR NetGroupDelUser_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = libnetapi_samr_open_domain(ctx, pipe_cli,
- SAMR_ACCESS_ENUM_DOMAINS |
- SAMR_ACCESS_OPEN_DOMAIN,
- SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
- &connect_handle,
- &domain_handle,
- &domain_sid);
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_samr_open_domain(ctx, pipe_cli,
+ SAMR_ACCESS_ENUM_DOMAINS |
+ SAMR_ACCESS_OPEN_DOMAIN,
+ SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
+ &connect_handle,
+ &domain_handle,
+ &domain_sid);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
diff --git a/source3/lib/netapi/localgroup.c b/source3/lib/netapi/localgroup.c
index 24b1c0cbbf..77d7498371 100644
--- a/source3/lib/netapi/localgroup.c
+++ b/source3/lib/netapi/localgroup.c
@@ -115,21 +115,19 @@ WERROR NetLocalGroupAdd_r(struct libnetapi_ctx *ctx,
werr = WERR_ALIAS_EXISTS;
goto done;
}
-
}
rpccli_samr_Close(pipe_cli, ctx, &builtin_handle);
- status = libnetapi_samr_open_domain(ctx, pipe_cli,
- SAMR_ACCESS_ENUM_DOMAINS |
- SAMR_ACCESS_OPEN_DOMAIN,
- SAMR_DOMAIN_ACCESS_CREATE_ALIAS |
- SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
- &connect_handle,
- &domain_handle,
- &domain_sid);
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_samr_open_domain(ctx, pipe_cli,
+ SAMR_ACCESS_ENUM_DOMAINS |
+ SAMR_ACCESS_OPEN_DOMAIN,
+ SAMR_DOMAIN_ACCESS_CREATE_ALIAS |
+ SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
+ &connect_handle,
+ &domain_handle,
+ &domain_sid);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -269,16 +267,15 @@ WERROR NetLocalGroupDel_r(struct libnetapi_ctx *ctx,
rpccli_samr_Close(pipe_cli, ctx, &builtin_handle);
- status = libnetapi_samr_open_domain(ctx, pipe_cli,
- SAMR_ACCESS_ENUM_DOMAINS |
- SAMR_ACCESS_OPEN_DOMAIN,
- SAMR_DOMAIN_ACCESS_CREATE_ALIAS |
- SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
- &connect_handle,
- &domain_handle,
- &domain_sid);
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_samr_open_domain(ctx, pipe_cli,
+ SAMR_ACCESS_ENUM_DOMAINS |
+ SAMR_ACCESS_OPEN_DOMAIN,
+ SAMR_DOMAIN_ACCESS_CREATE_ALIAS |
+ SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
+ &connect_handle,
+ &domain_handle,
+ &domain_sid);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -473,16 +470,15 @@ WERROR NetLocalGroupGetInfo_r(struct libnetapi_ctx *ctx,
rpccli_samr_Close(pipe_cli, ctx, &builtin_handle);
- status = libnetapi_samr_open_domain(ctx, pipe_cli,
- SAMR_ACCESS_ENUM_DOMAINS |
- SAMR_ACCESS_OPEN_DOMAIN,
- SAMR_DOMAIN_ACCESS_CREATE_ALIAS |
- SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
- &connect_handle,
- &domain_handle,
- &domain_sid);
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_samr_open_domain(ctx, pipe_cli,
+ SAMR_ACCESS_ENUM_DOMAINS |
+ SAMR_ACCESS_OPEN_DOMAIN,
+ SAMR_DOMAIN_ACCESS_CREATE_ALIAS |
+ SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
+ &connect_handle,
+ &domain_handle,
+ &domain_sid);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -679,15 +675,14 @@ WERROR NetLocalGroupSetInfo_r(struct libnetapi_ctx *ctx,
rpccli_samr_Close(pipe_cli, ctx, &builtin_handle);
- status = libnetapi_samr_open_domain(ctx, pipe_cli,
- SAMR_ACCESS_ENUM_DOMAINS |
- SAMR_ACCESS_OPEN_DOMAIN,
- SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
- &connect_handle,
- &domain_handle,
- &domain_sid);
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_samr_open_domain(ctx, pipe_cli,
+ SAMR_ACCESS_ENUM_DOMAINS |
+ SAMR_ACCESS_OPEN_DOMAIN,
+ SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
+ &connect_handle,
+ &domain_handle,
+ &domain_sid);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
diff --git a/source3/lib/netapi/netapi_private.h b/source3/lib/netapi/netapi_private.h
index c788222ad3..69e68ab733 100644
--- a/source3/lib/netapi/netapi_private.h
+++ b/source3/lib/netapi/netapi_private.h
@@ -33,11 +33,11 @@ WERROR libnetapi_open_pipe(struct libnetapi_ctx *ctx,
struct cli_state *cli,
int pipe_idx,
struct rpc_pipe_client **pipe_cli);
-NTSTATUS libnetapi_samr_open_domain(TALLOC_CTX *mem_ctx,
- struct rpc_pipe_client *pipe_cli,
- uint32_t connect_mask,
- uint32_t domain_mask,
- struct policy_handle *connect_handle,
- struct policy_handle *domain_handle,
- struct dom_sid2 **domain_sid);
+WERROR libnetapi_samr_open_domain(TALLOC_CTX *mem_ctx,
+ struct rpc_pipe_client *pipe_cli,
+ uint32_t connect_mask,
+ uint32_t domain_mask,
+ struct policy_handle *connect_handle,
+ struct policy_handle *domain_handle,
+ struct dom_sid2 **domain_sid);
#endif
diff --git a/source3/lib/netapi/samr.c b/source3/lib/netapi/samr.c
index 8e1c409ed9..a41de91de3 100644
--- a/source3/lib/netapi/samr.c
+++ b/source3/lib/netapi/samr.c
@@ -27,15 +27,16 @@
/****************************************************************
****************************************************************/
-NTSTATUS libnetapi_samr_open_domain(TALLOC_CTX *mem_ctx,
- struct rpc_pipe_client *pipe_cli,
- uint32_t connect_mask,
- uint32_t domain_mask,
- struct policy_handle *connect_handle,
- struct policy_handle *domain_handle,
- struct dom_sid2 **domain_sid)
+WERROR libnetapi_samr_open_domain(TALLOC_CTX *mem_ctx,
+ struct rpc_pipe_client *pipe_cli,
+ uint32_t connect_mask,
+ uint32_t domain_mask,
+ struct policy_handle *connect_handle,
+ struct policy_handle *domain_handle,
+ struct dom_sid2 **domain_sid)
{
NTSTATUS status;
+ WERROR werr;
uint32_t resume_handle = 0;
uint32_t num_entries = 0;
struct samr_SamArray *sam = NULL;
@@ -49,6 +50,7 @@ NTSTATUS libnetapi_samr_open_domain(TALLOC_CTX *mem_ctx,
connect_mask,
connect_handle);
if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
goto done;
}
}
@@ -60,6 +62,7 @@ NTSTATUS libnetapi_samr_open_domain(TALLOC_CTX *mem_ctx,
0xffffffff,
&num_entries);
if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
goto done;
}
@@ -76,7 +79,7 @@ NTSTATUS libnetapi_samr_open_domain(TALLOC_CTX *mem_ctx,
}
if (!domain_found) {
- status = NT_STATUS_NO_SUCH_DOMAIN;
+ werr = WERR_NO_SUCH_DOMAIN;
goto done;
}
@@ -87,6 +90,7 @@ NTSTATUS libnetapi_samr_open_domain(TALLOC_CTX *mem_ctx,
&lsa_domain_name,
domain_sid);
if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
goto done;
}
@@ -96,9 +100,12 @@ NTSTATUS libnetapi_samr_open_domain(TALLOC_CTX *mem_ctx,
*domain_sid,
domain_handle);
if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
goto done;
}
+ werr = WERR_OK;
+
done:
- return status;
+ return werr;
}
diff --git a/source3/lib/netapi/user.c b/source3/lib/netapi/user.c
index de4f9164ce..f053732ac9 100644
--- a/source3/lib/netapi/user.c
+++ b/source3/lib/netapi/user.c
@@ -175,17 +175,16 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = libnetapi_samr_open_domain(ctx, pipe_cli,
- SAMR_ACCESS_ENUM_DOMAINS |
- SAMR_ACCESS_OPEN_DOMAIN,
- SAMR_DOMAIN_ACCESS_LOOKUP_INFO_1 |
- SAMR_DOMAIN_ACCESS_CREATE_USER |
- SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
- &connect_handle,
- &domain_handle,
- &domain_sid);
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_samr_open_domain(ctx, pipe_cli,
+ SAMR_ACCESS_ENUM_DOMAINS |
+ SAMR_ACCESS_OPEN_DOMAIN,
+ SAMR_DOMAIN_ACCESS_LOOKUP_INFO_1 |
+ SAMR_DOMAIN_ACCESS_CREATE_USER |
+ SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
+ &connect_handle,
+ &domain_handle,
+ &domain_sid);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -325,15 +324,14 @@ WERROR NetUserDel_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = libnetapi_samr_open_domain(ctx, pipe_cli,
- SAMR_ACCESS_ENUM_DOMAINS |
- SAMR_ACCESS_OPEN_DOMAIN,
- SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
- &connect_handle,
- &domain_handle,
- &domain_sid);
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_samr_open_domain(ctx, pipe_cli,
+ SAMR_ACCESS_ENUM_DOMAINS |
+ SAMR_ACCESS_OPEN_DOMAIN,
+ SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
+ &connect_handle,
+ &domain_handle,
+ &domain_sid);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -501,17 +499,16 @@ WERROR NetUserEnum_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = libnetapi_samr_open_domain(ctx, pipe_cli,
- SAMR_ACCESS_ENUM_DOMAINS |
- SAMR_ACCESS_OPEN_DOMAIN,
- SAMR_DOMAIN_ACCESS_LOOKUP_INFO_2 |
- SAMR_DOMAIN_ACCESS_ENUM_ACCOUNTS |
- SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
- &connect_handle,
- &domain_handle,
- &domain_sid);
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_samr_open_domain(ctx, pipe_cli,
+ SAMR_ACCESS_ENUM_DOMAINS |
+ SAMR_ACCESS_OPEN_DOMAIN,
+ SAMR_DOMAIN_ACCESS_LOOKUP_INFO_2 |
+ SAMR_DOMAIN_ACCESS_ENUM_ACCOUNTS |
+ SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
+ &connect_handle,
+ &domain_handle,
+ &domain_sid);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -758,17 +755,16 @@ WERROR NetQueryDisplayInformation_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = libnetapi_samr_open_domain(ctx, pipe_cli,
- SAMR_ACCESS_ENUM_DOMAINS |
- SAMR_ACCESS_OPEN_DOMAIN,
- SAMR_DOMAIN_ACCESS_LOOKUP_INFO_2 |
- SAMR_DOMAIN_ACCESS_ENUM_ACCOUNTS |
- SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
- &connect_handle,
- &domain_handle,
- &domain_sid);
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_samr_open_domain(ctx, pipe_cli,
+ SAMR_ACCESS_ENUM_DOMAINS |
+ SAMR_ACCESS_OPEN_DOMAIN,
+ SAMR_DOMAIN_ACCESS_LOOKUP_INFO_2 |
+ SAMR_DOMAIN_ACCESS_ENUM_ACCOUNTS |
+ SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
+ &connect_handle,
+ &domain_handle,
+ &domain_sid);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}