summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-08-11 20:39:14 +0200
committerGünther Deschner <gd@samba.org>2008-08-14 12:21:44 +0200
commit11db643962cec98299fbf6f79ef0b51cd2ee0e90 (patch)
treed9b70856c07dd00e36de57b567776964ff120a06 /source3/lib
parent4136ab3c983f08536ee8aa49c0fed60bd95b6096 (diff)
downloadsamba-11db643962cec98299fbf6f79ef0b51cd2ee0e90.tar.gz
samba-11db643962cec98299fbf6f79ef0b51cd2ee0e90.tar.bz2
samba-11db643962cec98299fbf6f79ef0b51cd2ee0e90.zip
netapi: let libnetapi_samr_lookup_and_open_alias return NTSTATUS.
Guenther (cherry picked from commit dcf6d879a14a70ce5795eb8dcfbfe2fc5a8ad859) (This used to be commit 8ac6a2739be870f286d19dc6bf8f0054a559b43b)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/netapi/localgroup.c162
1 files changed, 77 insertions, 85 deletions
diff --git a/source3/lib/netapi/localgroup.c b/source3/lib/netapi/localgroup.c
index e863416438..6fe5f1cd86 100644
--- a/source3/lib/netapi/localgroup.c
+++ b/source3/lib/netapi/localgroup.c
@@ -24,15 +24,14 @@
#include "lib/netapi/netapi_private.h"
#include "lib/netapi/libnetapi.h"
-static WERROR libnetapi_samr_lookup_and_open_alias(TALLOC_CTX *mem_ctx,
- struct rpc_pipe_client *pipe_cli,
- struct policy_handle *domain_handle,
- const char *group_name,
- uint32_t access_rights,
- struct policy_handle *alias_handle)
+static NTSTATUS libnetapi_samr_lookup_and_open_alias(TALLOC_CTX *mem_ctx,
+ struct rpc_pipe_client *pipe_cli,
+ struct policy_handle *domain_handle,
+ const char *group_name,
+ uint32_t access_rights,
+ struct policy_handle *alias_handle)
{
NTSTATUS status;
- WERROR werr;
struct lsa_String lsa_account_name;
struct samr_Ids user_rids, name_types;
@@ -46,8 +45,7 @@ static WERROR libnetapi_samr_lookup_and_open_alias(TALLOC_CTX *mem_ctx,
&user_rids,
&name_types);
if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
- goto done;
+ return status;
}
switch (name_types.ids[0]) {
@@ -55,23 +53,14 @@ static WERROR libnetapi_samr_lookup_and_open_alias(TALLOC_CTX *mem_ctx,
case SID_NAME_WKN_GRP:
break;
default:
- return WERR_INVALID_DATATYPE;
- }
-
- status = rpccli_samr_OpenAlias(pipe_cli, mem_ctx,
- domain_handle,
- access_rights,
- user_rids.ids[0],
- alias_handle);
- if (NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
- goto done;
+ return NT_STATUS_INVALID_SID;
}
- werr = WERR_OK;
-
- done:
- return werr;
+ return rpccli_samr_OpenAlias(pipe_cli, mem_ctx,
+ domain_handle,
+ access_rights,
+ user_rids.ids[0],
+ alias_handle);
}
/****************************************************************
@@ -182,17 +171,16 @@ WERROR NetLocalGroupAdd_r(struct libnetapi_ctx *ctx,
goto done;
}
- werr = libnetapi_samr_lookup_and_open_alias(ctx, pipe_cli,
- &builtin_handle,
- alias_name,
- SAMR_ALIAS_ACCESS_LOOKUP_INFO,
- &alias_handle);
-
+ status = libnetapi_samr_lookup_and_open_alias(ctx, pipe_cli,
+ &builtin_handle,
+ alias_name,
+ SAMR_ALIAS_ACCESS_LOOKUP_INFO,
+ &alias_handle);
if (ctx->disable_policy_handle_cache) {
libnetapi_samr_close_builtin_handle(ctx, &builtin_handle);
}
- if (W_ERROR_IS_OK(werr)) {
+ if (NT_STATUS_IS_OK(status)) {
werr = WERR_ALIAS_EXISTS;
goto done;
}
@@ -312,17 +300,17 @@ WERROR NetLocalGroupDel_r(struct libnetapi_ctx *ctx,
goto done;
}
- werr = libnetapi_samr_lookup_and_open_alias(ctx, pipe_cli,
- &builtin_handle,
- r->in.group_name,
- SEC_STD_DELETE,
- &alias_handle);
+ status = libnetapi_samr_lookup_and_open_alias(ctx, pipe_cli,
+ &builtin_handle,
+ r->in.group_name,
+ SEC_STD_DELETE,
+ &alias_handle);
if (ctx->disable_policy_handle_cache) {
libnetapi_samr_close_builtin_handle(ctx, &builtin_handle);
}
- if (W_ERROR_IS_OK(werr)) {
+ if (NT_STATUS_IS_OK(status)) {
goto delete_alias;
}
@@ -338,17 +326,18 @@ WERROR NetLocalGroupDel_r(struct libnetapi_ctx *ctx,
goto done;
}
- werr = libnetapi_samr_lookup_and_open_alias(ctx, pipe_cli,
- &domain_handle,
- r->in.group_name,
- SEC_STD_DELETE,
- &alias_handle);
+ status = libnetapi_samr_lookup_and_open_alias(ctx, pipe_cli,
+ &domain_handle,
+ r->in.group_name,
+ SEC_STD_DELETE,
+ &alias_handle);
if (ctx->disable_policy_handle_cache) {
libnetapi_samr_close_domain_handle(ctx, &domain_handle);
}
- if (!W_ERROR_IS_OK(werr)) {
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
goto done;
}
@@ -492,17 +481,17 @@ WERROR NetLocalGroupGetInfo_r(struct libnetapi_ctx *ctx,
goto done;
}
- werr = libnetapi_samr_lookup_and_open_alias(ctx, pipe_cli,
- &builtin_handle,
- r->in.group_name,
- SAMR_ALIAS_ACCESS_LOOKUP_INFO,
- &alias_handle);
+ status = libnetapi_samr_lookup_and_open_alias(ctx, pipe_cli,
+ &builtin_handle,
+ r->in.group_name,
+ SAMR_ALIAS_ACCESS_LOOKUP_INFO,
+ &alias_handle);
if (ctx->disable_policy_handle_cache) {
libnetapi_samr_close_builtin_handle(ctx, &builtin_handle);
}
- if (W_ERROR_IS_OK(werr)) {
+ if (NT_STATUS_IS_OK(status)) {
goto query_alias;
}
@@ -518,17 +507,18 @@ WERROR NetLocalGroupGetInfo_r(struct libnetapi_ctx *ctx,
goto done;
}
- werr = libnetapi_samr_lookup_and_open_alias(ctx, pipe_cli,
- &domain_handle,
- r->in.group_name,
- SAMR_ALIAS_ACCESS_LOOKUP_INFO,
- &alias_handle);
+ status = libnetapi_samr_lookup_and_open_alias(ctx, pipe_cli,
+ &domain_handle,
+ r->in.group_name,
+ SAMR_ALIAS_ACCESS_LOOKUP_INFO,
+ &alias_handle);
if (ctx->disable_policy_handle_cache) {
libnetapi_samr_close_domain_handle(ctx, &domain_handle);
}
- if (!W_ERROR_IS_OK(werr)) {
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
goto done;
}
@@ -673,17 +663,17 @@ WERROR NetLocalGroupSetInfo_r(struct libnetapi_ctx *ctx,
init_lsa_String(&lsa_account_name, r->in.group_name);
- werr = libnetapi_samr_lookup_and_open_alias(ctx, pipe_cli,
- &builtin_handle,
- r->in.group_name,
- SAMR_ALIAS_ACCESS_SET_INFO,
- &alias_handle);
+ status = libnetapi_samr_lookup_and_open_alias(ctx, pipe_cli,
+ &builtin_handle,
+ r->in.group_name,
+ SAMR_ALIAS_ACCESS_SET_INFO,
+ &alias_handle);
if (ctx->disable_policy_handle_cache) {
libnetapi_samr_close_builtin_handle(ctx, &builtin_handle);
}
- if (W_ERROR_IS_OK(werr)) {
+ if (NT_STATUS_IS_OK(status)) {
goto set_alias;
}
@@ -698,12 +688,13 @@ WERROR NetLocalGroupSetInfo_r(struct libnetapi_ctx *ctx,
goto done;
}
- werr = libnetapi_samr_lookup_and_open_alias(ctx, pipe_cli,
- &domain_handle,
- r->in.group_name,
- SAMR_ALIAS_ACCESS_SET_INFO,
- &alias_handle);
- if (!W_ERROR_IS_OK(werr)) {
+ status = libnetapi_samr_lookup_and_open_alias(ctx, pipe_cli,
+ &domain_handle,
+ r->in.group_name,
+ SAMR_ALIAS_ACCESS_SET_INFO,
+ &alias_handle);
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
goto done;
}
@@ -1137,20 +1128,20 @@ static WERROR NetLocalGroupModifyMembers_r(struct libnetapi_ctx *ctx,
init_lsa_String(&lsa_account_name, r->in.group_name);
- werr = libnetapi_samr_lookup_and_open_alias(ctx, pipe_cli,
- &builtin_handle,
- r->in.group_name,
- SAMR_ALIAS_ACCESS_ADD_MEMBER |
- SAMR_ALIAS_ACCESS_REMOVE_MEMBER |
- SAMR_ALIAS_ACCESS_GET_MEMBERS |
- SAMR_ALIAS_ACCESS_LOOKUP_INFO,
- &alias_handle);
+ status = libnetapi_samr_lookup_and_open_alias(ctx, pipe_cli,
+ &builtin_handle,
+ r->in.group_name,
+ SAMR_ALIAS_ACCESS_ADD_MEMBER |
+ SAMR_ALIAS_ACCESS_REMOVE_MEMBER |
+ SAMR_ALIAS_ACCESS_GET_MEMBERS |
+ SAMR_ALIAS_ACCESS_LOOKUP_INFO,
+ &alias_handle);
if (ctx->disable_policy_handle_cache) {
libnetapi_samr_close_builtin_handle(ctx, &builtin_handle);
}
- if (W_ERROR_IS_OK(werr)) {
+ if (NT_STATUS_IS_OK(status)) {
goto modify_membership;
}
@@ -1165,15 +1156,16 @@ static WERROR NetLocalGroupModifyMembers_r(struct libnetapi_ctx *ctx,
goto done;
}
- werr = libnetapi_samr_lookup_and_open_alias(ctx, pipe_cli,
- &domain_handle,
- r->in.group_name,
- SAMR_ALIAS_ACCESS_ADD_MEMBER |
- SAMR_ALIAS_ACCESS_REMOVE_MEMBER |
- SAMR_ALIAS_ACCESS_GET_MEMBERS |
- SAMR_ALIAS_ACCESS_LOOKUP_INFO,
- &alias_handle);
- if (!W_ERROR_IS_OK(werr)) {
+ status = libnetapi_samr_lookup_and_open_alias(ctx, pipe_cli,
+ &domain_handle,
+ r->in.group_name,
+ SAMR_ALIAS_ACCESS_ADD_MEMBER |
+ SAMR_ALIAS_ACCESS_REMOVE_MEMBER |
+ SAMR_ALIAS_ACCESS_GET_MEMBERS |
+ SAMR_ALIAS_ACCESS_LOOKUP_INFO,
+ &alias_handle);
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
goto done;
}