netapi: let libnetapi_samr_open_domain return WERROR.
authorGünther Deschner <gd@samba.org>
Mon, 2 Jun 2008 21:55:45 +0000 (23:55 +0200)
committerGünther Deschner <gd@samba.org>
Mon, 2 Jun 2008 23:27:49 +0000 (01:27 +0200)
Guenther
(This used to be commit 3d037a07e015a3af75dde054cef4c0bb7795fbb5)

source3/lib/netapi/group.c
source3/lib/netapi/localgroup.c
source3/lib/netapi/netapi_private.h
source3/lib/netapi/samr.c
source3/lib/netapi/user.c

index 7f905f0185c1ba9e50c9c73b3d759046df71761b..f56c92175bb0fd65623e31ab2ebbbe37eca59887 100644 (file)
@@ -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;
        }
 
index 24b1c0cbbf5babeb01f5f76607dd55a652724310..77d7498371eabe69ab7686fc041283b287a95b58 100644 (file)
@@ -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;
        }
 
index c788222ad3330d930dba7e9efd2a6d3c53268d38..69e68ab733e7e8995fdcd8a80ab5afc30a2073a2 100644 (file)
@@ -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
index 8e1c409ed98af8f3f37cd956e776e5a2a5273c35..a41de91de38dfdbfd8c66a500a9d96c044d1f625 100644 (file)
 /****************************************************************
 ****************************************************************/
 
-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;
 }
index de4f9164ce144f6518dd4be8b66985bd72277f5b..f053732ac90abe4d0abf401134d67c32e7458282 100644 (file)
@@ -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;
        }