s3:rpc_client: map fault codes to NTSTATUS with dcerpc_fault_to_nt_status()
authorStefan Metzmacher <metze@samba.org>
Sat, 23 Apr 2011 22:00:40 +0000 (00:00 +0200)
committerStefan Metzmacher <metze@samba.org>
Sun, 24 Apr 2011 08:44:53 +0000 (10:44 +0200)
Most fault codes have a NTSTATUS representation, so use that.

This brings the fault handling in common with the source4/librpc/rpc code,
which make it possible to share more highlevel code, between source3 and
source4 as the error checking can be the same now.

metze

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Sun Apr 24 10:44:53 CEST 2011 on sn-devel-104

source3/lib/netapi/user.c
source3/libnet/libnet_join.c
source3/rpc_client/cli_pipe.c
source3/winbindd/winbindd_cm.c
source3/winbindd/winbindd_msrpc.c
source3/winbindd/winbindd_pam.c

index 63be7ac751212011705157743072edf58a87e7a3..653ece1385409ae1df26f8398bb9ba1785095821 100644 (file)
@@ -322,7 +322,7 @@ static NTSTATUS set_user_info_USER_INFO_X(TALLOC_CTX *ctx,
                                                  25,
                                                  &user_info,
                                                  &result);
-               if (NT_STATUS_EQUAL(status, NT_STATUS(DCERPC_FAULT_INVALID_TAG))) {
+               if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE)) {
 
                        user_info.info23.info = info21;
 
index 1e866c3dd195f59c912a2a89e6168a62cdb94679..c3693a892554b3f8b0362950e9b035ad1b22d2ff 100644 (file)
@@ -1074,7 +1074,7 @@ static NTSTATUS libnet_join_joindomain_rpc(TALLOC_CTX *mem_ctx,
                                          &user_info,
                                          &result);
 
-       if (NT_STATUS_EQUAL(status, NT_STATUS(DCERPC_FAULT_INVALID_TAG))) {
+       if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE)) {
 
                /* retry with level 24 */
 
index d7f990af2c98ce6fb6eadcdd36f384248b6ccaf3..55cc5f8b3489f668d4cc4eb94faaeab731d649b5 100644 (file)
@@ -469,11 +469,7 @@ static NTSTATUS cli_pipe_validate_current_pdu(TALLOC_CTX *mem_ctx,
                          pkt->u.fault.status),
                          rpccli_pipe_txt(talloc_tos(), cli)));
 
-               if (NT_STATUS_IS_OK(NT_STATUS(pkt->u.fault.status))) {
-                       return NT_STATUS_UNSUCCESSFUL;
-               } else {
-                       return NT_STATUS(pkt->u.fault.status);
-               }
+               return dcerpc_fault_to_nt_status(pkt->u.fault.status);
 
        default:
                DEBUG(0, (__location__ "Unknown packet type %u received "
index 1473d337218b2db9606072480ff19a633a626196..3a701b9c0e3c81be0ba480b716e2d4a6d3b5c8b6 100644 (file)
@@ -1985,7 +1985,7 @@ static void set_dc_type_and_flags_connect( struct winbindd_domain *domain )
                 * no_dssetup mode here as well to get domain->initialized
                 * set - gd */
 
-               if (NT_STATUS_V(status) == DCERPC_FAULT_OP_RNG_ERROR) {
+               if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE)) {
                        goto no_dssetup;
                }
 
index 83cdd063a70c8838f6c34a79207d9aa87e4be5bb..921cdb5a8bc3cd36076df396e8765a36d2f0bb0b 100644 (file)
@@ -1120,8 +1120,8 @@ NTSTATUS winbindd_lookup_sids(TALLOC_CTX *mem_ctx,
        /* And restore our original timeout. */
        dcerpc_binding_handle_set_timeout(b, orig_timeout);
 
-       if (NT_STATUS_V(status) == DCERPC_FAULT_ACCESS_DENIED ||
-           NT_STATUS_V(status) == DCERPC_FAULT_SEC_PKG_ERROR) {
+       if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) ||
+           NT_STATUS_EQUAL(status, NT_STATUS_RPC_SEC_PKG_ERROR)) {
                /*
                 * This can happen if the schannel key is not
                 * valid anymore, we need to invalidate the
@@ -1208,8 +1208,8 @@ NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
        /* And restore our original timeout. */
        dcerpc_binding_handle_set_timeout(b, orig_timeout);
 
-       if (NT_STATUS_V(status) == DCERPC_FAULT_ACCESS_DENIED ||
-           NT_STATUS_V(status) == DCERPC_FAULT_SEC_PKG_ERROR) {
+       if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) ||
+           NT_STATUS_EQUAL(status, NT_STATUS_RPC_SEC_PKG_ERROR)) {
                /*
                 * This can happen if the schannel key is not
                 * valid anymore, we need to invalidate the
index 76e06d3735a2fe6a2bd224bf0795de9b63001b98..6b086c8c0fa61f96f52b768b8a2fa6d3d05b5008 100644 (file)
@@ -1248,7 +1248,7 @@ static NTSTATUS winbind_samlogon_retry_loop(struct winbindd_domain *domain,
                                        info3);
                }
 
-               if ((NT_STATUS_V(result) == DCERPC_FAULT_OP_RNG_ERROR)
+               if (NT_STATUS_EQUAL(result, NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE)
                    && domain->can_do_samlogon_ex) {
                        DEBUG(3, ("Got a DC that can not do NetSamLogonEx, "
                                  "retrying with NetSamLogon\n"));
@@ -1938,10 +1938,10 @@ enum winbindd_result winbindd_dual_pam_chauthtok(struct winbindd_domain *contact
         * short to comply with the samr_ChangePasswordUser3 idl - gd */
 
        /* only fallback when the chgpasswd_user3 call is not supported */
-       if ((NT_STATUS_EQUAL(result, NT_STATUS(DCERPC_FAULT_OP_RNG_ERROR))) ||
-                  (NT_STATUS_EQUAL(result, NT_STATUS_NOT_SUPPORTED)) ||
-                  (NT_STATUS_EQUAL(result, NT_STATUS_BUFFER_TOO_SMALL)) ||
-                  (NT_STATUS_EQUAL(result, NT_STATUS_NOT_IMPLEMENTED))) {
+       if (NT_STATUS_EQUAL(result, NT_STATUS_RPC_PROCNUM_OUT_OF_RANGE) ||
+           NT_STATUS_EQUAL(result, NT_STATUS_NOT_SUPPORTED) ||
+           NT_STATUS_EQUAL(result, NT_STATUS_BUFFER_TOO_SMALL) ||
+           NT_STATUS_EQUAL(result, NT_STATUS_NOT_IMPLEMENTED)) {
 
                DEBUG(10,("Password change with chgpasswd_user3 failed with: %s, retrying chgpasswd_user2\n",
                        nt_errstr(result)));