Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

Location:
vendor/current/source3/rpcclient
Files:
1 added
16 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/rpcclient/cmd_dfs.c

    r414 r740  
    2222#include "includes.h"
    2323#include "rpcclient.h"
    24 #include "../librpc/gen_ndr/cli_dfs.h"
     24#include "../librpc/gen_ndr/ndr_dfs_c.h"
    2525
    2626/* Check DFS is supported by the remote server */
     
    3131        enum dfs_ManagerVersion version;
    3232        NTSTATUS result;
     33        struct dcerpc_binding_handle *b = cli->binding_handle;
    3334
    3435        if (argc != 1) {
     
    3738        }
    3839
    39         result = rpccli_dfs_GetManagerVersion(cli, mem_ctx, &version);
     40        result = dcerpc_dfs_GetManagerVersion(b, mem_ctx, &version);
    4041
    4142        if (!NT_STATUS_IS_OK(result)) {
     
    5960        const char *path, *servername, *sharename, *comment;
    6061        uint32 flags = 0;
     62        struct dcerpc_binding_handle *b = cli->binding_handle;
    6163
    6264        if (argc != 5) {
     
    7173        comment = argv[4];
    7274
    73         result = rpccli_dfs_Add(cli, mem_ctx, path, servername,
     75        result = dcerpc_dfs_Add(b, mem_ctx, path, servername,
    7476                                sharename, comment, flags, &werr);
    7577        if (!NT_STATUS_IS_OK(result)) {
     
    8688        WERROR werr;
    8789        const char *path, *servername, *sharename;
     90        struct dcerpc_binding_handle *b = cli->binding_handle;
    8891
    8992        if (argc != 4) {
     
    9699        sharename = argv[3];
    97100
    98         result = rpccli_dfs_Remove(cli, mem_ctx, path, servername,
     101        result = dcerpc_dfs_Remove(b, mem_ctx, path, servername,
    99102                                   sharename, &werr);
    100103        if (!NT_STATUS_IS_OK(result)) {
     
    196199        struct dfs_EnumArray200 info200;
    197200        struct dfs_EnumArray300 info300;
     201        struct dcerpc_binding_handle *b = cli->binding_handle;
    198202
    199203        NTSTATUS result;
     
    222226        }
    223227
    224         result = rpccli_dfs_Enum(cli, mem_ctx, str.level, 0xFFFFFFFF, &str,
     228        result = dcerpc_dfs_Enum(b, mem_ctx, str.level, 0xFFFFFFFF, &str,
    225229                                 &total, &werr);
    226 
    227         if (NT_STATUS_IS_OK(result)) {
     230        if (!NT_STATUS_IS_OK(result)) {
     231                return ntstatus_to_werror(result);
     232        }
     233        if (W_ERROR_IS_OK(werr)) {
    228234                display_dfs_enumstruct(&str);
    229235        }
     
    244250        struct dfs_EnumArray200 info200;
    245251        struct dfs_EnumArray300 info300;
     252        struct dcerpc_binding_handle *b = cli->binding_handle;
    246253
    247254        NTSTATUS result;
     
    271278        }
    272279
    273         result = rpccli_dfs_EnumEx(cli, mem_ctx, argv[1], str.level,
     280        result = dcerpc_dfs_EnumEx(b, mem_ctx, argv[1], str.level,
    274281                                   0xFFFFFFFF, &str, &total, &werr);
    275 
    276         if (NT_STATUS_IS_OK(result)) {
     282        if (!NT_STATUS_IS_OK(result)) {
     283                return ntstatus_to_werror(result);
     284        }
     285        if (W_ERROR_IS_OK(werr)) {
    277286                display_dfs_enumstruct(&str);
    278287        }
     
    290299        uint32 info_level = 1;
    291300        union dfs_Info ctr;
     301        struct dcerpc_binding_handle *b = cli->binding_handle;
    292302
    293303        if (argc < 4 || argc > 5) {
     
    304314                info_level = atoi(argv[4]);
    305315
    306         result = rpccli_dfs_GetInfo(cli, mem_ctx, path, servername,
     316        result = dcerpc_dfs_GetInfo(b, mem_ctx, path, servername,
    307317                                    sharename, info_level, &ctr, &werr);
    308 
    309         if (NT_STATUS_IS_OK(result)) {
     318        if (!NT_STATUS_IS_OK(result)) {
     319                return ntstatus_to_werror(result);
     320        }
     321        if (W_ERROR_IS_OK(werr)) {
    310322                display_dfs_info(info_level, &ctr);
    311323        }
  • vendor/current/source3/rpcclient/cmd_drsuapi.c

    r414 r740  
    2121#include "includes.h"
    2222#include "rpcclient.h"
    23 #include "../librpc/gen_ndr/cli_drsuapi.h"
     23#include "../librpc/gen_ndr/ndr_drsuapi_c.h"
    2424
    2525static WERROR cracknames(struct rpc_pipe_client *cli,
     
    3535        WERROR werr;
    3636        int i;
    37         int32_t level = 1;
     37        uint32_t level = 1;
    3838        union drsuapi_DsNameRequest req;
    39         int32_t level_out;
     39        uint32_t level_out;
    4040        struct drsuapi_DsNameString *names;
     41        struct dcerpc_binding_handle *b = cli->binding_handle;
    4142
    4243        names = TALLOC_ZERO_ARRAY(mem_ctx, struct drsuapi_DsNameString, argc);
     
    5556        req.req1.format_desired = format_desired;
    5657
    57         status = rpccli_drsuapi_DsCrackNames(cli, mem_ctx,
     58        status = dcerpc_drsuapi_DsCrackNames(b, mem_ctx,
    5859                                             bind_handle,
    5960                                             level,
     
    8384        struct GUID bind_guid;
    8485        struct policy_handle bind_handle;
     86        struct dcerpc_binding_handle *b = cli->binding_handle;
    8587
    8688        union drsuapi_DsNameCtr ctr;
     
    9395        GUID_from_string(DRSUAPI_DS_BIND_GUID, &bind_guid);
    9496
    95         status = rpccli_drsuapi_DsBind(cli, mem_ctx,
     97        status = dcerpc_drsuapi_DsBind(b, mem_ctx,
    9698                                       &bind_guid,
    9799                                       NULL,
     
    101103        if (!NT_STATUS_IS_OK(status)) {
    102104                return ntstatus_to_werror(status);
     105        }
     106
     107        if (!W_ERROR_IS_OK(werr)) {
     108                return werr;
    103109        }
    104110
     
    126132 out:
    127133        if (is_valid_policy_hnd(&bind_handle)) {
    128                 rpccli_drsuapi_DsUnbind(cli, mem_ctx, &bind_handle, &werr);
     134                WERROR _werr;
     135                dcerpc_drsuapi_DsUnbind(b, mem_ctx, &bind_handle, &_werr);
    129136        }
    130137
     
    235242        struct GUID bind_guid;
    236243        struct policy_handle bind_handle;
     244        struct dcerpc_binding_handle *b = cli->binding_handle;
    237245
    238246        const char *domain = NULL;
     
    254262        GUID_from_string(DRSUAPI_DS_BIND_GUID, &bind_guid);
    255263
    256         status = rpccli_drsuapi_DsBind(cli, mem_ctx,
     264        status = dcerpc_drsuapi_DsBind(b, mem_ctx,
    257265                                       &bind_guid,
    258266                                       NULL,
     
    264272        }
    265273
     274        if (!W_ERROR_IS_OK(werr)) {
     275                return werr;
     276        }
     277
    266278        req.req1.domain_name = domain;
    267279        req.req1.level = level;
    268280
    269         status = rpccli_drsuapi_DsGetDomainControllerInfo(cli, mem_ctx,
     281        status = dcerpc_drsuapi_DsGetDomainControllerInfo(b, mem_ctx,
    270282                                                          &bind_handle,
    271283                                                          1,
     
    286298 out:
    287299        if (is_valid_policy_hnd(&bind_handle)) {
    288                 rpccli_drsuapi_DsUnbind(cli, mem_ctx, &bind_handle, &werr);
     300                WERROR _werr;
     301                dcerpc_drsuapi_DsUnbind(b, mem_ctx, &bind_handle, &_werr);
    289302        }
    290303
     
    300313
    301314        struct policy_handle bind_handle;
     315        struct dcerpc_binding_handle *b = cli->binding_handle;
    302316
    303317        struct GUID bind_guid;
     
    309323        DATA_BLOB session_key;
    310324
    311         int32_t level = 8;
     325        uint32_t level = 8;
    312326        bool single = false;
    313         int32_t level_out = 0;
     327        uint32_t level_out = 0;
    314328        union drsuapi_DsGetNCChangesRequest req;
    315329        union drsuapi_DsGetNCChangesCtr ctr;
     
    319333        struct drsuapi_DsGetNCChangesCtr1 *ctr1 = NULL;
    320334        struct drsuapi_DsGetNCChangesCtr6 *ctr6 = NULL;
    321         int32_t out_level = 0;
     335        uint32_t out_level = 0;
    322336        int y;
    323337
    324338        uint32_t supported_extensions = 0;
    325         uint32_t replica_flags  = DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE |
    326                                   DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP |
    327                                   DRSUAPI_DS_REPLICA_NEIGHBOUR_DO_SCHEDULED_SYNCS |
    328                                   DRSUAPI_DS_REPLICA_NEIGHBOUR_RETURN_OBJECT_PARENTS |
    329                                   DRSUAPI_DS_REPLICA_NEIGHBOUR_NEVER_SYNCED;
     339        uint32_t replica_flags  = DRSUAPI_DRS_WRIT_REP |
     340                                  DRSUAPI_DRS_INIT_SYNC |
     341                                  DRSUAPI_DRS_PER_SYNC |
     342                                  DRSUAPI_DRS_GET_ANC |
     343                                  DRSUAPI_DRS_NEVER_SYNCED;
    330344
    331345        if (argc > 3) {
     
    389403        bind_info.info.info28 = info28;
    390404
    391         status = rpccli_drsuapi_DsBind(cli, mem_ctx,
     405        status = dcerpc_drsuapi_DsBind(b, mem_ctx,
    392406                                       &bind_guid,
    393407                                       &bind_info,
     
    476490                }
    477491
    478                 status = rpccli_drsuapi_DsGetNCChanges(cli, mem_ctx,
     492                status = dcerpc_drsuapi_DsGetNCChanges(b, mem_ctx,
    479493                                                       &bind_handle,
    480494                                                       level,
     
    484498                                                       &werr);
    485499                if (!NT_STATUS_IS_OK(status)) {
     500                        werr = ntstatus_to_werror(status);
     501                        printf("Failed to get NC Changes: %s",
     502                                get_friendly_nt_error_msg(status));
     503                        goto out;
     504                }
     505
     506                if (!W_ERROR_IS_OK(werr)) {
    486507                        printf("Failed to get NC Changes: %s",
    487508                                get_friendly_werror_msg(werr));
    488                         goto out;
    489                 }
    490 
    491                 if (!W_ERROR_IS_OK(werr)) {
    492                         status = werror_to_ntstatus(werr);
    493509                        goto out;
    494510                }
  • vendor/current/source3/rpcclient/cmd_dssetup.c

    r414 r740  
    2222#include "includes.h"
    2323#include "rpcclient.h"
    24 #include "../librpc/gen_ndr/cli_dssetup.h"
     24#include "../librpc/gen_ndr/ndr_dssetup_c.h"
    2525
    2626/* Look up domain related information on a remote host */
     
    3030                                              const char **argv)
    3131{
     32        struct dcerpc_binding_handle *b = cli->binding_handle;
    3233        NTSTATUS status;
    3334        WERROR werr;
    3435        union dssetup_DsRoleInfo info;
    3536
    36         status = rpccli_dssetup_DsRoleGetPrimaryDomainInformation(cli, mem_ctx,
     37        status = dcerpc_dssetup_DsRoleGetPrimaryDomainInformation(b, mem_ctx,
    3738                                                                  DS_ROLE_BASIC_INFORMATION,
    3839                                                                  &info,
  • vendor/current/source3/rpcclient/cmd_echo.c

    r414 r740  
    2121#include "includes.h"
    2222#include "rpcclient.h"
    23 #include "../librpc/gen_ndr/cli_echo.h"
     23#include "../librpc/gen_ndr/ndr_echo_c.h"
    2424
    2525static NTSTATUS cmd_echo_add_one(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
    2626                                 int argc, const char **argv)
    2727{
     28        struct dcerpc_binding_handle *b = cli->binding_handle;
    2829        uint32 request = 1, response;
    29         NTSTATUS result;
     30        NTSTATUS status;
    3031
    3132        if (argc > 2) {
     
    3435        }
    3536
    36         if (argc == 2)
     37        if (argc == 2) {
    3738                request = atoi(argv[1]);
     39        }
    3840
    39         result = rpccli_echo_AddOne(cli, mem_ctx, request, &response);
    40 
    41         if (!NT_STATUS_IS_OK(result))
     41        status = dcerpc_echo_AddOne(b, mem_ctx, request, &response);
     42        if (!NT_STATUS_IS_OK(status)) {
    4243                goto done;
     44        }
    4345
    4446        printf("%d + 1 = %d\n", request, response);
    4547
    4648done:
    47         return result;
     49        return status;
    4850}
    4951
     
    5153                              int argc, const char **argv)
    5254{
     55        struct dcerpc_binding_handle *b = cli->binding_handle;
    5356        uint32 size, i;
    54         NTSTATUS result;
     57        NTSTATUS status;
    5558        uint8_t *in_data = NULL, *out_data = NULL;
    5659
     
    6467                printf("Failure to allocate buff of %d bytes\n",
    6568                       size);
    66                 result = NT_STATUS_NO_MEMORY;
     69                status = NT_STATUS_NO_MEMORY;
    6770                goto done;
    6871        }
     
    7073                printf("Failure to allocate buff of %d bytes\n",
    7174                       size);
    72                 result = NT_STATUS_NO_MEMORY;
     75                status = NT_STATUS_NO_MEMORY;
    7376                goto done;
    7477        }
    7578
    76         for (i = 0; i < size; i++)
     79        for (i = 0; i < size; i++) {
    7780                in_data[i] = i & 0xff;
     81        }
    7882
    79         result = rpccli_echo_EchoData(cli, mem_ctx, size, in_data, out_data);
    80 
    81         if (!NT_STATUS_IS_OK(result))
     83        status = dcerpc_echo_EchoData(b, mem_ctx, size, in_data, out_data);
     84        if (!NT_STATUS_IS_OK(status)) {
    8285                goto done;
     86        }
    8387
    8488        for (i = 0; i < size; i++) {
     
    8690                        printf("mismatch at offset %d, %d != %d\n",
    8791                               i, in_data[i], out_data[i]);
    88                         result = NT_STATUS_UNSUCCESSFUL;
     92                        status = NT_STATUS_UNSUCCESSFUL;
    8993                }
    9094        }
     
    9498        SAFE_FREE(out_data);
    9599
    96         return result;
     100        return status;
    97101}
    98102
     
    101105                                     const char **argv)
    102106{
     107        struct dcerpc_binding_handle *b = cli->binding_handle;
    103108        uint32 size, i;
    104         NTSTATUS result;
     109        NTSTATUS status;
    105110        uint8_t *out_data = NULL;
    106111
     
    114119                printf("Failure to allocate buff of %d bytes\n",
    115120                       size);
    116                 result = NT_STATUS_NO_MEMORY;
     121                status = NT_STATUS_NO_MEMORY;
    117122                goto done;             
    118123        }
    119124       
    120125
    121         result = rpccli_echo_SourceData(cli, mem_ctx, size, out_data);
    122 
    123         if (!NT_STATUS_IS_OK(result))
     126        status = dcerpc_echo_SourceData(b, mem_ctx, size, out_data);
     127        if (!NT_STATUS_IS_OK(status)) {
    124128                goto done;
     129        }
    125130
    126131        for (i = 0; i < size; i++) {
     
    128133                        printf("mismatch at offset %d, %d != %d\n",
    129134                               i, out_data[i], i & 0xff);
    130                         result = NT_STATUS_UNSUCCESSFUL;
     135                        status = NT_STATUS_UNSUCCESSFUL;
    131136                }
    132137        }
     
    135140
    136141        SAFE_FREE(out_data);
    137         return result;
     142        return status;
    138143}
    139144
     
    141146                                   int argc, const char **argv)
    142147{
     148        struct dcerpc_binding_handle *b = cli->binding_handle;
    143149        uint32 size, i;
    144         NTSTATUS result;
     150        NTSTATUS status;
    145151        uint8_t *in_data = NULL;
    146152
     
    154160                printf("Failure to allocate buff of %d bytes\n",
    155161                       size);
    156                 result = NT_STATUS_NO_MEMORY;
     162                status = NT_STATUS_NO_MEMORY;
    157163                goto done;             
    158164        }
    159165
    160         for (i = 0; i < size; i++)
     166        for (i = 0; i < size; i++) {
    161167                in_data[i] = i & 0xff;
     168        }
    162169
    163         result = rpccli_echo_SinkData(cli, mem_ctx, size, in_data);
    164 
    165         if (!NT_STATUS_IS_OK(result))
     170        status = dcerpc_echo_SinkData(b, mem_ctx, size, in_data);
     171        if (!NT_STATUS_IS_OK(status)) {
    166172                goto done;
     173        }
    167174
    168175done:
    169176        SAFE_FREE(in_data);
    170177
    171         return result;
     178        return status;
    172179}
    173180
  • vendor/current/source3/rpcclient/cmd_epmapper.c

    r414 r740  
    2121#include "includes.h"
    2222#include "rpcclient.h"
    23 #include "../librpc/gen_ndr/cli_epmapper.h"
     23#include "../librpc/gen_ndr/ndr_epmapper_c.h"
     24#include "../librpc/gen_ndr/ndr_lsa.h"
    2425
    2526static NTSTATUS cmd_epmapper_map(struct rpc_pipe_client *p,
     
    2728                                 int argc, const char **argv)
    2829{
     30        struct dcerpc_binding_handle *b = p->binding_handle;
    2931        struct dcerpc_binding map_binding;
    3032        struct epm_twr_t map_tower;
    31         struct epm_twr_t res_tower;
    32         struct epm_twr_p_t towers;
     33        struct epm_twr_p_t towers[500];
    3334        struct policy_handle entry_handle;
    3435        struct ndr_syntax_id abstract_syntax;
     
    3637        TALLOC_CTX *tmp_ctx = talloc_stackframe();
    3738        NTSTATUS status;
     39        uint32_t result;
     40        uint32_t i;
    3841
    3942        abstract_syntax = ndr_table_lsarpc.syntax_id;
     
    5255        }
    5356
    54         towers.twr = &res_tower;
     57        ZERO_STRUCT(towers);
     58        ZERO_STRUCT(entry_handle);
    5559
    56         ZERO_STRUCT(entry_handle);
    57         status = rpccli_epm_Map(
    58                 p, tmp_ctx, &abstract_syntax.uuid,
    59                 &map_tower, &entry_handle, 1,
    60                 &num_towers, &towers);
     60        status = dcerpc_epm_Map(
     61                b, tmp_ctx, &abstract_syntax.uuid,
     62                &map_tower, &entry_handle, ARRAY_SIZE(towers),
     63                &num_towers, towers, &result);
     64        if (!NT_STATUS_IS_OK(status)) {
     65                d_fprintf(stderr, "dcerpc_epm_Map returned %s\n",
     66                          nt_errstr(status));
     67                return status;
     68        }
    6169
    62         return status;
     70        if (result != EPMAPPER_STATUS_OK) {
     71                d_fprintf(stderr, "epm_Map returned %u (0x%08X)\n",
     72                          result, result);
     73                return NT_STATUS_UNSUCCESSFUL;
     74        }
     75
     76        d_printf("num_tower[%u]\n", num_towers);
     77
     78        for (i=0; i < num_towers; i++) {
     79                struct dcerpc_binding *binding;
     80
     81                if (towers[i].twr == NULL) {
     82                        d_fprintf(stderr, "tower[%u] NULL\n", i);
     83                        break;
     84                }
     85
     86                status = dcerpc_binding_from_tower(tmp_ctx, &towers[i].twr->tower,
     87                                                   &binding);
     88                if (!NT_STATUS_IS_OK(status)) {
     89                        break;
     90                }
     91
     92                d_printf("tower[%u] %s\n", i, dcerpc_binding_string(tmp_ctx, binding));
     93        }
     94
     95        return NT_STATUS_OK;
    6396}
    6497
     
    67100                                    int argc, const char **argv)
    68101{
     102        struct dcerpc_binding_handle *b = p->binding_handle;
    69103        struct policy_handle entry_handle;
    70104
     
    78112                char *guid_string;
    79113                struct dcerpc_binding *binding;
     114                uint32_t result;
    80115
    81                 status = rpccli_epm_Lookup(p, tmp_ctx,
     116                status = dcerpc_epm_Lookup(b, tmp_ctx,
    82117                                   0, /* rpc_c_ep_all */
    83118                                   NULL,
     
    86121                                   &entry_handle,
    87122                                   1, /* max_ents */
    88                                    &num_entries, &entry);
     123                                   &num_entries, &entry,
     124                                   &result);
    89125                if (!NT_STATUS_IS_OK(status)) {
    90                         d_fprintf(stderr, "rpccli_epm_Lookup returned %s\n",
     126                        d_fprintf(stderr, "dcerpc_epm_Lookup returned %s\n",
    91127                                  nt_errstr(status));
    92128                        break;
    93129                }
    94130
     131                if (result == EPMAPPER_STATUS_NO_MORE_ENTRIES) {
     132                        d_fprintf(stderr, "epm_Lookup no more entries\n");
     133                        break;
     134                }
     135
     136                if (result != EPMAPPER_STATUS_OK) {
     137                        d_fprintf(stderr, "epm_Lookup returned %u (0x%08X)\n",
     138                                  result, result);
     139                        break;
     140                }
     141
    95142                if (num_entries != 1) {
    96                         d_fprintf(stderr, "rpccli_epm_Lookup returned %d "
     143                        d_fprintf(stderr, "epm_Lookup returned %d "
    97144                                  "entries, expected one\n", (int)num_entries);
    98145                        break;
  • vendor/current/source3/rpcclient/cmd_eventlog.c

    r414 r740  
    2121#include "includes.h"
    2222#include "rpcclient.h"
    23 #include "../librpc/gen_ndr/cli_eventlog.h"
     23#include "../librpc/gen_ndr/ndr_eventlog.h"
     24#include "../librpc/gen_ndr/ndr_eventlog_c.h"
     25#include "rpc_client/init_lsa.h"
    2426
    2527static NTSTATUS get_eventlog_handle(struct rpc_pipe_client *cli,
     
    2830                                    struct policy_handle *handle)
    2931{
    30         NTSTATUS status;
     32        NTSTATUS status, result;
    3133        struct eventlog_OpenUnknown0 unknown0;
    3234        struct lsa_String logname, servername;
     35        struct dcerpc_binding_handle *b = cli->binding_handle;
    3336
    3437        unknown0.unknown0 = 0x005c;
     
    3841        init_lsa_String(&servername, NULL);
    3942
    40         status = rpccli_eventlog_OpenEventLogW(cli, mem_ctx,
     43        status = dcerpc_eventlog_OpenEventLogW(b, mem_ctx,
    4144                                               &unknown0,
    4245                                               &logname,
     
    4447                                               0x00000001, /* major */
    4548                                               0x00000001, /* minor */
    46                                                handle);
    47         if (!NT_STATUS_IS_OK(status)) {
    48                 return status;
    49         }
    50 
    51         return NT_STATUS_OK;
     49                                               handle,
     50                                               &result);
     51        if (!NT_STATUS_IS_OK(status)) {
     52                return status;
     53        }
     54
     55        return result;
    5256}
    5357
     
    5862{
    5963        NTSTATUS status = NT_STATUS_OK;
    60         struct policy_handle handle;
     64        NTSTATUS result = NT_STATUS_OK;
     65        struct policy_handle handle;
     66        struct dcerpc_binding_handle *b = cli->binding_handle;
    6167
    6268        uint32_t flags = EVENTLOG_BACKWARDS_READ |
     
    98104                uint32_t pos = 0;
    99105
    100                 status = rpccli_eventlog_ReadEventLogW(cli, mem_ctx,
     106                status = dcerpc_eventlog_ReadEventLogW(b, mem_ctx,
    101107                                                       &handle,
    102108                                                       flags,
     
    105111                                                       data,
    106112                                                       &sent_size,
    107                                                        &real_size);
    108                 if (NT_STATUS_EQUAL(status, NT_STATUS_BUFFER_TOO_SMALL) &&
     113                                                       &real_size,
     114                                                       &result);
     115                if (!NT_STATUS_IS_OK(status)) {
     116                        return status;
     117                }
     118                if (NT_STATUS_EQUAL(result, NT_STATUS_BUFFER_TOO_SMALL) &&
    109119                    real_size > 0 ) {
    110120                        number_of_bytes = real_size;
     
    113123                                goto done;
    114124                        }
    115                         status = rpccli_eventlog_ReadEventLogW(cli, mem_ctx,
     125                        status = dcerpc_eventlog_ReadEventLogW(b, mem_ctx,
    116126                                                               &handle,
    117127                                                               flags,
     
    120130                                                               data,
    121131                                                               &sent_size,
    122                                                                &real_size);
     132                                                               &real_size,
     133                                                               &result);
     134                        if (!NT_STATUS_IS_OK(status)) {
     135                                return status;
     136                        }
    123137                }
    124138
    125                 if (!NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE) &&
    126                     !NT_STATUS_IS_OK(status)) {
     139                if (!NT_STATUS_EQUAL(result, NT_STATUS_END_OF_FILE) &&
     140                    !NT_STATUS_IS_OK(result)) {
    127141                        goto done;
    128142                }
     
    136150                        blob = data_blob_const(data + pos, size);
    137151                        /* dump_data(0, blob.data, blob.length); */
    138                         ndr_err = ndr_pull_struct_blob_all(&blob, mem_ctx, NULL, &r,
     152                        ndr_err = ndr_pull_struct_blob_all(&blob, mem_ctx, &r,
    139153                                           (ndr_pull_flags_fn_t)ndr_pull_EVENTLOGRECORD);
    140154                        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    156170                offset++;
    157171
    158         } while (NT_STATUS_IS_OK(status));
    159 
    160  done:
    161         rpccli_eventlog_CloseEventLog(cli, mem_ctx, &handle);
     172        } while (NT_STATUS_IS_OK(result));
     173
     174 done:
     175        dcerpc_eventlog_CloseEventLog(b, mem_ctx, &handle, &result);
    162176
    163177        return status;
     
    169183                                        const char **argv)
    170184{
    171         NTSTATUS status;
     185        NTSTATUS status, result;
    172186        struct policy_handle handle;
    173187        uint32_t number = 0;
     188        struct dcerpc_binding_handle *b = cli->binding_handle;
    174189
    175190        if (argc != 2) {
     
    183198        }
    184199
    185         status = rpccli_eventlog_GetNumRecords(cli, mem_ctx,
     200        status = dcerpc_eventlog_GetNumRecords(b, mem_ctx,
    186201                                               &handle,
    187                                                &number);
    188         if (!NT_STATUS_IS_OK(status)) {
     202                                               &number,
     203                                               &result);
     204        if (!NT_STATUS_IS_OK(status)) {
     205                goto done;
     206        }
     207        if (!NT_STATUS_IS_OK(result)) {
     208                status = result;
    189209                goto done;
    190210        }
     
    193213
    194214 done:
    195         rpccli_eventlog_CloseEventLog(cli, mem_ctx, &handle);
     215        dcerpc_eventlog_CloseEventLog(b, mem_ctx, &handle, &result);
    196216
    197217        return status;
     
    203223                                          const char **argv)
    204224{
    205         NTSTATUS status;
     225        NTSTATUS status, result;
    206226        struct policy_handle handle;
    207227        uint32_t oldest_entry = 0;
     228        struct dcerpc_binding_handle *b = cli->binding_handle;
    208229
    209230        if (argc != 2) {
     
    217238        }
    218239
    219         status = rpccli_eventlog_GetOldestRecord(cli, mem_ctx,
     240        status = dcerpc_eventlog_GetOldestRecord(b, mem_ctx,
    220241                                                 &handle,
    221                                                  &oldest_entry);
    222         if (!NT_STATUS_IS_OK(status)) {
     242                                                 &oldest_entry,
     243                                                 &result);
     244        if (!NT_STATUS_IS_OK(status)) {
     245                goto done;
     246        }
     247        if (!NT_STATUS_IS_OK(result)) {
     248                status = result;
    223249                goto done;
    224250        }
     
    227253
    228254 done:
    229         rpccli_eventlog_CloseEventLog(cli, mem_ctx, &handle);
     255        dcerpc_eventlog_CloseEventLog(b, mem_ctx, &handle, &result);
    230256
    231257        return status;
     
    237263                                         const char **argv)
    238264{
    239         NTSTATUS status;
    240         struct policy_handle handle;
     265        NTSTATUS status, result;
     266        struct policy_handle handle;
     267        struct dcerpc_binding_handle *b = cli->binding_handle;
    241268
    242269        uint16_t num_of_strings = 1;
     
    266293        init_lsa_String(&servername, NULL);
    267294
    268         status = rpccli_eventlog_ReportEventW(cli, mem_ctx,
     295        status = dcerpc_eventlog_ReportEventW(b, mem_ctx,
    269296                                              &handle,
    270297                                              time(NULL),
     
    280307                                              0, /* flags */
    281308                                              &record_number,
    282                                               &time_written);
    283 
    284         if (!NT_STATUS_IS_OK(status)) {
     309                                              &time_written,
     310                                              &result);
     311
     312        if (!NT_STATUS_IS_OK(status)) {
     313                goto done;
     314        }
     315        if (!NT_STATUS_IS_OK(result)) {
     316                status = result;
    285317                goto done;
    286318        }
     
    290322
    291323 done:
    292         rpccli_eventlog_CloseEventLog(cli, mem_ctx, &handle);
     324        dcerpc_eventlog_CloseEventLog(b, mem_ctx, &handle, &result);
    293325
    294326        return status;
     
    300332                                               const char **argv)
    301333{
    302         NTSTATUS status;
    303         struct policy_handle handle;
     334        NTSTATUS status, result;
     335        struct policy_handle handle;
     336        struct dcerpc_binding_handle *b = cli->binding_handle;
    304337
    305338        uint16_t num_of_strings = 1;
     
    330363        init_lsa_String(&sourcename, "rpcclient");
    331364
    332         status = rpccli_eventlog_ReportEventAndSourceW(cli, mem_ctx,
     365        status = dcerpc_eventlog_ReportEventAndSourceW(b, mem_ctx,
    333366                                                       &handle,
    334367                                                       time(NULL),
     
    345378                                                       0, /* flags */
    346379                                                       &record_number,
    347                                                        &time_written);
    348         if (!NT_STATUS_IS_OK(status)) {
     380                                                       &time_written,
     381                                                       &result);
     382        if (!NT_STATUS_IS_OK(status)) {
     383                goto done;
     384        }
     385        if (!NT_STATUS_IS_OK(result)) {
     386                status = result;
    349387                goto done;
    350388        }
     
    354392
    355393 done:
    356         rpccli_eventlog_CloseEventLog(cli, mem_ctx, &handle);
     394        dcerpc_eventlog_CloseEventLog(b, mem_ctx, &handle, &result);
    357395
    358396        return status;
     
    364402                                              const char **argv)
    365403{
    366         NTSTATUS status;
     404        NTSTATUS status, result;
    367405        struct policy_handle log_handle;
    368406        struct lsa_String module_name, reg_module_name;
    369407        struct eventlog_OpenUnknown0 unknown0;
     408        struct dcerpc_binding_handle *b = cli->binding_handle;
    370409
    371410        unknown0.unknown0 = 0x005c;
     
    380419        init_lsa_String(&reg_module_name, NULL);
    381420
    382         status = rpccli_eventlog_RegisterEventSourceW(cli, mem_ctx,
     421        status = dcerpc_eventlog_RegisterEventSourceW(b, mem_ctx,
    383422                                                      &unknown0,
    384423                                                      &module_name,
     
    386425                                                      1, /* major_version */
    387426                                                      1, /* minor_version */
    388                                                       &log_handle);
    389         if (!NT_STATUS_IS_OK(status)) {
    390                 goto done;
    391         }
    392 
    393  done:
    394         rpccli_eventlog_DeregisterEventSource(cli, mem_ctx, &log_handle);
     427                                                      &log_handle,
     428                                                      &result);
     429        if (!NT_STATUS_IS_OK(status)) {
     430                goto done;
     431        }
     432        if (!NT_STATUS_IS_OK(result)) {
     433                status = result;
     434                goto done;
     435        }
     436
     437 done:
     438        dcerpc_eventlog_DeregisterEventSource(b, mem_ctx, &log_handle, &result);
    395439
    396440        return status;
     
    402446                                       const char **argv)
    403447{
    404         NTSTATUS status;
     448        NTSTATUS status, result;
    405449        struct policy_handle handle;
    406450        struct lsa_String backup_filename;
    407451        const char *tmp;
     452        struct dcerpc_binding_handle *b = cli->binding_handle;
    408453
    409454        if (argc != 3) {
     
    425470        init_lsa_String(&backup_filename, tmp);
    426471
    427         status = rpccli_eventlog_BackupEventLogW(cli, mem_ctx,
     472        status = dcerpc_eventlog_BackupEventLogW(b, mem_ctx,
    428473                                                 &handle,
    429                                                  &backup_filename);
    430 
    431  done:
    432         rpccli_eventlog_CloseEventLog(cli, mem_ctx, &handle);
     474                                                 &backup_filename,
     475                                                 &result);
     476        if (!NT_STATUS_IS_OK(status)) {
     477                goto done;
     478        }
     479        if (!NT_STATUS_IS_OK(result)) {
     480                status = result;
     481                goto done;
     482        }
     483
     484 done:
     485        dcerpc_eventlog_CloseEventLog(b, mem_ctx, &handle, &result);
    433486
    434487        return status;
     
    440493                                     const char **argv)
    441494{
    442         NTSTATUS status;
     495        NTSTATUS status, result;
    443496        struct policy_handle handle;
    444497        uint8_t *buffer = NULL;
    445498        uint32_t buf_size = 0;
    446499        uint32_t bytes_needed = 0;
     500        struct dcerpc_binding_handle *b = cli->binding_handle;
    447501
    448502        if (argc != 2) {
     
    456510        }
    457511
    458         status = rpccli_eventlog_GetLogInformation(cli, mem_ctx,
     512        status = dcerpc_eventlog_GetLogInformation(b, mem_ctx,
    459513                                                   &handle,
    460514                                                   0, /* level */
    461515                                                   buffer,
    462516                                                   buf_size,
    463                                                    &bytes_needed);
    464         if (!NT_STATUS_IS_OK(status) &&
    465             !NT_STATUS_EQUAL(status, NT_STATUS_BUFFER_TOO_SMALL)) {
     517                                                   &bytes_needed,
     518                                                   &result);
     519        if (!NT_STATUS_IS_OK(status)) {
     520                goto done;
     521        }
     522        if (!NT_STATUS_IS_OK(result) &&
     523            !NT_STATUS_EQUAL(result, NT_STATUS_BUFFER_TOO_SMALL)) {
    466524                goto done;
    467525        }
     
    474532        }
    475533
    476         status = rpccli_eventlog_GetLogInformation(cli, mem_ctx,
     534        status = dcerpc_eventlog_GetLogInformation(b, mem_ctx,
    477535                                                   &handle,
    478536                                                   0, /* level */
    479537                                                   buffer,
    480538                                                   buf_size,
    481                                                    &bytes_needed);
    482         if (!NT_STATUS_IS_OK(status)) {
    483                 goto done;
    484         }
    485 
    486  done:
    487         rpccli_eventlog_CloseEventLog(cli, mem_ctx, &handle);
     539                                                   &bytes_needed,
     540                                                   &result);
     541        if (!NT_STATUS_IS_OK(status)) {
     542                goto done;
     543        }
     544        if (!NT_STATUS_IS_OK(result)) {
     545                status = result;
     546                goto done;
     547        }
     548
     549 done:
     550        dcerpc_eventlog_CloseEventLog(b, mem_ctx, &handle, &result);
    488551
    489552        return status;
  • vendor/current/source3/rpcclient/cmd_lsarpc.c

    r414 r740  
    1111   the Free Software Foundation; either version 3 of the License, or
    1212   (at your option) any later version.
    13    
     13
    1414   This program is distributed in the hope that it will be useful,
    1515   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1616   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1717   GNU General Public License for more details.
    18    
     18
    1919   You should have received a copy of the GNU General Public License
    2020   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    2424#include "rpcclient.h"
    2525#include "../libcli/auth/libcli_auth.h"
    26 #include "../librpc/gen_ndr/cli_lsa.h"
     26#include "../librpc/gen_ndr/ndr_lsa.h"
     27#include "../librpc/gen_ndr/ndr_lsa_c.h"
     28#include "rpc_client/cli_lsarpc.h"
     29#include "rpc_client/init_lsa.h"
     30#include "../libcli/security/security.h"
    2731
    2832/* useful function to allow entering a name instead of a SID and
     
    3034static NTSTATUS name_to_sid(struct rpc_pipe_client *cli,
    3135                            TALLOC_CTX *mem_ctx,
    32                             DOM_SID *sid, const char *name)
     36                            struct dom_sid *sid, const char *name)
    3337{
    3438        struct policy_handle pol;
    3539        enum lsa_SidType *sid_types;
    36         NTSTATUS result;
    37         DOM_SID *sids;
     40        NTSTATUS status, result;
     41        struct dom_sid *sids;
     42        struct dcerpc_binding_handle *b = cli->binding_handle;
    3843
    3944        /* maybe its a raw SID */
     
    4348        }
    4449
    45         result = rpccli_lsa_open_policy(cli, mem_ctx, True,
     50        status = rpccli_lsa_open_policy(cli, mem_ctx, True,
    4651                                     SEC_FLAG_MAXIMUM_ALLOWED,
    4752                                     &pol);
    48         if (!NT_STATUS_IS_OK(result))
    49                 goto done;
    50 
    51         result = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, 1, &name, NULL, 1, &sids, &sid_types);
    52         if (!NT_STATUS_IS_OK(result))
    53                 goto done;
    54 
    55         rpccli_lsa_Close(cli, mem_ctx, &pol);
     53        if (!NT_STATUS_IS_OK(status))
     54                goto done;
     55
     56        status = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, 1, &name, NULL, 1, &sids, &sid_types);
     57        if (!NT_STATUS_IS_OK(status))
     58                goto done;
     59
     60        dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
    5661
    5762        *sid = sids[0];
    5863
    5964done:
    60         return result;
     65        return status;
    6166}
    6267
     
    153158{
    154159        struct policy_handle pol;
    155         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     160        NTSTATUS status, result;
    156161        union lsa_PolicyInformation *info = NULL;
     162        struct dcerpc_binding_handle *b = cli->binding_handle;
    157163
    158164        uint32 info_class = 3;
     
    168174        switch (info_class) {
    169175        case 12:
    170                 result = rpccli_lsa_open_policy2(cli, mem_ctx, True,
     176                status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
    171177                                                 SEC_FLAG_MAXIMUM_ALLOWED,
    172178                                                 &pol);
    173179
    174                 if (!NT_STATUS_IS_OK(result))
     180                if (!NT_STATUS_IS_OK(status))
    175181                        goto done;
    176                        
    177                 result = rpccli_lsa_QueryInfoPolicy2(cli, mem_ctx,
     182
     183                status = dcerpc_lsa_QueryInfoPolicy2(b, mem_ctx,
    178184                                                     &pol,
    179185                                                     info_class,
    180                                                      &info);
     186                                                     &info,
     187                                                     &result);
    181188                break;
    182189        default:
    183                 result = rpccli_lsa_open_policy(cli, mem_ctx, True,
     190                status = rpccli_lsa_open_policy(cli, mem_ctx, True,
    184191                                                SEC_FLAG_MAXIMUM_ALLOWED,
    185192                                                &pol);
    186193
    187                 if (!NT_STATUS_IS_OK(result))
     194                if (!NT_STATUS_IS_OK(status))
    188195                        goto done;
    189                
    190                 result = rpccli_lsa_QueryInfoPolicy(cli, mem_ctx,
     196
     197                status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx,
    191198                                                    &pol,
    192199                                                    info_class,
    193                                                     &info);
    194         }
    195 
     200                                                    &info,
     201                                                    &result);
     202        }
     203
     204        if (!NT_STATUS_IS_OK(status)) {
     205                goto done;
     206        }
     207        status = result;
    196208        if (NT_STATUS_IS_OK(result)) {
    197209                display_lsa_query_info(info, info_class);
    198210        }
    199211
    200         rpccli_lsa_Close(cli, mem_ctx, &pol);
    201 
    202  done:
    203         return result;
     212        dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
     213
     214 done:
     215        return status;
    204216}
    205217
     
    211223{
    212224        struct policy_handle pol;
    213         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    214         DOM_SID *sids;
     225        NTSTATUS status, result;
     226        struct dom_sid *sids;
    215227        enum lsa_SidType *types;
    216228        int i;
     229        struct dcerpc_binding_handle *b = cli->binding_handle;
    217230
    218231        if (argc == 1) {
     
    221234        }
    222235
    223         result = rpccli_lsa_open_policy(cli, mem_ctx, True,
     236        status = rpccli_lsa_open_policy(cli, mem_ctx, True,
    224237                                     SEC_FLAG_MAXIMUM_ALLOWED,
    225238                                     &pol);
    226239
    227         if (!NT_STATUS_IS_OK(result))
    228                 goto done;
    229 
    230         result = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 1,
     240        if (!NT_STATUS_IS_OK(status))
     241                goto done;
     242
     243        status = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 1,
    231244                                      (const char**)(argv + 1), NULL, 1, &sids, &types);
    232245
    233         if (!NT_STATUS_IS_OK(result) && NT_STATUS_V(result) !=
     246        if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) !=
    234247            NT_STATUS_V(STATUS_SOME_UNMAPPED))
    235248                goto done;
    236249
    237         result = NT_STATUS_OK;
     250        status = NT_STATUS_OK;
    238251
    239252        /* Print results */
     
    246259        }
    247260
    248         rpccli_lsa_Close(cli, mem_ctx, &pol);
    249 
    250  done:
    251         return result;
     261        dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
     262
     263 done:
     264        return status;
    252265}
    253266
     
    259272{
    260273        struct policy_handle pol;
    261         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    262         DOM_SID *sids;
     274        NTSTATUS status, result;
     275        struct dom_sid *sids;
    263276        enum lsa_SidType *types;
    264277        int i, level;
     278        struct dcerpc_binding_handle *b = cli->binding_handle;
    265279
    266280        if (argc < 3) {
     
    269283        }
    270284
    271         result = rpccli_lsa_open_policy(cli, mem_ctx, True,
     285        status = rpccli_lsa_open_policy(cli, mem_ctx, True,
    272286                                     SEC_FLAG_MAXIMUM_ALLOWED,
    273287                                     &pol);
    274288
    275         if (!NT_STATUS_IS_OK(result))
     289        if (!NT_STATUS_IS_OK(status))
    276290                goto done;
    277291
    278292        level = atoi(argv[1]);
    279293
    280         result = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 2,
     294        status = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 2,
    281295                                      (const char**)(argv + 2), NULL, level, &sids, &types);
    282296
    283         if (!NT_STATUS_IS_OK(result) && NT_STATUS_V(result) !=
     297        if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) !=
    284298            NT_STATUS_V(STATUS_SOME_UNMAPPED))
    285299                goto done;
    286300
    287         result = NT_STATUS_OK;
     301        status = NT_STATUS_OK;
    288302
    289303        /* Print results */
     
    296310        }
    297311
    298         rpccli_lsa_Close(cli, mem_ctx, &pol);
    299 
    300  done:
    301         return result;
     312        dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
     313
     314 done:
     315        return status;
    302316}
    303317
     
    306320                                      const char **argv)
    307321{
    308         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     322        NTSTATUS status, result;
    309323
    310324        uint32_t num_names;
     
    314328        uint32_t count = 0;
    315329        int i;
     330        struct dcerpc_binding_handle *b = cli->binding_handle;
    316331
    317332        if (argc == 1) {
     
    330345        }
    331346
    332         result = rpccli_lsa_LookupNames4(cli, mem_ctx,
     347        status = dcerpc_lsa_LookupNames4(b, mem_ctx,
    333348                                         num_names,
    334349                                         names,
     
    338353                                         &count,
    339354                                         0,
    340                                          0);
     355                                         0,
     356                                         &result);
     357        if (!NT_STATUS_IS_OK(status)) {
     358                return status;
     359        }
    341360        if (!NT_STATUS_IS_OK(result)) {
    342361                return result;
     
    351370        }
    352371
    353         return result;
     372        return status;
    354373}
    355374
     
    360379{
    361380        struct policy_handle pol;
    362         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    363         DOM_SID *sids;
     381        NTSTATUS status, result;
     382        struct dom_sid *sids;
    364383        char **domains;
    365384        char **names;
    366385        enum lsa_SidType *types;
    367386        int i;
     387        struct dcerpc_binding_handle *b = cli->binding_handle;
    368388
    369389        if (argc == 1) {
     
    372392        }
    373393
    374         result = rpccli_lsa_open_policy(cli, mem_ctx, True,
     394        status = rpccli_lsa_open_policy(cli, mem_ctx, True,
    375395                                     SEC_FLAG_MAXIMUM_ALLOWED,
    376396                                     &pol);
    377397
    378         if (!NT_STATUS_IS_OK(result))
     398        if (!NT_STATUS_IS_OK(status))
    379399                goto done;
    380400
    381401        /* Convert arguments to sids */
    382402
    383         sids = TALLOC_ARRAY(mem_ctx, DOM_SID, argc - 1);
     403        sids = TALLOC_ARRAY(mem_ctx, struct dom_sid, argc - 1);
    384404
    385405        if (!sids) {
     
    390410        for (i = 0; i < argc - 1; i++)
    391411                if (!string_to_sid(&sids[i], argv[i + 1])) {
    392                         result = NT_STATUS_INVALID_SID;
     412                        status = NT_STATUS_INVALID_SID;
    393413                        goto done;
    394414                }
     
    396416        /* Lookup the SIDs */
    397417
    398         result = rpccli_lsa_lookup_sids(cli, mem_ctx, &pol, argc - 1, sids,
     418        status = rpccli_lsa_lookup_sids(cli, mem_ctx, &pol, argc - 1, sids,
    399419                                     &domains, &names, &types);
    400420
    401         if (!NT_STATUS_IS_OK(result) && NT_STATUS_V(result) !=
     421        if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) !=
    402422            NT_STATUS_V(STATUS_SOME_UNMAPPED))
    403423                goto done;
    404424
    405         result = NT_STATUS_OK;
     425        status = NT_STATUS_OK;
    406426
    407427        /* Print results */
     
    416436        }
    417437
    418         rpccli_lsa_Close(cli, mem_ctx, &pol);
    419 
    420  done:
    421         return result;
     438        dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
     439
     440 done:
     441        return status;
    422442}
    423443
     
    428448                                     int argc, const char **argv)
    429449{
    430         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     450        NTSTATUS status = NT_STATUS_UNSUCCESSFUL, result;
    431451        int i;
    432452        struct lsa_SidArray sids;
     
    434454        struct lsa_TransNameArray2 names;
    435455        uint32_t count = 0;
     456        struct dcerpc_binding_handle *b = cli->binding_handle;
    436457
    437458        if (argc == 1) {
     
    452473
    453474        for (i = 0; i < sids.num_sids; i++) {
    454                 sids.sids[0].sid = string_sid_talloc(sids.sids, argv[i + 1]);
    455                 if (!sids.sids[0].sid) {
    456                         result = NT_STATUS_INVALID_SID;
     475                sids.sids[i].sid = talloc(sids.sids, struct dom_sid);
     476                if (sids.sids[i].sid == NULL) {
     477                        status = NT_STATUS_NO_MEMORY;
    457478                        goto done;
    458479                }
     480                if (!string_to_sid(sids.sids[i].sid, argv[i+1])) {
     481                        status = NT_STATUS_INVALID_SID;
     482                        goto done;
     483                }
    459484        }
    460485
    461486        /* Lookup the SIDs */
    462         result = rpccli_lsa_LookupSids3(cli, mem_ctx,
     487        status = dcerpc_lsa_LookupSids3(b, mem_ctx,
    463488                                        &sids,
    464489                                        &domains,
     
    467492                                        &count,
    468493                                        0,
    469                                         0);
    470 
     494                                        0,
     495                                        &result);
     496        if (!NT_STATUS_IS_OK(status)) {
     497                goto done;
     498        }
    471499        if (!NT_STATUS_IS_OK(result) && NT_STATUS_V(result) !=
    472             NT_STATUS_V(STATUS_SOME_UNMAPPED))
    473                 goto done;
    474 
    475         result = NT_STATUS_OK;
     500            NT_STATUS_V(STATUS_SOME_UNMAPPED)) {
     501                status = result;
     502                goto done;
     503        }
     504
     505        status = NT_STATUS_OK;
    476506
    477507        /* Print results */
     
    487517
    488518 done:
    489         return result;
     519        return status;
    490520}
    491521
     
    498528{
    499529        struct policy_handle pol;
    500         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     530        NTSTATUS status, result;
    501531        struct lsa_DomainList domain_list;
     532        struct dcerpc_binding_handle *b = cli->binding_handle;
    502533
    503534        /* defaults, but may be changed using params */
     
    515546        }       
    516547
    517         result = rpccli_lsa_open_policy(cli, mem_ctx, True,
     548        status = rpccli_lsa_open_policy(cli, mem_ctx, True,
    518549                                     LSA_POLICY_VIEW_LOCAL_INFORMATION,
    519550                                     &pol);
    520551
    521         if (!NT_STATUS_IS_OK(result))
    522                 goto done;
    523 
    524         result = STATUS_MORE_ENTRIES;
    525 
    526         while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) {
     552        if (!NT_STATUS_IS_OK(status))
     553                goto done;
     554
     555        status = STATUS_MORE_ENTRIES;
     556
     557        while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
    527558
    528559                /* Lookup list of trusted domains */
    529560
    530                 result = rpccli_lsa_EnumTrustDom(cli, mem_ctx,
     561                status = dcerpc_lsa_EnumTrustDom(b, mem_ctx,
    531562                                                 &pol,
    532563                                                 &enum_ctx,
    533564                                                 &domain_list,
    534                                                  max_size);
     565                                                 max_size,
     566                                                 &result);
     567                if (!NT_STATUS_IS_OK(status)) {
     568                        goto done;
     569                }
    535570                if (!NT_STATUS_IS_OK(result) &&
    536571                    !NT_STATUS_EQUAL(result, NT_STATUS_NO_MORE_ENTRIES) &&
    537                     !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES))
     572                    !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) {
     573                        status = result;
    538574                        goto done;
     575                }
    539576
    540577                /* Print results: list of names and sids returned in this
     
    551588        }
    552589
    553         rpccli_lsa_Close(cli, mem_ctx, &pol);
    554  done:
    555         return result;
     590        dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
     591 done:
     592        return status;
    556593}
    557594
     
    563600{
    564601        struct policy_handle pol;
    565         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     602        NTSTATUS status, result;
    566603        struct lsa_PrivArray priv_array;
     604        struct dcerpc_binding_handle *b = cli->binding_handle;
    567605
    568606        uint32 enum_context=0;
     
    581619                pref_max_length=atoi(argv[2]);
    582620
    583         result = rpccli_lsa_open_policy(cli, mem_ctx, True,
     621        status = rpccli_lsa_open_policy(cli, mem_ctx, True,
    584622                                     SEC_FLAG_MAXIMUM_ALLOWED,
    585623                                     &pol);
    586624
    587         if (!NT_STATUS_IS_OK(result))
    588                 goto done;
    589 
    590         result = rpccli_lsa_EnumPrivs(cli, mem_ctx,
     625        if (!NT_STATUS_IS_OK(status))
     626                goto done;
     627
     628        status = dcerpc_lsa_EnumPrivs(b, mem_ctx,
    591629                                      &pol,
    592630                                      &enum_context,
    593631                                      &priv_array,
    594                                       pref_max_length);
    595         if (!NT_STATUS_IS_OK(result))
    596                 goto done;
     632                                      pref_max_length,
     633                                      &result);
     634        if (!NT_STATUS_IS_OK(status))
     635                goto done;
     636        if (!NT_STATUS_IS_OK(result)) {
     637                status = result;
     638                goto done;
     639        }
    597640
    598641        /* Print results */
     
    608651        }
    609652
    610         rpccli_lsa_Close(cli, mem_ctx, &pol);
    611  done:
    612         return result;
     653        dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
     654 done:
     655        return status;
    613656}
    614657
     
    620663{
    621664        struct policy_handle pol;
    622         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     665        NTSTATUS status, result;
     666        struct dcerpc_binding_handle *b = cli->binding_handle;
    623667
    624668        uint16 lang_id=0;
     
    633677        }
    634678
    635         result = rpccli_lsa_open_policy(cli, mem_ctx, True,
     679        status = rpccli_lsa_open_policy(cli, mem_ctx, True,
    636680                                     SEC_FLAG_MAXIMUM_ALLOWED,
    637681                                     &pol);
    638682
    639         if (!NT_STATUS_IS_OK(result))
     683        if (!NT_STATUS_IS_OK(status))
    640684                goto done;
    641685
    642686        init_lsa_String(&lsa_name, argv[1]);
    643687
    644         result = rpccli_lsa_LookupPrivDisplayName(cli, mem_ctx,
     688        status = dcerpc_lsa_LookupPrivDisplayName(b, mem_ctx,
    645689                                                  &pol,
    646690                                                  &lsa_name,
     
    648692                                                  lang_id_sys,
    649693                                                  &description,
    650                                                   &lang_id_desc);
    651 
    652         if (!NT_STATUS_IS_OK(result))
    653                 goto done;
     694                                                  &lang_id_desc,
     695                                                  &result);
     696        if (!NT_STATUS_IS_OK(status))
     697                goto done;
     698        if (!NT_STATUS_IS_OK(result)) {
     699                status = result;
     700                goto done;
     701        }
    654702
    655703        /* Print results */
    656704        printf("%s -> %s (language: 0x%x)\n", argv[1], description->string, lang_id_desc);
    657705
    658         rpccli_lsa_Close(cli, mem_ctx, &pol);
    659  done:
    660         return result;
     706        dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
     707 done:
     708        return status;
    661709}
    662710
     
    668716{
    669717        struct policy_handle pol;
    670         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     718        NTSTATUS status, result;
     719        struct dcerpc_binding_handle *b = cli->binding_handle;
    671720
    672721        uint32 enum_context=0;
     
    686735                pref_max_length=atoi(argv[2]);
    687736
    688         result = rpccli_lsa_open_policy(cli, mem_ctx, True,
     737        status = rpccli_lsa_open_policy(cli, mem_ctx, True,
    689738                                     SEC_FLAG_MAXIMUM_ALLOWED,
    690739                                     &pol);
    691740
    692         if (!NT_STATUS_IS_OK(result))
    693                 goto done;
    694 
    695         result = rpccli_lsa_EnumAccounts(cli, mem_ctx,
     741        if (!NT_STATUS_IS_OK(status))
     742                goto done;
     743
     744        status = dcerpc_lsa_EnumAccounts(b, mem_ctx,
    696745                                         &pol,
    697746                                         &enum_context,
    698747                                         &sid_array,
    699                                          pref_max_length);
    700 
    701         if (!NT_STATUS_IS_OK(result))
    702                 goto done;
     748                                         pref_max_length,
     749                                         &result);
     750        if (!NT_STATUS_IS_OK(status))
     751                goto done;
     752        if (!NT_STATUS_IS_OK(result)) {
     753                status = result;
     754                goto done;
     755        }
    703756
    704757        /* Print results */
     
    712765        }
    713766
    714         rpccli_lsa_Close(cli, mem_ctx, &pol);
    715  done:
    716         return result;
     767        dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
     768 done:
     769        return status;
    717770}
    718771
     
    725778        struct policy_handle dom_pol;
    726779        struct policy_handle user_pol;
    727         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     780        NTSTATUS status, result;
    728781        uint32 des_access = 0x000f000f;
    729        
    730         DOM_SID sid;
     782        struct dcerpc_binding_handle *b = cli->binding_handle;
     783
     784        struct dom_sid sid;
    731785
    732786        if (argc != 2 ) {
     
    735789        }
    736790
    737         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
    738         if (!NT_STATUS_IS_OK(result))
     791        status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
     792        if (!NT_STATUS_IS_OK(status))
    739793                goto done;     
    740794
    741         result = rpccli_lsa_open_policy2(cli, mem_ctx, True,
     795        status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
    742796                                     SEC_FLAG_MAXIMUM_ALLOWED,
    743797                                     &dom_pol);
    744798
    745         if (!NT_STATUS_IS_OK(result))
    746                 goto done;
    747 
    748         result = rpccli_lsa_CreateAccount(cli, mem_ctx,
     799        if (!NT_STATUS_IS_OK(status))
     800                goto done;
     801
     802        status = dcerpc_lsa_CreateAccount(b, mem_ctx,
    749803                                          &dom_pol,
    750804                                          &sid,
    751805                                          des_access,
    752                                           &user_pol);
    753 
    754         if (!NT_STATUS_IS_OK(result))
    755                 goto done;
     806                                          &user_pol,
     807                                          &result);
     808        if (!NT_STATUS_IS_OK(status))
     809                goto done;
     810        if (!NT_STATUS_IS_OK(result)) {
     811                status = result;
     812                goto done;
     813        }
    756814
    757815        printf("Account for SID %s successfully created\n\n", argv[1]);
    758         result = NT_STATUS_OK;
    759 
    760         rpccli_lsa_Close(cli, mem_ctx, &dom_pol);
    761  done:
    762         return result;
     816        status = NT_STATUS_OK;
     817
     818        dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
     819 done:
     820        return status;
    763821}
    764822
     
    772830        struct policy_handle dom_pol;
    773831        struct policy_handle user_pol;
    774         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     832        NTSTATUS status, result;
    775833        uint32 access_desired = 0x000f000f;
    776         DOM_SID sid;
     834        struct dom_sid sid;
    777835        struct lsa_PrivilegeSet *privs = NULL;
    778836        int i;
     837        struct dcerpc_binding_handle *b = cli->binding_handle;
    779838
    780839        if (argc != 2 ) {
     
    783842        }
    784843
    785         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
    786         if (!NT_STATUS_IS_OK(result))
     844        status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
     845        if (!NT_STATUS_IS_OK(status))
    787846                goto done;     
    788847
    789         result = rpccli_lsa_open_policy2(cli, mem_ctx, True,
     848        status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
    790849                                     SEC_FLAG_MAXIMUM_ALLOWED,
    791850                                     &dom_pol);
    792851
    793         if (!NT_STATUS_IS_OK(result))
    794                 goto done;
    795 
    796         result = rpccli_lsa_OpenAccount(cli, mem_ctx,
     852        if (!NT_STATUS_IS_OK(status))
     853                goto done;
     854
     855        status = dcerpc_lsa_OpenAccount(b, mem_ctx,
    797856                                        &dom_pol,
    798857                                        &sid,
    799858                                        access_desired,
    800                                         &user_pol);
    801 
    802         if (!NT_STATUS_IS_OK(result))
    803                 goto done;
    804 
    805         result = rpccli_lsa_EnumPrivsAccount(cli, mem_ctx,
     859                                        &user_pol,
     860                                        &result);
     861        if (!NT_STATUS_IS_OK(status))
     862                goto done;
     863        if (!NT_STATUS_IS_OK(result)) {
     864                status = result;
     865                goto done;
     866        }
     867
     868        status = dcerpc_lsa_EnumPrivsAccount(b, mem_ctx,
    806869                                             &user_pol,
    807                                              &privs);
    808 
    809         if (!NT_STATUS_IS_OK(result))
    810                 goto done;
     870                                             &privs,
     871                                             &result);
     872        if (!NT_STATUS_IS_OK(status))
     873                goto done;
     874        if (!NT_STATUS_IS_OK(result)) {
     875                status = result;
     876                goto done;
     877        }
    811878
    812879        /* Print results */
     
    821888        }
    822889
    823         rpccli_lsa_Close(cli, mem_ctx, &dom_pol);
    824  done:
    825         return result;
     890        dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
     891 done:
     892        return status;
    826893}
    827894
     
    834901{
    835902        struct policy_handle dom_pol;
    836         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    837         DOM_SID sid;
     903        NTSTATUS status, result;
     904        struct dom_sid sid;
    838905        struct lsa_RightSet rights;
     906        struct dcerpc_binding_handle *b = cli->binding_handle;
    839907
    840908        int i;
     
    845913        }
    846914
    847         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
    848         if (!NT_STATUS_IS_OK(result))
     915        status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
     916        if (!NT_STATUS_IS_OK(status))
    849917                goto done;     
    850918
    851         result = rpccli_lsa_open_policy2(cli, mem_ctx, True,
     919        status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
    852920                                     SEC_FLAG_MAXIMUM_ALLOWED,
    853921                                     &dom_pol);
    854922
    855         if (!NT_STATUS_IS_OK(result))
    856                 goto done;
    857 
    858         result = rpccli_lsa_EnumAccountRights(cli, mem_ctx,
     923        if (!NT_STATUS_IS_OK(status))
     924                goto done;
     925
     926        status = dcerpc_lsa_EnumAccountRights(b, mem_ctx,
    859927                                              &dom_pol,
    860928                                              &sid,
    861                                               &rights);
    862 
    863         if (!NT_STATUS_IS_OK(result))
    864                 goto done;
     929                                              &rights,
     930                                              &result);
     931        if (!NT_STATUS_IS_OK(status))
     932                goto done;
     933        if (!NT_STATUS_IS_OK(result)) {
     934                status = result;
     935                goto done;
     936        }
    865937
    866938        printf("found %d privileges for SID %s\n", rights.count,
     
    871943        }
    872944
    873         rpccli_lsa_Close(cli, mem_ctx, &dom_pol);
    874  done:
    875         return result;
     945        dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
     946 done:
     947        return status;
    876948}
    877949
     
    884956{
    885957        struct policy_handle dom_pol;
    886         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     958        NTSTATUS status, result;
    887959        struct lsa_RightSet rights;
    888         DOM_SID sid;
     960        struct dom_sid sid;
    889961        int i;
     962        struct dcerpc_binding_handle *b = cli->binding_handle;
    890963
    891964        if (argc < 3 ) {
     
    894967        }
    895968
    896         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
    897         if (!NT_STATUS_IS_OK(result))
     969        status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
     970        if (!NT_STATUS_IS_OK(status))
    898971                goto done;     
    899972
    900         result = rpccli_lsa_open_policy2(cli, mem_ctx, True,
     973        status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
    901974                                     SEC_FLAG_MAXIMUM_ALLOWED,
    902975                                     &dom_pol);
    903976
    904         if (!NT_STATUS_IS_OK(result))
     977        if (!NT_STATUS_IS_OK(status))
    905978                goto done;
    906979
     
    916989        }
    917990
    918         result = rpccli_lsa_AddAccountRights(cli, mem_ctx,
     991        status = dcerpc_lsa_AddAccountRights(b, mem_ctx,
    919992                                             &dom_pol,
    920993                                             &sid,
    921                                              &rights);
    922 
    923         if (!NT_STATUS_IS_OK(result))
    924                 goto done;
    925 
    926         rpccli_lsa_Close(cli, mem_ctx, &dom_pol);
    927  done:
    928         return result;
     994                                             &rights,
     995                                             &result);
     996        if (!NT_STATUS_IS_OK(status))
     997                goto done;
     998        if (!NT_STATUS_IS_OK(result)) {
     999                status = result;
     1000                goto done;
     1001        }
     1002
     1003        dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
     1004 done:
     1005        return status;
    9291006}
    9301007
     
    9371014{
    9381015        struct policy_handle dom_pol;
    939         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     1016        NTSTATUS status, result;
    9401017        struct lsa_RightSet rights;
    941         DOM_SID sid;
     1018        struct dom_sid sid;
    9421019        int i;
     1020        struct dcerpc_binding_handle *b = cli->binding_handle;
    9431021
    9441022        if (argc < 3 ) {
     
    9471025        }
    9481026
    949         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
    950         if (!NT_STATUS_IS_OK(result))
     1027        status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
     1028        if (!NT_STATUS_IS_OK(status))
    9511029                goto done;     
    9521030
    953         result = rpccli_lsa_open_policy2(cli, mem_ctx, True,
     1031        status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
    9541032                                     SEC_FLAG_MAXIMUM_ALLOWED,
    9551033                                     &dom_pol);
    9561034
    957         if (!NT_STATUS_IS_OK(result))
     1035        if (!NT_STATUS_IS_OK(status))
    9581036                goto done;
    9591037
     
    9691047        }
    9701048
    971         result = rpccli_lsa_RemoveAccountRights(cli, mem_ctx,
     1049        status = dcerpc_lsa_RemoveAccountRights(b, mem_ctx,
    9721050                                                &dom_pol,
    9731051                                                &sid,
    9741052                                                false,
    975                                                 &rights);
    976 
    977         if (!NT_STATUS_IS_OK(result))
    978                 goto done;
    979 
    980         rpccli_lsa_Close(cli, mem_ctx, &dom_pol);
    981 
    982  done:
    983         return result;
     1053                                                &rights,
     1054                                                &result);
     1055        if (!NT_STATUS_IS_OK(status))
     1056                goto done;
     1057        if (!NT_STATUS_IS_OK(result)) {
     1058                status = result;
     1059                goto done;
     1060        }
     1061
     1062        dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
     1063
     1064 done:
     1065        return status;
    9841066}
    9851067
     
    9921074{
    9931075        struct policy_handle pol;
    994         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     1076        NTSTATUS status, result;
    9951077        struct lsa_LUID luid;
    9961078        struct lsa_String name;
     1079        struct dcerpc_binding_handle *b = cli->binding_handle;
    9971080
    9981081        if (argc != 2 ) {
     
    10011084        }
    10021085
    1003         result = rpccli_lsa_open_policy2(cli, mem_ctx, True,
     1086        status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
    10041087                                     SEC_FLAG_MAXIMUM_ALLOWED,
    10051088                                     &pol);
    10061089
    1007         if (!NT_STATUS_IS_OK(result))
     1090        if (!NT_STATUS_IS_OK(status))
    10081091                goto done;
    10091092
    10101093        init_lsa_String(&name, argv[1]);
    10111094
    1012         result = rpccli_lsa_LookupPrivValue(cli, mem_ctx,
     1095        status = dcerpc_lsa_LookupPrivValue(b, mem_ctx,
    10131096                                            &pol,
    10141097                                            &name,
    1015                                             &luid);
    1016 
    1017         if (!NT_STATUS_IS_OK(result))
    1018                 goto done;
     1098                                            &luid,
     1099                                            &result);
     1100        if (!NT_STATUS_IS_OK(status))
     1101                goto done;
     1102        if (!NT_STATUS_IS_OK(result)) {
     1103                status = result;
     1104                goto done;
     1105        }
    10191106
    10201107        /* Print results */
     
    10221109        printf("%u:%u (0x%x:0x%x)\n", luid.high, luid.low, luid.high, luid.low);
    10231110
    1024         rpccli_lsa_Close(cli, mem_ctx, &pol);
    1025  done:
    1026         return result;
     1111        dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
     1112 done:
     1113        return status;
    10271114}
    10281115
     
    10341121{
    10351122        struct policy_handle pol;
    1036         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    1037         SEC_DESC_BUF *sdb;
    1038         uint32 sec_info = DACL_SECURITY_INFORMATION;
     1123        NTSTATUS status, result;
     1124        struct sec_desc_buf *sdb;
     1125        uint32 sec_info = SECINFO_DACL;
     1126        struct dcerpc_binding_handle *b = cli->binding_handle;
    10391127
    10401128        if (argc < 1 || argc > 2) {
     
    10431131        }
    10441132
    1045         result = rpccli_lsa_open_policy2(cli, mem_ctx, True,
     1133        status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
    10461134                                      SEC_FLAG_MAXIMUM_ALLOWED,
    10471135                                      &pol);
     
    10501138                sscanf(argv[1], "%x", &sec_info);
    10511139
    1052         if (!NT_STATUS_IS_OK(result))
    1053                 goto done;
    1054 
    1055         result = rpccli_lsa_QuerySecurity(cli, mem_ctx,
     1140        if (!NT_STATUS_IS_OK(status))
     1141                goto done;
     1142
     1143        status = dcerpc_lsa_QuerySecurity(b, mem_ctx,
    10561144                                          &pol,
    10571145                                          sec_info,
    1058                                           &sdb);
    1059         if (!NT_STATUS_IS_OK(result))
    1060                 goto done;
     1146                                          &sdb,
     1147                                          &result);
     1148        if (!NT_STATUS_IS_OK(status))
     1149                goto done;
     1150        if (!NT_STATUS_IS_OK(result)) {
     1151                status = result;
     1152                goto done;
     1153        }
    10611154
    10621155        /* Print results */
     
    10641157        display_sec_desc(sdb->sd);
    10651158
    1066         rpccli_lsa_Close(cli, mem_ctx, &pol);
    1067  done:
    1068         return result;
     1159        dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
     1160 done:
     1161        return status;
    10691162}
    10701163
     
    10731166{
    10741167        char *pwd, *pwd_old;
    1075        
     1168
    10761169        DATA_BLOB data     = data_blob_const(p->password->data, p->password->length);
    10771170        DATA_BLOB data_old = data_blob_const(p->old_password->data, p->old_password->length);
     
    10801173        pwd     = sess_decrypt_string(talloc_tos(), &data, &session_key_blob);
    10811174        pwd_old = sess_decrypt_string(talloc_tos(), &data_old, &session_key_blob);
    1082        
     1175
    10831176        d_printf("Password:\t%s\n", pwd);
    10841177        d_printf("Old Password:\t%s\n", pwd_old);
     
    11151208{
    11161209        struct policy_handle pol;
    1117         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    1118         DOM_SID dom_sid;
     1210        NTSTATUS status, result;
     1211        struct dom_sid dom_sid;
    11191212        uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
    11201213        union lsa_TrustedDomainInfo *info = NULL;
    11211214        enum lsa_TrustDomInfoEnum info_class = 1;
    11221215        uint8_t nt_hash[16];
     1216        struct dcerpc_binding_handle *b = cli->binding_handle;
    11231217
    11241218        if (argc > 3 || argc < 2) {
     
    11331227                info_class = atoi(argv[2]);
    11341228
    1135         result = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);
    1136 
    1137         if (!NT_STATUS_IS_OK(result))
    1138                 goto done;
    1139 
    1140         result = rpccli_lsa_QueryTrustedDomainInfoBySid(cli, mem_ctx,
     1229        status = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);
     1230
     1231        if (!NT_STATUS_IS_OK(status))
     1232                goto done;
     1233
     1234        status = dcerpc_lsa_QueryTrustedDomainInfoBySid(b, mem_ctx,
    11411235                                                        &pol,
    11421236                                                        &dom_sid,
    11431237                                                        info_class,
    1144                                                         &info);
    1145         if (!NT_STATUS_IS_OK(result))
    1146                 goto done;
     1238                                                        &info,
     1239                                                        &result);
     1240        if (!NT_STATUS_IS_OK(status))
     1241                goto done;
     1242        if (!NT_STATUS_IS_OK(result)) {
     1243                status = result;
     1244                goto done;
     1245        }
    11471246
    11481247        if (!rpccli_get_pwd_hash(cli, nt_hash)) {
     
    11541253
    11551254 done:
    1156         rpccli_lsa_Close(cli, mem_ctx, &pol);
    1157 
    1158         return result;
     1255        dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
     1256
     1257        return status;
    11591258}
    11601259
     
    11641263{
    11651264        struct policy_handle pol;
    1166         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     1265        NTSTATUS status, result;
    11671266        uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
    11681267        union lsa_TrustedDomainInfo *info = NULL;
     
    11701269        struct lsa_String trusted_domain;
    11711270        uint8_t nt_hash[16];
     1271        struct dcerpc_binding_handle *b = cli->binding_handle;
    11721272
    11731273        if (argc > 3 || argc < 2) {
     
    11791279                info_class = atoi(argv[2]);
    11801280
    1181         result = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);
    1182 
    1183         if (!NT_STATUS_IS_OK(result))
     1281        status = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);
     1282
     1283        if (!NT_STATUS_IS_OK(status))
    11841284                goto done;
    11851285
    11861286        init_lsa_String(&trusted_domain, argv[1]);
    11871287
    1188         result = rpccli_lsa_QueryTrustedDomainInfoByName(cli, mem_ctx,
     1288        status = dcerpc_lsa_QueryTrustedDomainInfoByName(b, mem_ctx,
    11891289                                                         &pol,
    11901290                                                         &trusted_domain,
    11911291                                                         info_class,
    1192                                                          &info);
    1193         if (!NT_STATUS_IS_OK(result))
    1194                 goto done;
     1292                                                         &info,
     1293                                                         &result);
     1294        if (!NT_STATUS_IS_OK(status))
     1295                goto done;
     1296        if (!NT_STATUS_IS_OK(result)) {
     1297                status = result;
     1298                goto done;
     1299        }
    11951300
    11961301        if (!rpccli_get_pwd_hash(cli, nt_hash)) {
     
    12021307
    12031308 done:
    1204         rpccli_lsa_Close(cli, mem_ctx, &pol);
    1205 
    1206         return result;
     1309        dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
     1310
     1311        return status;
    12071312}
    12081313
     
    12121317{
    12131318        struct policy_handle pol, trustdom_pol;
    1214         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     1319        NTSTATUS status, result;
    12151320        uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
    12161321        union lsa_TrustedDomainInfo *info = NULL;
    1217         DOM_SID dom_sid;
     1322        struct dom_sid dom_sid;
    12181323        enum lsa_TrustDomInfoEnum info_class = 1;
    12191324        uint8_t nt_hash[16];
     1325        struct dcerpc_binding_handle *b = cli->binding_handle;
    12201326
    12211327        if (argc > 3 || argc < 2) {
     
    12311337                info_class = atoi(argv[2]);
    12321338
    1233         result = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);
    1234 
    1235         if (!NT_STATUS_IS_OK(result))
    1236                 goto done;
    1237 
    1238         result = rpccli_lsa_OpenTrustedDomain(cli, mem_ctx,
     1339        status = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);
     1340
     1341        if (!NT_STATUS_IS_OK(status))
     1342                goto done;
     1343
     1344        status = dcerpc_lsa_OpenTrustedDomain(b, mem_ctx,
    12391345                                              &pol,
    12401346                                              &dom_sid,
    12411347                                              access_mask,
    1242                                               &trustdom_pol);
    1243 
    1244         if (!NT_STATUS_IS_OK(result))
    1245                 goto done;
    1246 
    1247         result = rpccli_lsa_QueryTrustedDomainInfo(cli, mem_ctx,
     1348                                              &trustdom_pol,
     1349                                              &result);
     1350        if (!NT_STATUS_IS_OK(status))
     1351                goto done;
     1352        if (!NT_STATUS_IS_OK(result)) {
     1353                status = result;
     1354                goto done;
     1355        }
     1356
     1357        status = dcerpc_lsa_QueryTrustedDomainInfo(b, mem_ctx,
    12481358                                                   &trustdom_pol,
    12491359                                                   info_class,
    1250                                                    &info);
    1251 
    1252         if (!NT_STATUS_IS_OK(result))
    1253                 goto done;
     1360                                                   &info,
     1361                                                   &result);
     1362        if (!NT_STATUS_IS_OK(status))
     1363                goto done;
     1364        if (!NT_STATUS_IS_OK(result)) {
     1365                status = result;
     1366                goto done;
     1367        }
    12541368
    12551369        if (!rpccli_get_pwd_hash(cli, nt_hash)) {
     
    12611375
    12621376 done:
    1263         rpccli_lsa_Close(cli, mem_ctx, &pol);
    1264 
    1265         return result;
     1377        dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
     1378
     1379        return status;
    12661380}
    12671381
     
    12711385{
    12721386        struct policy_handle pol;
    1273         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     1387        NTSTATUS status, result;
    12741388        const char *servername = cli->desthost;
    12751389        struct lsa_String *account_name = NULL;
    12761390        struct lsa_String *authority_name = NULL;
     1391        struct dcerpc_binding_handle *b = cli->binding_handle;
    12771392
    12781393        if (argc > 2) {
     
    12811396        }
    12821397
    1283         result = rpccli_lsa_open_policy(cli, mem_ctx, true,
     1398        status = rpccli_lsa_open_policy(cli, mem_ctx, true,
    12841399                                        SEC_FLAG_MAXIMUM_ALLOWED,
    12851400                                        &pol);
    12861401
    1287         if (!NT_STATUS_IS_OK(result)) {
    1288                 goto done;
    1289         }
    1290 
    1291         result = rpccli_lsa_GetUserName(cli, mem_ctx,
     1402        if (!NT_STATUS_IS_OK(status)) {
     1403                goto done;
     1404        }
     1405
     1406        status = dcerpc_lsa_GetUserName(b, mem_ctx,
    12921407                                        servername,
    12931408                                        &account_name,
    1294                                         &authority_name);
    1295         if (!NT_STATUS_IS_OK(result)) {
     1409                                        &authority_name,
     1410                                        &result);
     1411        if (!NT_STATUS_IS_OK(status)) {
     1412                goto done;
     1413        }
     1414        if (!NT_STATUS_IS_OK(result)) {
     1415                status = result;
    12961416                goto done;
    12971417        }
     
    13031423                "");
    13041424
    1305         rpccli_lsa_Close(cli, mem_ctx, &pol);
    1306  done:
    1307         return result;
     1425        dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
     1426 done:
     1427        return status;
    13081428}
    13091429
     
    13131433{
    13141434        struct policy_handle dom_pol, user_pol;
    1315         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     1435        NTSTATUS status, result;
    13161436        struct lsa_PrivilegeSet privs;
    13171437        struct lsa_LUIDAttribute *set = NULL;
    1318         DOM_SID sid;
     1438        struct dom_sid sid;
    13191439        int i;
     1440        struct dcerpc_binding_handle *b = cli->binding_handle;
    13201441
    13211442        ZERO_STRUCT(privs);
     
    13261447        }
    13271448
    1328         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
    1329         if (!NT_STATUS_IS_OK(result)) {
    1330                 goto done;
    1331         }
    1332 
    1333         result = rpccli_lsa_open_policy2(cli, mem_ctx, True,
     1449        status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
     1450        if (!NT_STATUS_IS_OK(status)) {
     1451                goto done;
     1452        }
     1453
     1454        status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
    13341455                                         SEC_FLAG_MAXIMUM_ALLOWED,
    13351456                                         &dom_pol);
    13361457
    1337         if (!NT_STATUS_IS_OK(result)) {
    1338                 goto done;
    1339         }
    1340 
    1341         result = rpccli_lsa_OpenAccount(cli, mem_ctx,
     1458        if (!NT_STATUS_IS_OK(status)) {
     1459                goto done;
     1460        }
     1461
     1462        status = dcerpc_lsa_OpenAccount(b, mem_ctx,
    13421463                                        &dom_pol,
    13431464                                        &sid,
    13441465                                        SEC_FLAG_MAXIMUM_ALLOWED,
    1345                                         &user_pol);
    1346 
    1347         if (!NT_STATUS_IS_OK(result)) {
     1466                                        &user_pol,
     1467                                        &result);
     1468        if (!NT_STATUS_IS_OK(status)) {
     1469                goto done;
     1470        }
     1471        if (!NT_STATUS_IS_OK(result)) {
     1472                status = result;
    13481473                goto done;
    13491474        }
     
    13561481                init_lsa_String(&priv_name, argv[i]);
    13571482
    1358                 result = rpccli_lsa_LookupPrivValue(cli, mem_ctx,
     1483                status = dcerpc_lsa_LookupPrivValue(b, mem_ctx,
    13591484                                                    &dom_pol,
    13601485                                                    &priv_name,
    1361                                                     &luid);
     1486                                                    &luid,
     1487                                                    &result);
     1488                if (!NT_STATUS_IS_OK(status)) {
     1489                        continue;
     1490                }
    13621491                if (!NT_STATUS_IS_OK(result)) {
     1492                        status = result;
    13631493                        continue;
    13641494                }
     
    13781508        privs.set = set;
    13791509
    1380         result = rpccli_lsa_AddPrivilegesToAccount(cli, mem_ctx,
     1510        status = dcerpc_lsa_AddPrivilegesToAccount(b, mem_ctx,
    13811511                                                   &user_pol,
    1382                                                    &privs);
    1383 
    1384         if (!NT_STATUS_IS_OK(result)) {
    1385                 goto done;
    1386         }
    1387 
    1388         rpccli_lsa_Close(cli, mem_ctx, &user_pol);
    1389         rpccli_lsa_Close(cli, mem_ctx, &dom_pol);
    1390  done:
    1391         return result;
     1512                                                   &privs,
     1513                                                   &result);
     1514        if (!NT_STATUS_IS_OK(status)) {
     1515                goto done;
     1516        }
     1517        if (!NT_STATUS_IS_OK(result)) {
     1518                status = result;
     1519                goto done;
     1520        }
     1521
     1522        dcerpc_lsa_Close(b, mem_ctx, &user_pol, &result);
     1523        dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
     1524 done:
     1525        return status;
    13921526}
    13931527
     
    13971531{
    13981532        struct policy_handle dom_pol, user_pol;
    1399         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     1533        NTSTATUS status, result;
    14001534        struct lsa_PrivilegeSet privs;
    14011535        struct lsa_LUIDAttribute *set = NULL;
    1402         DOM_SID sid;
     1536        struct dom_sid sid;
    14031537        int i;
     1538        struct dcerpc_binding_handle *b = cli->binding_handle;
    14041539
    14051540        ZERO_STRUCT(privs);
     
    14101545        }
    14111546
    1412         result = name_to_sid(cli, mem_ctx, &sid, argv[1]);
    1413         if (!NT_STATUS_IS_OK(result)) {
    1414                 goto done;
    1415         }
    1416 
    1417         result = rpccli_lsa_open_policy2(cli, mem_ctx, True,
     1547        status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
     1548        if (!NT_STATUS_IS_OK(status)) {
     1549                goto done;
     1550        }
     1551
     1552        status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
    14181553                                         SEC_FLAG_MAXIMUM_ALLOWED,
    14191554                                         &dom_pol);
    14201555
    1421         if (!NT_STATUS_IS_OK(result)) {
    1422                 goto done;
    1423         }
    1424 
    1425         result = rpccli_lsa_OpenAccount(cli, mem_ctx,
     1556        if (!NT_STATUS_IS_OK(status)) {
     1557                goto done;
     1558        }
     1559
     1560        status = dcerpc_lsa_OpenAccount(b, mem_ctx,
    14261561                                        &dom_pol,
    14271562                                        &sid,
    14281563                                        SEC_FLAG_MAXIMUM_ALLOWED,
    1429                                         &user_pol);
    1430 
    1431         if (!NT_STATUS_IS_OK(result)) {
     1564                                        &user_pol,
     1565                                        &result);
     1566        if (!NT_STATUS_IS_OK(status)) {
     1567                goto done;
     1568        }
     1569        if (!NT_STATUS_IS_OK(result)) {
     1570                status = result;
    14321571                goto done;
    14331572        }
     
    14401579                init_lsa_String(&priv_name, argv[i]);
    14411580
    1442                 result = rpccli_lsa_LookupPrivValue(cli, mem_ctx,
     1581                status = dcerpc_lsa_LookupPrivValue(b, mem_ctx,
    14431582                                                    &dom_pol,
    14441583                                                    &priv_name,
    1445                                                     &luid);
     1584                                                    &luid,
     1585                                                    &result);
     1586                if (!NT_STATUS_IS_OK(status)) {
     1587                        continue;
     1588                }
    14461589                if (!NT_STATUS_IS_OK(result)) {
     1590                        status = result;
    14471591                        continue;
    14481592                }
     
    14631607
    14641608
    1465         result = rpccli_lsa_RemovePrivilegesFromAccount(cli, mem_ctx,
     1609        status = dcerpc_lsa_RemovePrivilegesFromAccount(b, mem_ctx,
    14661610                                                        &user_pol,
    14671611                                                        false,
    1468                                                         &privs);
    1469 
    1470         if (!NT_STATUS_IS_OK(result)) {
    1471                 goto done;
    1472         }
    1473 
    1474         rpccli_lsa_Close(cli, mem_ctx, &user_pol);
    1475         rpccli_lsa_Close(cli, mem_ctx, &dom_pol);
    1476  done:
    1477         return result;
     1612                                                        &privs,
     1613                                                        &result);
     1614        if (!NT_STATUS_IS_OK(status)) {
     1615                goto done;
     1616        }
     1617        if (!NT_STATUS_IS_OK(result)) {
     1618                status = result;
     1619                goto done;
     1620        }
     1621
     1622        dcerpc_lsa_Close(b, mem_ctx, &user_pol, &result);
     1623        dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
     1624 done:
     1625        return status;
    14781626}
    14791627
     
    14821630                                      const char **argv)
    14831631{
    1484         NTSTATUS status;
     1632        NTSTATUS status, result;
    14851633        struct policy_handle handle, sec_handle;
    14861634        struct lsa_String name;
     1635        struct dcerpc_binding_handle *b = cli->binding_handle;
    14871636
    14881637        if (argc < 2) {
     
    15011650        init_lsa_String(&name, argv[1]);
    15021651
    1503         status = rpccli_lsa_CreateSecret(cli, mem_ctx,
     1652        status = dcerpc_lsa_CreateSecret(b, mem_ctx,
    15041653                                         &handle,
    15051654                                         name,
    15061655                                         SEC_FLAG_MAXIMUM_ALLOWED,
    1507                                          &sec_handle);
    1508         if (!NT_STATUS_IS_OK(status)) {
     1656                                         &sec_handle,
     1657                                         &result);
     1658        if (!NT_STATUS_IS_OK(status)) {
     1659                goto done;
     1660        }
     1661        if (!NT_STATUS_IS_OK(result)) {
     1662                status = result;
    15091663                goto done;
    15101664        }
     
    15121666 done:
    15131667        if (is_valid_policy_hnd(&sec_handle)) {
    1514                 rpccli_lsa_Close(cli, mem_ctx, &sec_handle);
     1668                dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result);
    15151669        }
    15161670        if (is_valid_policy_hnd(&handle)) {
    1517                 rpccli_lsa_Close(cli, mem_ctx, &handle);
     1671                dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
    15181672        }
    15191673
     
    15251679                                      const char **argv)
    15261680{
    1527         NTSTATUS status;
     1681        NTSTATUS status, result;
    15281682        struct policy_handle handle, sec_handle;
    15291683        struct lsa_String name;
     1684        struct dcerpc_binding_handle *b = cli->binding_handle;
    15301685
    15311686        if (argc < 2) {
     
    15441699        init_lsa_String(&name, argv[1]);
    15451700
    1546         status = rpccli_lsa_OpenSecret(cli, mem_ctx,
     1701        status = dcerpc_lsa_OpenSecret(b, mem_ctx,
    15471702                                       &handle,
    15481703                                       name,
    15491704                                       SEC_FLAG_MAXIMUM_ALLOWED,
    1550                                        &sec_handle);
    1551         if (!NT_STATUS_IS_OK(status)) {
    1552                 goto done;
    1553         }
    1554 
    1555         status = rpccli_lsa_DeleteObject(cli, mem_ctx,
    1556                                          &sec_handle);
    1557         if (!NT_STATUS_IS_OK(status)) {
     1705                                       &sec_handle,
     1706                                       &result);
     1707        if (!NT_STATUS_IS_OK(status)) {
     1708                goto done;
     1709        }
     1710        if (!NT_STATUS_IS_OK(result)) {
     1711                status = result;
     1712                goto done;
     1713        }
     1714
     1715        status = dcerpc_lsa_DeleteObject(b, mem_ctx,
     1716                                         &sec_handle,
     1717                                         &result);
     1718        if (!NT_STATUS_IS_OK(status)) {
     1719                goto done;
     1720        }
     1721        if (!NT_STATUS_IS_OK(result)) {
     1722                status = result;
    15581723                goto done;
    15591724        }
     
    15611726 done:
    15621727        if (is_valid_policy_hnd(&sec_handle)) {
    1563                 rpccli_lsa_Close(cli, mem_ctx, &sec_handle);
     1728                dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result);
    15641729        }
    15651730        if (is_valid_policy_hnd(&handle)) {
    1566                 rpccli_lsa_Close(cli, mem_ctx, &handle);
     1731                dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
    15671732        }
    15681733
     
    15741739                                     const char **argv)
    15751740{
    1576         NTSTATUS status;
     1741        NTSTATUS status, result;
    15771742        struct policy_handle handle, sec_handle;
    15781743        struct lsa_String name;
     
    15851750        DATA_BLOB old_blob = data_blob_null;
    15861751        char *new_secret, *old_secret;
     1752        struct dcerpc_binding_handle *b = cli->binding_handle;
    15871753
    15881754        if (argc < 2) {
     
    16011767        init_lsa_String(&name, argv[1]);
    16021768
    1603         status = rpccli_lsa_OpenSecret(cli, mem_ctx,
     1769        status = dcerpc_lsa_OpenSecret(b, mem_ctx,
    16041770                                       &handle,
    16051771                                       name,
    16061772                                       SEC_FLAG_MAXIMUM_ALLOWED,
    1607                                        &sec_handle);
    1608         if (!NT_STATUS_IS_OK(status)) {
     1773                                       &sec_handle,
     1774                                       &result);
     1775        if (!NT_STATUS_IS_OK(status)) {
     1776                goto done;
     1777        }
     1778        if (!NT_STATUS_IS_OK(result)) {
     1779                status = result;
    16091780                goto done;
    16101781        }
     
    16131784        ZERO_STRUCT(old_val);
    16141785
    1615         status = rpccli_lsa_QuerySecret(cli, mem_ctx,
     1786        status = dcerpc_lsa_QuerySecret(b, mem_ctx,
    16161787                                        &sec_handle,
    16171788                                        &new_val,
    16181789                                        &new_mtime,
    16191790                                        &old_val,
    1620                                         &old_mtime);
    1621         if (!NT_STATUS_IS_OK(status)) {
     1791                                        &old_mtime,
     1792                                        &result);
     1793        if (!NT_STATUS_IS_OK(status)) {
     1794                goto done;
     1795        }
     1796        if (!NT_STATUS_IS_OK(result)) {
     1797                status = result;
    16221798                goto done;
    16231799        }
     
    16461822 done:
    16471823        if (is_valid_policy_hnd(&sec_handle)) {
    1648                 rpccli_lsa_Close(cli, mem_ctx, &sec_handle);
     1824                dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result);
    16491825        }
    16501826        if (is_valid_policy_hnd(&handle)) {
    1651                 rpccli_lsa_Close(cli, mem_ctx, &handle);
     1827                dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
    16521828        }
    16531829
     
    16591835                                   const char **argv)
    16601836{
    1661         NTSTATUS status;
     1837        NTSTATUS status, result;
    16621838        struct policy_handle handle, sec_handle;
    16631839        struct lsa_String name;
     
    16661842        DATA_BLOB enc_key;
    16671843        DATA_BLOB session_key;
     1844        struct dcerpc_binding_handle *b = cli->binding_handle;
    16681845
    16691846        if (argc < 3) {
     
    16821859        init_lsa_String(&name, argv[1]);
    16831860
    1684         status = rpccli_lsa_OpenSecret(cli, mem_ctx,
     1861        status = dcerpc_lsa_OpenSecret(b, mem_ctx,
    16851862                                       &handle,
    16861863                                       name,
    16871864                                       SEC_FLAG_MAXIMUM_ALLOWED,
    1688                                        &sec_handle);
    1689         if (!NT_STATUS_IS_OK(status)) {
     1865                                       &sec_handle,
     1866                                       &result);
     1867        if (!NT_STATUS_IS_OK(status)) {
     1868                goto done;
     1869        }
     1870        if (!NT_STATUS_IS_OK(result)) {
     1871                status = result;
    16901872                goto done;
    16911873        }
     
    17051887        new_val.data = enc_key.data;
    17061888
    1707         status = rpccli_lsa_SetSecret(cli, mem_ctx,
     1889        status = dcerpc_lsa_SetSecret(b, mem_ctx,
    17081890                                      &sec_handle,
    17091891                                      &new_val,
    1710                                       NULL);
    1711         if (!NT_STATUS_IS_OK(status)) {
     1892                                      NULL,
     1893                                      &result);
     1894        if (!NT_STATUS_IS_OK(status)) {
     1895                goto done;
     1896        }
     1897        if (!NT_STATUS_IS_OK(result)) {
     1898                status = result;
    17121899                goto done;
    17131900        }
     
    17151902 done:
    17161903        if (is_valid_policy_hnd(&sec_handle)) {
    1717                 rpccli_lsa_Close(cli, mem_ctx, &sec_handle);
     1904                dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result);
    17181905        }
    17191906        if (is_valid_policy_hnd(&handle)) {
    1720                 rpccli_lsa_Close(cli, mem_ctx, &handle);
     1907                dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
    17211908        }
    17221909
     
    17281915                                              const char **argv)
    17291916{
    1730         NTSTATUS status;
     1917        NTSTATUS status, result;
    17311918        struct policy_handle handle;
    17321919        struct lsa_String name;
     
    17351922        DATA_BLOB blob = data_blob_null;
    17361923        char *secret;
     1924        struct dcerpc_binding_handle *b = cli->binding_handle;
    17371925
    17381926        if (argc < 2) {
     
    17531941        ZERO_STRUCT(val);
    17541942
    1755         status = rpccli_lsa_RetrievePrivateData(cli, mem_ctx,
     1943        status = dcerpc_lsa_RetrievePrivateData(b, mem_ctx,
    17561944                                                &handle,
    17571945                                                &name,
    1758                                                 &val);
    1759         if (!NT_STATUS_IS_OK(status)) {
     1946                                                &val,
     1947                                                &result);
     1948        if (!NT_STATUS_IS_OK(status)) {
     1949                goto done;
     1950        }
     1951        if (!NT_STATUS_IS_OK(result)) {
     1952                status = result;
    17601953                goto done;
    17611954        }
     
    17771970 done:
    17781971        if (is_valid_policy_hnd(&handle)) {
    1779                 rpccli_lsa_Close(cli, mem_ctx, &handle);
     1972                dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
    17801973        }
    17811974
     
    17871980                                           const char **argv)
    17881981{
    1789         NTSTATUS status;
     1982        NTSTATUS status, result;
    17901983        struct policy_handle handle;
    17911984        struct lsa_String name;
     
    17931986        DATA_BLOB session_key;
    17941987        DATA_BLOB enc_key;
     1988        struct dcerpc_binding_handle *b = cli->binding_handle;
    17951989
    17961990        if (argc < 3) {
     
    18222016        val.data = enc_key.data;
    18232017
    1824         status = rpccli_lsa_StorePrivateData(cli, mem_ctx,
     2018        status = dcerpc_lsa_StorePrivateData(b, mem_ctx,
    18252019                                             &handle,
    18262020                                             &name,
    1827                                              &val);
    1828         if (!NT_STATUS_IS_OK(status)) {
     2021                                             &val,
     2022                                             &result);
     2023        if (!NT_STATUS_IS_OK(status)) {
     2024                goto done;
     2025        }
     2026        if (!NT_STATUS_IS_OK(result)) {
     2027                status = result;
    18292028                goto done;
    18302029        }
     
    18322031 done:
    18332032        if (is_valid_policy_hnd(&handle)) {
    1834                 rpccli_lsa_Close(cli, mem_ctx, &handle);
     2033                dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
    18352034        }
    18362035
     
    18422041                                              const char **argv)
    18432042{
    1844         NTSTATUS status;
     2043        NTSTATUS status, result;
    18452044        struct policy_handle handle, trustdom_handle;
     2045        struct dom_sid sid;
    18462046        struct lsa_DomainInfo info;
     2047        struct dcerpc_binding_handle *b = cli->binding_handle;
    18472048
    18482049        if (argc < 3) {
     
    18602061
    18612062        init_lsa_StringLarge(&info.name, argv[1]);
    1862         info.sid = string_sid_talloc(mem_ctx, argv[2]);
    1863 
    1864         status = rpccli_lsa_CreateTrustedDomain(cli, mem_ctx,
     2063        info.sid = &sid;
     2064        string_to_sid(&sid, argv[2]);
     2065
     2066        status = dcerpc_lsa_CreateTrustedDomain(b, mem_ctx,
    18652067                                                &handle,
    18662068                                                &info,
    18672069                                                SEC_FLAG_MAXIMUM_ALLOWED,
    1868                                                 &trustdom_handle);
    1869         if (!NT_STATUS_IS_OK(status)) {
     2070                                                &trustdom_handle,
     2071                                                &result);
     2072        if (!NT_STATUS_IS_OK(status)) {
     2073                goto done;
     2074        }
     2075        if (!NT_STATUS_IS_OK(result)) {
     2076                status = result;
    18702077                goto done;
    18712078        }
     
    18732080 done:
    18742081        if (is_valid_policy_hnd(&trustdom_handle)) {
    1875                 rpccli_lsa_Close(cli, mem_ctx, &trustdom_handle);
     2082                dcerpc_lsa_Close(b, mem_ctx, &trustdom_handle, &result);
    18762083        }
    18772084
    18782085        if (is_valid_policy_hnd(&handle)) {
    1879                 rpccli_lsa_Close(cli, mem_ctx, &handle);
     2086                dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
    18802087        }
    18812088
     
    18872094                                              const char **argv)
    18882095{
    1889         NTSTATUS status;
     2096        NTSTATUS status, result;
    18902097        struct policy_handle handle, trustdom_handle;
    18912098        struct lsa_String name;
    18922099        struct dom_sid *sid = NULL;
     2100        struct dcerpc_binding_handle *b = cli->binding_handle;
    18932101
    18942102        if (argc < 2) {
     
    19072115        init_lsa_String(&name, argv[1]);
    19082116
    1909         status = rpccli_lsa_OpenTrustedDomainByName(cli, mem_ctx,
     2117        status = dcerpc_lsa_OpenTrustedDomainByName(b, mem_ctx,
    19102118                                                    &handle,
    19112119                                                    name,
    19122120                                                    SEC_FLAG_MAXIMUM_ALLOWED,
    1913                                                     &trustdom_handle);
    1914         if (NT_STATUS_IS_OK(status)) {
     2121                                                    &trustdom_handle,
     2122                                                    &result);
     2123        if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(result)) {
    19152124                goto delete_object;
    19162125        }
     
    19212130                int i;
    19222131
    1923                 status = rpccli_lsa_EnumTrustDom(cli, mem_ctx,
     2132                status = dcerpc_lsa_EnumTrustDom(b, mem_ctx,
    19242133                                                 &handle,
    19252134                                                 &resume_handle,
    19262135                                                 &domains,
    1927                                                  0xffff);
     2136                                                 0xffff,
     2137                                                 &result);
    19282138                if (!NT_STATUS_IS_OK(status)) {
     2139                        goto done;
     2140                }
     2141                if (!NT_STATUS_IS_OK(result)) {
     2142                        status = result;
    19292143                        goto done;
    19302144                }
     
    19422156        }
    19432157
    1944         status = rpccli_lsa_OpenTrustedDomain(cli, mem_ctx,
     2158        status = dcerpc_lsa_OpenTrustedDomain(b, mem_ctx,
    19452159                                              &handle,
    19462160                                              sid,
    19472161                                              SEC_FLAG_MAXIMUM_ALLOWED,
    1948                                               &trustdom_handle);
    1949         if (!NT_STATUS_IS_OK(status)) {
     2162                                              &trustdom_handle,
     2163                                              &result);
     2164        if (!NT_STATUS_IS_OK(status)) {
     2165                goto done;
     2166        }
     2167        if (!NT_STATUS_IS_OK(result)) {
     2168                status = result;
    19502169                goto done;
    19512170        }
    19522171
    19532172 delete_object:
    1954         status = rpccli_lsa_DeleteObject(cli, mem_ctx,
    1955                                          &trustdom_handle);
    1956         if (!NT_STATUS_IS_OK(status)) {
     2173        status = dcerpc_lsa_DeleteObject(b, mem_ctx,
     2174                                         &trustdom_handle,
     2175                                         &result);
     2176        if (!NT_STATUS_IS_OK(status)) {
     2177                goto done;
     2178        }
     2179        if (!NT_STATUS_IS_OK(result)) {
     2180                status = result;
    19572181                goto done;
    19582182        }
     
    19602184 done:
    19612185        if (is_valid_policy_hnd(&trustdom_handle)) {
    1962                 rpccli_lsa_Close(cli, mem_ctx, &trustdom_handle);
     2186                dcerpc_lsa_Close(b, mem_ctx, &trustdom_handle, &result);
    19632187        }
    19642188
    19652189        if (is_valid_policy_hnd(&handle)) {
    1966                 rpccli_lsa_Close(cli, mem_ctx, &handle);
     2190                dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
    19672191        }
    19682192
  • vendor/current/source3/rpcclient/cmd_netlogon.c

    r414 r740  
    2323#include "rpcclient.h"
    2424#include "../libcli/auth/libcli_auth.h"
    25 #include "../librpc/gen_ndr/cli_netlogon.h"
     25#include "../librpc/gen_ndr/ndr_netlogon.h"
     26#include "../librpc/gen_ndr/ndr_netlogon_c.h"
     27#include "rpc_client/cli_netlogon.h"
     28#include "secrets.h"
    2629
    2730static WERROR cmd_netlogon_logon_ctrl2(struct rpc_pipe_client *cli,
     
    3740        union netr_CONTROL_QUERY_INFORMATION query;
    3841        const char *domain = lp_workgroup();
     42        struct dcerpc_binding_handle *b = cli->binding_handle;
    3943
    4044        if (argc > 5) {
     
    6973        }
    7074
    71         status = rpccli_netr_LogonControl2(cli, mem_ctx,
     75        status = dcerpc_netr_LogonControl2(b, mem_ctx,
    7276                                          logon_server,
    7377                                          function_code,
     
    97101        NTSTATUS status;
    98102        int old_timeout;
     103        struct dcerpc_binding_handle *b = cli->binding_handle;
    99104
    100105        if (argc != 2) {
     
    107112        rpccli_set_timeout(cli, MAX(old_timeout, 30000)); /* At least 30 sec */
    108113
    109         status = rpccli_netr_GetAnyDCName(cli, mem_ctx,
     114        status = dcerpc_netr_GetAnyDCName(b, mem_ctx,
    110115                                          cli->desthost,
    111116                                          argv[1],
     
    137142        WERROR werr;
    138143        int old_timeout;
     144        struct dcerpc_binding_handle *b = cli->binding_handle;
    139145
    140146        if (argc != 2) {
     
    147153        rpccli_set_timeout(cli, MAX(30000, old_timeout)); /* At least 30 sec */
    148154
    149         status = rpccli_netr_GetDcName(cli, mem_ctx,
     155        status = dcerpc_netr_GetDcName(b, mem_ctx,
    150156                                       cli->desthost,
    151157                                       argv[1],
     
    181187        struct GUID site_guid = GUID_zero();
    182188        struct netr_DsRGetDCNameInfo *info = NULL;
     189        struct dcerpc_binding_handle *b = cli->binding_handle;
    183190
    184191        if (argc < 2) {
     
    208215        debug_dsdcinfo_flags(1,flags);
    209216
    210         result = rpccli_netr_DsRGetDCName(cli, mem_ctx,
     217        result = dcerpc_netr_DsRGetDCName(b, mem_ctx,
    211218                                          server_name,
    212219                                          domain_name,
     
    216223                                          &info,
    217224                                          &werr);
     225        if (!NT_STATUS_IS_OK(result)) {
     226                return ntstatus_to_werror(result);
     227        }
    218228
    219229        if (W_ERROR_IS_OK(werr)) {
     
    241251        struct GUID domain_guid = GUID_zero();
    242252        struct netr_DsRGetDCNameInfo *info = NULL;
     253        struct dcerpc_binding_handle *b = cli->binding_handle;
    243254
    244255        if (argc < 2) {
     
    266277        debug_dsdcinfo_flags(1,flags);
    267278
    268         status = rpccli_netr_DsRGetDCNameEx(cli, mem_ctx,
     279        status = dcerpc_netr_DsRGetDCNameEx(b, mem_ctx,
    269280                                            server_name,
    270281                                            domain_name,
     
    302313        struct GUID domain_guid = GUID_zero();
    303314        struct netr_DsRGetDCNameInfo *info = NULL;
     315        struct dcerpc_binding_handle *b = cli->binding_handle;
    304316
    305317        if (argc < 2) {
     
    338350        debug_dsdcinfo_flags(1,flags);
    339351
    340         status = rpccli_netr_DsRGetDCNameEx2(cli, mem_ctx,
     352        status = dcerpc_netr_DsRGetDCNameEx2(b, mem_ctx,
    341353                                             server_name,
    342354                                             client_account,
     
    370382        NTSTATUS status;
    371383        const char *sitename = NULL;
     384        struct dcerpc_binding_handle *b = cli->binding_handle;
    372385
    373386        if (argc != 2) {
     
    376389        }
    377390
    378         status = rpccli_netr_DsRGetSiteName(cli, mem_ctx,
     391        status = dcerpc_netr_DsRGetSiteName(b, mem_ctx,
    379392                                            argv[1],
    380393                                            &sitename,
     
    405418        uint32_t level = 1;
    406419        union netr_CONTROL_QUERY_INFORMATION info;
     420        struct dcerpc_binding_handle *b = cli->binding_handle;
    407421
    408422        if (argc > 4) {
     
    424438        }
    425439
    426         status = rpccli_netr_LogonControl(cli, mem_ctx,
     440        status = dcerpc_netr_LogonControl(b, mem_ctx,
    427441                                          logon_server,
    428442                                          function_code,
     
    465479                case NETR_DELTA_DELETE_GROUP:
    466480                        printf("Delete Group: %d\n",
    467                                 u.delete_account.unknown);
     481                                id.rid);
    468482                        break;
    469483                case NETR_DELTA_RENAME_GROUP:
     
    498512                case NETR_DELTA_DELETE_ALIAS:
    499513                        printf("Delete Alias: %d\n",
    500                                 r->delta_enum[i].delta_id_union.rid);
     514                                id.rid);
    501515                        break;
    502516                case NETR_DELTA_RENAME_ALIAS:
     
    514528                        break;
    515529                case NETR_DELTA_POLICY:
    516                         printf("Policy\n");
     530                        printf("Policy: %s\n",
     531                                sid_string_dbg(id.sid));
    517532                        break;
    518533                case NETR_DELTA_TRUSTED_DOMAIN:
     
    521536                        break;
    522537                case NETR_DELTA_DELETE_TRUST:
    523                         printf("Delete Trust: %d\n",
    524                                 u.delete_trust.unknown);
     538                        printf("Delete Trust: %s\n",
     539                                sid_string_dbg(id.sid));
    525540                        break;
    526541                case NETR_DELTA_ACCOUNT:
    527                         printf("Account\n");
     542                        printf("Account: %s\n",
     543                                sid_string_dbg(id.sid));
    528544                        break;
    529545                case NETR_DELTA_DELETE_ACCOUNT:
    530                         printf("Delete Account: %d\n",
    531                                 u.delete_account.unknown);
     546                        printf("Delete Account: %s\n",
     547                                sid_string_dbg(id.sid));
    532548                        break;
    533549                case NETR_DELTA_SECRET:
    534                         printf("Secret\n");
     550                        printf("Secret: %s\n",
     551                                id.name);
    535552                        break;
    536553                case NETR_DELTA_DELETE_SECRET:
    537                         printf("Delete Secret: %d\n",
    538                                 u.delete_secret.unknown);
     554                        printf("Delete Secret: %s\n",
     555                                id.name);
    539556                        break;
    540557                case NETR_DELTA_DELETE_GROUP2:
     
    565582{
    566583        NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     584        NTSTATUS status;
    567585        const char *logon_server = cli->desthost;
    568586        const char *computername = global_myname();
     
    572590        uint16_t restart_state = 0;
    573591        uint32_t sync_context = 0;
     592        struct dcerpc_binding_handle *b = cli->binding_handle;
    574593
    575594        if (argc > 2) {
     
    589608                netlogon_creds_client_authenticator(cli->dc, &credential);
    590609
    591                 result = rpccli_netr_DatabaseSync2(cli, mem_ctx,
     610                status = dcerpc_netr_DatabaseSync2(b, mem_ctx,
    592611                                                   logon_server,
    593612                                                   computername,
     
    598617                                                   &sync_context,
    599618                                                   &delta_enum_array,
    600                                                    0xffff);
     619                                                   0xffff,
     620                                                   &result);
     621                if (!NT_STATUS_IS_OK(status)) {
     622                        return status;
     623                }
    601624
    602625                /* Check returned credentials. */
     
    629652{
    630653        NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     654        NTSTATUS status;
    631655        uint32_t tmp;
    632656        const char *logon_server = cli->desthost;
     
    636660        enum netr_SamDatabaseID database_id = SAM_DATABASE_DOMAIN;
    637661        uint64_t sequence_num;
     662        struct dcerpc_binding_handle *b = cli->binding_handle;
    638663
    639664        if (argc != 3) {
     
    652677                netlogon_creds_client_authenticator(cli->dc, &credential);
    653678
    654                 result = rpccli_netr_DatabaseDeltas(cli, mem_ctx,
     679                status = dcerpc_netr_DatabaseDeltas(b, mem_ctx,
    655680                                                    logon_server,
    656681                                                    computername,
     
    660685                                                    &sequence_num,
    661686                                                    &delta_enum_array,
    662                                                     0xffff);
     687                                                    0xffff,
     688                                                    &result);
     689                if (!NT_STATUS_IS_OK(status)) {
     690                        return status;
     691                }
    663692
    664693                /* Check returned credentials. */
     
    693722        int logon_type = NetlogonNetworkInformation;
    694723        const char *username, *password;
    695         int auth_level = 2;
     724        uint16_t validation_level = 3;
    696725        uint32 logon_param = 0;
    697726        const char *workstation = NULL;
     
    715744
    716745        if (argc >= 6)
    717                 sscanf(argv[5], "%i", &auth_level);
     746                validation_level = atoi(argv[5]);
    718747
    719748        if (argc == 7)
     
    722751        /* Perform the sam logon */
    723752
    724         result = rpccli_netlogon_sam_logon(cli, mem_ctx, logon_param, lp_workgroup(), username, password, workstation, logon_type);
     753        result = rpccli_netlogon_sam_logon(cli, mem_ctx, logon_param, lp_workgroup(), username, password, workstation, validation_level, logon_type);
    725754
    726755        if (!NT_STATUS_IS_OK(result))
     
    767796        const char *domain_name = lp_workgroup();
    768797        uint32_t rid = 0;
     798        struct dcerpc_binding_handle *b = cli->binding_handle;
    769799
    770800        if (argc < 1 || argc > 3) {
     
    782812        }
    783813
    784         status = rpccli_netr_LogonGetTrustRid(cli, mem_ctx,
     814        status = dcerpc_netr_LogonGetTrustRid(b, mem_ctx,
    785815                                              server_name,
    786816                                              domain_name,
     
    788818                                              &werr);
    789819        if (!NT_STATUS_IS_OK(status)) {
     820                werr = ntstatus_to_werror(status);
    790821                goto done;
    791822        }
     
    807838        uint32_t trust_flags = NETR_TRUST_FLAG_IN_FOREST;
    808839        struct netr_DomainTrustList trusts;
     840        struct dcerpc_binding_handle *b = cli->binding_handle;
    809841
    810842        if (argc < 1 || argc > 3) {
     
    822854        }
    823855
    824         status = rpccli_netr_DsrEnumerateDomainTrusts(cli, mem_ctx,
     856        status = dcerpc_netr_DsrEnumerateDomainTrusts(b, mem_ctx,
    825857                                                      server_name,
    826858                                                      trust_flags,
     
    828860                                                      &werr);
    829861        if (!NT_STATUS_IS_OK(status)) {
     862                werr = ntstatus_to_werror(status);
    830863                goto done;
    831864        }
     
    855888        const char *domain = lp_workgroup();
    856889        const char *dns_host = NULL;
     890        struct dcerpc_binding_handle *b = cli->binding_handle;
    857891
    858892        if (argc < 1 || argc > 4) {
     
    874908        }
    875909
    876         status = rpccli_netr_DsrDeregisterDNSHostRecords(cli, mem_ctx,
     910        status = dcerpc_netr_DsrDeregisterDNSHostRecords(b, mem_ctx,
    877911                                                         server_name,
    878912                                                         domain,
     
    882916                                                         &werr);
    883917        if (!NT_STATUS_IS_OK(status)) {
     918                werr = ntstatus_to_werror(status);
    884919                goto done;
    885920        }
     
    902937        struct lsa_ForestTrustInformation *info = NULL;
    903938        uint32_t flags = 0;
     939        struct dcerpc_binding_handle *b = cli->binding_handle;
    904940
    905941        if (argc < 1 || argc > 4) {
     
    921957        }
    922958
    923         status = rpccli_netr_DsRGetForestTrustInformation(cli, mem_ctx,
     959        status = dcerpc_netr_DsRGetForestTrustInformation(b, mem_ctx,
    924960                                                         server_name,
    925961                                                         trusted_domain_name,
     
    928964                                                         &werr);
    929965        if (!NT_STATUS_IS_OK(status)) {
     966                werr = ntstatus_to_werror(status);
    930967                goto done;
    931968        }
     
    938975}
    939976
    940 static WERROR cmd_netlogon_enumtrusteddomains(struct rpc_pipe_client *cli,
    941                                               TALLOC_CTX *mem_ctx, int argc,
    942                                               const char **argv)
     977static NTSTATUS cmd_netlogon_enumtrusteddomains(struct rpc_pipe_client *cli,
     978                                                TALLOC_CTX *mem_ctx, int argc,
     979                                                const char **argv)
    943980{
    944981        NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
    945         WERROR werr = WERR_GENERAL_FAILURE;
     982        NTSTATUS result;
    946983        const char *server_name = cli->desthost;
    947984        struct netr_Blob blob;
     985        struct dcerpc_binding_handle *b = cli->binding_handle;
    948986
    949987
    950988        if (argc < 1 || argc > 3) {
    951989                fprintf(stderr, "Usage: %s <server_name>\n", argv[0]);
    952                 return WERR_OK;
     990                return NT_STATUS_OK;
    953991        }
    954992
     
    957995        }
    958996
    959         status = rpccli_netr_NetrEnumerateTrustedDomains(cli, mem_ctx,
     997        status = dcerpc_netr_NetrEnumerateTrustedDomains(b, mem_ctx,
    960998                                                         server_name,
    961999                                                         &blob,
    962                                                          &werr);
     1000                                                         &result);
    9631001        if (!NT_STATUS_IS_OK(status)) {
    9641002                goto done;
    9651003        }
    9661004
    967         if (W_ERROR_IS_OK(werr)) {
    968                 printf("success\n");
    969                 dump_data(1, blob.data, blob.length);
    970         }
     1005        if (!NT_STATUS_IS_OK(result)) {
     1006                status = result;
     1007                goto done;
     1008        }
     1009
     1010        printf("success\n");
     1011        dump_data(1, blob.data, blob.length);
    9711012 done:
    972         return werr;
     1013        return status;
    9731014}
    9741015
     
    9811022        const char *server_name = cli->desthost;
    9821023        struct netr_DomainTrustList list;
     1024        struct dcerpc_binding_handle *b = cli->binding_handle;
    9831025
    9841026        if (argc < 1 || argc > 3) {
     
    9911033        }
    9921034
    993         status = rpccli_netr_NetrEnumerateTrustedDomainsEx(cli, mem_ctx,
     1035        status = dcerpc_netr_NetrEnumerateTrustedDomainsEx(b, mem_ctx,
    9941036                                                           server_name,
    9951037                                                           &list,
    9961038                                                           &werr);
    9971039        if (!NT_STATUS_IS_OK(status)) {
     1040                werr = ntstatus_to_werror(status);
    9981041                goto done;
    9991042        }
     
    10141057        const char *server_name = cli->desthost;
    10151058        struct DcSitesCtr *ctr = NULL;
     1059        struct dcerpc_binding_handle *b = cli->binding_handle;
    10161060
    10171061        if (argc < 1 || argc > 3) {
     
    10241068        }
    10251069
    1026         status = rpccli_netr_DsrGetDcSiteCoverageW(cli, mem_ctx,
     1070        status = dcerpc_netr_DsrGetDcSiteCoverageW(b, mem_ctx,
    10271071                                                   server_name,
    10281072                                                   &ctr,
    10291073                                                   &werr);
    10301074        if (!NT_STATUS_IS_OK(status)) {
     1075                werr = ntstatus_to_werror(status);
    10311076                goto done;
    10321077        }
     
    10481093{
    10491094        NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
     1095        NTSTATUS result;
    10501096        const char *server_name = cli->desthost;
    10511097        uint32_t neg_flags = NETLOGON_NEG_AUTH2_ADS_FLAGS;
     
    10561102        struct netr_ChangeLogEntry e;
    10571103        uint32_t rid = 500;
     1104        struct dcerpc_binding_handle *b = cli->binding_handle;
    10581105
    10591106        if (argc > 2) {
     
    10931140        e.delta_type            = NETR_DELTA_USER;
    10941141
    1095         status = rpccli_netr_DatabaseRedo(cli, mem_ctx,
     1142        status = dcerpc_netr_DatabaseRedo(b, mem_ctx,
    10961143                                          server_name,
    10971144                                          global_myname(),
     
    11001147                                          e,
    11011148                                          0, /* is calculated automatically */
    1102                                           &delta_enum_array);
     1149                                          &delta_enum_array,
     1150                                          &result);
     1151        if (!NT_STATUS_IS_OK(status)) {
     1152                return status;
     1153        }
    11031154
    11041155        if (!netlogon_creds_client_check(cli->dc, &srv_cred.cred)) {
     
    11071158        }
    11081159
    1109         return status;
     1160        return result;
    11101161}
    11111162
     
    11151166{
    11161167        NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
     1168        NTSTATUS result;
    11171169        struct netr_Authenticator credential;
    11181170        struct netr_Authenticator return_authenticator;
    11191171        union netr_Capabilities capabilities;
    11201172        uint32_t level = 1;
     1173        struct dcerpc_binding_handle *b = cli->binding_handle;
    11211174
    11221175        if (argc > 2) {
     
    11331186        netlogon_creds_client_authenticator(cli->dc, &credential);
    11341187
    1135         status = rpccli_netr_LogonGetCapabilities(cli, mem_ctx,
     1188        status = dcerpc_netr_LogonGetCapabilities(b, mem_ctx,
    11361189                                                  cli->desthost,
    11371190                                                  global_myname(),
     
    11391192                                                  &return_authenticator,
    11401193                                                  level,
    1141                                                   &capabilities);
     1194                                                  &capabilities,
     1195                                                  &result);
     1196        if (!NT_STATUS_IS_OK(status)) {
     1197                return status;
     1198        }
    11421199
    11431200        if (!netlogon_creds_client_check(cli->dc,
     
    11491206        printf("capabilities: 0x%08x\n", capabilities.server_capabilities);
    11501207
    1151         return status;
     1208        return result;
    11521209}
    11531210
     
    11751232        { "dsenumdomtrusts",  RPC_RTYPE_WERROR, NULL, cmd_netlogon_dsr_enumtrustdom, &ndr_table_netlogon.syntax_id, NULL, "Enumerate all trusted domains in an AD forest",     "" },
    11761233        { "deregisterdnsrecords", RPC_RTYPE_WERROR, NULL, cmd_netlogon_deregisterdnsrecords, &ndr_table_netlogon.syntax_id, NULL, "Deregister DNS records",     "" },
    1177         { "netrenumtrusteddomains", RPC_RTYPE_WERROR, NULL, cmd_netlogon_enumtrusteddomains, &ndr_table_netlogon.syntax_id, NULL, "Enumerate trusted domains",     "" },
     1234        { "netrenumtrusteddomains", RPC_RTYPE_NTSTATUS, cmd_netlogon_enumtrusteddomains, NULL, &ndr_table_netlogon.syntax_id, NULL, "Enumerate trusted domains",     "" },
    11781235        { "netrenumtrusteddomainsex", RPC_RTYPE_WERROR, NULL, cmd_netlogon_enumtrusteddomainsex, &ndr_table_netlogon.syntax_id, NULL, "Enumerate trusted domains",     "" },
    11791236        { "getdcsitecoverage", RPC_RTYPE_WERROR, NULL, cmd_netlogon_getdcsitecoverage, &ndr_table_netlogon.syntax_id, NULL, "Get the Site-Coverage from a DC",     "" },
  • vendor/current/source3/rpcclient/cmd_ntsvcs.c

    r414 r740  
    2121#include "includes.h"
    2222#include "rpcclient.h"
    23 #include "../librpc/gen_ndr/cli_ntsvcs.h"
     23#include "../librpc/gen_ndr/ndr_ntsvcs_c.h"
    2424
    2525static WERROR cmd_ntsvcs_get_version(struct rpc_pipe_client *cli,
     
    2828                                     const char **argv)
    2929{
     30        struct dcerpc_binding_handle *b = cli->binding_handle;
    3031        NTSTATUS status;
    3132        WERROR werr;
    3233        uint16_t version;
    3334
    34         status = rpccli_PNP_GetVersion(cli, mem_ctx,
     35        status = dcerpc_PNP_GetVersion(b, mem_ctx,
    3536                                       &version, &werr);
    3637        if (!NT_STATUS_IS_OK(status)) {
     
    5051                                           const char **argv)
    5152{
     53        struct dcerpc_binding_handle *b = cli->binding_handle;
    5254        NTSTATUS status;
    5355        WERROR werr;
     
    6668        }
    6769
    68         status = rpccli_PNP_ValidateDeviceInstance(cli, mem_ctx,
     70        status = dcerpc_PNP_ValidateDeviceInstance(b, mem_ctx,
    6971                                                   devicepath,
    7072                                                   flags,
     
    8284                                       const char **argv)
    8385{
     86        struct dcerpc_binding_handle *b = cli->binding_handle;
    8487        NTSTATUS status;
    8588        WERROR werr;
     
    97100        devicepath = argv[1];
    98101
    99         status = rpccli_PNP_HwProfFlags(cli, mem_ctx,
     102        status = dcerpc_PNP_HwProfFlags(b, mem_ctx,
    100103                                        0,
    101104                                        devicepath,
     
    120123                                          const char **argv)
    121124{
     125        struct dcerpc_binding_handle *b = cli->binding_handle;
    122126        NTSTATUS status;
    123127        WERROR werr;
     
    128132        ZERO_STRUCT(info);
    129133
    130         status = rpccli_PNP_GetHwProfInfo(cli, mem_ctx,
     134        status = dcerpc_PNP_GetHwProfInfo(b, mem_ctx,
    131135                                          idx,
    132136                                          &info,
     
    146150                                          const char **argv)
    147151{
     152        struct dcerpc_binding_handle *b = cli->binding_handle;
    148153        NTSTATUS status;
    149154        WERROR werr;
     
    171176        W_ERROR_HAVE_NO_MEMORY(buffer);
    172177
    173         status = rpccli_PNP_GetDeviceRegProp(cli, mem_ctx,
     178        status = dcerpc_PNP_GetDeviceRegProp(b, mem_ctx,
    174179                                             devicepath,
    175180                                             property,
     
    192197                                           const char **argv)
    193198{
     199        struct dcerpc_binding_handle *b = cli->binding_handle;
    194200        NTSTATUS status;
    195201        WERROR werr;
     
    211217        }
    212218
    213         status = rpccli_PNP_GetDeviceListSize(cli, mem_ctx,
     219        status = dcerpc_PNP_GetDeviceListSize(b, mem_ctx,
    214220                                              filter,
    215221                                              &size,
     
    230236                                      const char **argv)
    231237{
     238        struct dcerpc_binding_handle *b = cli->binding_handle;
    232239        NTSTATUS status;
    233240        WERROR werr;
     
    259266        }
    260267
    261         status = rpccli_PNP_GetDeviceList(cli, mem_ctx,
     268        status = dcerpc_PNP_GetDeviceList(b, mem_ctx,
    262269                                          filter,
    263270                                          buffer,
  • vendor/current/source3/rpcclient/cmd_samr.c

    r414 r740  
    2626#include "rpcclient.h"
    2727#include "../libcli/auth/libcli_auth.h"
    28 #include "../librpc/gen_ndr/cli_samr.h"
    29 
    30 extern DOM_SID domain_sid;
     28#include "../librpc/gen_ndr/ndr_samr.h"
     29#include "../librpc/gen_ndr/ndr_samr_c.h"
     30#include "rpc_client/cli_samr.h"
     31#include "rpc_client/init_samr.h"
     32#include "rpc_client/init_lsa.h"
     33#include "../libcli/security/security.h"
     34
     35extern struct dom_sid domain_sid;
    3136
    3237/****************************************************************************
     
    277282                                  struct policy_handle *domain_pol)
    278283{
     284        struct dcerpc_binding_handle *b = cli->binding_handle;
     285        NTSTATUS status = NT_STATUS_INVALID_PARAMETER, result;
    279286
    280287        if (StrCaseCmp(sam, "domain") == 0) {
    281                 return rpccli_samr_OpenDomain(cli, mem_ctx,
     288                status = dcerpc_samr_OpenDomain(b, mem_ctx,
    282289                                              connect_pol,
    283290                                              access_mask,
    284291                                              _domain_sid,
    285                                               domain_pol);
     292                                              domain_pol,
     293                                              &result);
    286294        } else if (StrCaseCmp(sam, "builtin") == 0) {
    287                 return rpccli_samr_OpenDomain(cli, mem_ctx,
     295                status = dcerpc_samr_OpenDomain(b, mem_ctx,
    288296                                              connect_pol,
    289297                                              access_mask,
    290298                                              CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
    291                                               domain_pol);
    292         }
    293 
    294         return NT_STATUS_INVALID_PARAMETER;
     299                                              domain_pol,
     300                                              &result);
     301        }
     302
     303        if (!NT_STATUS_IS_OK(status)) {
     304                return status;
     305        }
     306
     307        return result;
    295308}
    296309
     
    303316{
    304317        struct policy_handle connect_pol, domain_pol, user_pol;
    305         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     318        NTSTATUS status, result;
    306319        uint32 info_level = 21;
    307320        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
    308321        union samr_UserInfo *info = NULL;
    309322        uint32 user_rid = 0;
     323        struct dcerpc_binding_handle *b = cli->binding_handle;
    310324
    311325        if ((argc < 2) || (argc > 4)) {
     
    323337
    324338
    325         result = rpccli_try_samr_connects(cli, mem_ctx,
     339        status = rpccli_try_samr_connects(cli, mem_ctx,
    326340                                          MAXIMUM_ALLOWED_ACCESS,
    327341                                          &connect_pol);
    328 
    329         if (!NT_STATUS_IS_OK(result))
    330                 goto done;
    331 
    332         result = rpccli_samr_OpenDomain(cli, mem_ctx,
     342        if (!NT_STATUS_IS_OK(status)) {
     343                goto done;
     344        }
     345
     346        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    333347                                        &connect_pol,
    334348                                        MAXIMUM_ALLOWED_ACCESS,
    335349                                        &domain_sid,
    336                                         &domain_pol);
    337         if (!NT_STATUS_IS_OK(result))
    338                 goto done;
    339 
    340         result = rpccli_samr_OpenUser(cli, mem_ctx,
     350                                        &domain_pol,
     351                                        &result);
     352        if (!NT_STATUS_IS_OK(status)) {
     353                goto done;
     354        }
     355        if (!NT_STATUS_IS_OK(result)) {
     356                status = result;
     357                goto done;
     358        }
     359
     360        status = dcerpc_samr_OpenUser(b, mem_ctx,
    341361                                      &domain_pol,
    342362                                      access_mask,
    343363                                      user_rid,
    344                                       &user_pol);
    345 
     364                                      &user_pol,
     365                                      &result);
     366        if (!NT_STATUS_IS_OK(status)) {
     367                goto done;
     368        }
    346369        if (NT_STATUS_EQUAL(result, NT_STATUS_NO_SUCH_USER) &&
    347370            (user_rid == 0)) {
     
    353376                init_lsa_String(&lsa_acct_name, argv[1]);
    354377
    355                 result = rpccli_samr_LookupNames(cli, mem_ctx,
     378                status = dcerpc_samr_LookupNames(b, mem_ctx,
    356379                                                 &domain_pol,
    357380                                                 1,
    358381                                                 &lsa_acct_name,
    359382                                                 &rids,
    360                                                  &types);
    361 
     383                                                 &types,
     384                                                 &result);
     385                if (!NT_STATUS_IS_OK(status)) {
     386                        goto done;
     387                }
    362388                if (NT_STATUS_IS_OK(result)) {
    363                         result = rpccli_samr_OpenUser(cli, mem_ctx,
     389                        status = dcerpc_samr_OpenUser(b, mem_ctx,
    364390                                                      &domain_pol,
    365391                                                      access_mask,
    366392                                                      rids.ids[0],
    367                                                       &user_pol);
    368                 }
    369         }
    370 
    371 
    372         if (!NT_STATUS_IS_OK(result))
    373                 goto done;
    374 
    375         result = rpccli_samr_QueryUserInfo(cli, mem_ctx,
     393                                                      &user_pol,
     394                                                      &result);
     395                        if (!NT_STATUS_IS_OK(status)) {
     396                                goto done;
     397                        }
     398                }
     399        }
     400
     401
     402        if (!NT_STATUS_IS_OK(result)) {
     403                status = result;
     404                goto done;
     405        }
     406
     407        status = dcerpc_samr_QueryUserInfo(b, mem_ctx,
    376408                                           &user_pol,
    377409                                           info_level,
    378                                            &info);
    379 
    380         if (!NT_STATUS_IS_OK(result))
    381                 goto done;
     410                                           &info,
     411                                           &result);
     412        if (!NT_STATUS_IS_OK(status)) {
     413                goto done;
     414        }
     415        if (!NT_STATUS_IS_OK(result)) {
     416                status = result;
     417                goto done;
     418        }
    382419
    383420        switch (info_level) {
     
    402439        }
    403440
    404         rpccli_samr_Close(cli, mem_ctx, &user_pol);
    405         rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    406         rpccli_samr_Close(cli, mem_ctx, &connect_pol);
     441        dcerpc_samr_Close(b, mem_ctx, &user_pol, &result);
     442        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     443        dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
    407444
    408445done:
    409         return result;
     446        return status;
    410447}
    411448
     
    491528{
    492529        struct policy_handle connect_pol, domain_pol, group_pol;
    493         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     530        NTSTATUS status, result;
    494531        enum samr_GroupInfoEnum info_level = GROUPINFOALL;
    495532        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
    496533        union samr_GroupInfo *group_info = NULL;
    497534        uint32 group_rid;
     535        struct dcerpc_binding_handle *b = cli->binding_handle;
    498536
    499537        if ((argc < 2) || (argc > 4)) {
     
    510548                sscanf(argv[3], "%x", &access_mask);
    511549
    512         result = rpccli_try_samr_connects(cli, mem_ctx,
     550        status = rpccli_try_samr_connects(cli, mem_ctx,
    513551                                          MAXIMUM_ALLOWED_ACCESS,
    514552                                          &connect_pol);
    515 
    516         if (!NT_STATUS_IS_OK(result))
    517                 goto done;
    518 
    519         result = rpccli_samr_OpenDomain(cli, mem_ctx,
     553        if (!NT_STATUS_IS_OK(status)) {
     554                goto done;
     555        }
     556
     557        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    520558                                        &connect_pol,
    521559                                        MAXIMUM_ALLOWED_ACCESS,
    522560                                        &domain_sid,
    523                                         &domain_pol);
    524 
    525         if (!NT_STATUS_IS_OK(result))
    526                 goto done;
    527 
    528         result = rpccli_samr_OpenGroup(cli, mem_ctx,
     561                                        &domain_pol,
     562                                        &result);
     563        if (!NT_STATUS_IS_OK(status)) {
     564                goto done;
     565        }
     566        if (!NT_STATUS_IS_OK(result)) {
     567                status = result;
     568                goto done;
     569        }
     570
     571        status = dcerpc_samr_OpenGroup(b, mem_ctx,
    529572                                       &domain_pol,
    530573                                       access_mask,
    531574                                       group_rid,
    532                                        &group_pol);
    533 
    534         if (!NT_STATUS_IS_OK(result))
    535                 goto done;
    536 
    537         result = rpccli_samr_QueryGroupInfo(cli, mem_ctx,
     575                                       &group_pol,
     576                                       &result);
     577        if (!NT_STATUS_IS_OK(status)) {
     578                goto done;
     579        }
     580        if (!NT_STATUS_IS_OK(result)) {
     581                status = result;
     582                goto done;
     583        }
     584
     585        status = dcerpc_samr_QueryGroupInfo(b, mem_ctx,
    538586                                            &group_pol,
    539587                                            info_level,
    540                                             &group_info);
    541         if (!NT_STATUS_IS_OK(result)) {
     588                                            &group_info,
     589                                            &result);
     590        if (!NT_STATUS_IS_OK(status)) {
     591                goto done;
     592        }
     593        if (!NT_STATUS_IS_OK(result)) {
     594                status = result;
    542595                goto done;
    543596        }
     
    545598        display_group_info(group_info, info_level);
    546599
    547         rpccli_samr_Close(cli, mem_ctx, &group_pol);
    548         rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    549         rpccli_samr_Close(cli, mem_ctx, &connect_pol);
     600        dcerpc_samr_Close(b, mem_ctx, &group_pol, &result);
     601        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     602        dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
    550603done:
    551         return result;
     604        return status;
    552605}
    553606
     
    561614                                domain_pol,
    562615                                user_pol;
    563         NTSTATUS                result = NT_STATUS_UNSUCCESSFUL;
     616        NTSTATUS status, result;
    564617        uint32                  user_rid;
    565618        uint32                  access_mask = MAXIMUM_ALLOWED_ACCESS;
    566619        int                     i;
    567620        struct samr_RidWithAttributeArray *rid_array = NULL;
     621        struct dcerpc_binding_handle *b = cli->binding_handle;
    568622
    569623        if ((argc < 2) || (argc > 3)) {
     
    577631                sscanf(argv[2], "%x", &access_mask);
    578632
    579         result = rpccli_try_samr_connects(cli, mem_ctx,
     633        status = rpccli_try_samr_connects(cli, mem_ctx,
    580634                                          MAXIMUM_ALLOWED_ACCESS,
    581635                                          &connect_pol);
    582 
    583         if (!NT_STATUS_IS_OK(result))
    584                 goto done;
    585 
    586         result = rpccli_samr_OpenDomain(cli, mem_ctx,
     636        if (!NT_STATUS_IS_OK(status)) {
     637                goto done;
     638        }
     639
     640        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    587641                                        &connect_pol,
    588642                                        MAXIMUM_ALLOWED_ACCESS,
    589                                         &domain_sid, &domain_pol);
    590 
    591         if (!NT_STATUS_IS_OK(result))
    592                 goto done;
    593 
    594         result = rpccli_samr_OpenUser(cli, mem_ctx,
     643                                        &domain_sid,
     644                                        &domain_pol,
     645                                        &result);
     646        if (!NT_STATUS_IS_OK(status)) {
     647                goto done;
     648        }
     649        if (!NT_STATUS_IS_OK(result)) {
     650                status = result;
     651                goto done;
     652        }
     653
     654        status = dcerpc_samr_OpenUser(b, mem_ctx,
    595655                                      &domain_pol,
    596656                                      access_mask,
    597657                                      user_rid,
    598                                       &user_pol);
    599 
    600         if (!NT_STATUS_IS_OK(result))
    601                 goto done;
    602 
    603         result = rpccli_samr_GetGroupsForUser(cli, mem_ctx,
     658                                      &user_pol,
     659                                      &result);
     660
     661        if (!NT_STATUS_IS_OK(status)) {
     662                goto done;
     663        }
     664        if (!NT_STATUS_IS_OK(result)) {
     665                status = result;
     666                goto done;
     667        }
     668
     669        status = dcerpc_samr_GetGroupsForUser(b, mem_ctx,
    604670                                              &user_pol,
    605                                               &rid_array);
    606 
    607         if (!NT_STATUS_IS_OK(result))
    608                 goto done;
     671                                              &rid_array,
     672                                              &result);
     673        if (!NT_STATUS_IS_OK(status)) {
     674                goto done;
     675        }
     676        if (!NT_STATUS_IS_OK(result)) {
     677                status = result;
     678                goto done;
     679        }
    609680
    610681        for (i = 0; i < rid_array->count; i++) {
     
    614685        }
    615686
    616         rpccli_samr_Close(cli, mem_ctx, &user_pol);
    617         rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    618         rpccli_samr_Close(cli, mem_ctx, &connect_pol);
     687        dcerpc_samr_Close(b, mem_ctx, &user_pol, &result);
     688        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     689        dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
    619690 done:
    620         return result;
     691        return status;
    621692}
    622693
     
    628699{
    629700        struct policy_handle            connect_pol, domain_pol;
    630         NTSTATUS                result = NT_STATUS_UNSUCCESSFUL;
    631         DOM_SID                *sids;
    632         size_t                     num_sids;
     701        NTSTATUS status, result;
     702        struct dom_sid                *sids;
     703        uint32_t                     num_sids;
    633704        uint32                  access_mask = MAXIMUM_ALLOWED_ACCESS;
    634705        int                     i;
    635706        struct lsa_SidArray sid_array;
    636707        struct samr_Ids alias_rids;
     708        struct dcerpc_binding_handle *b = cli->binding_handle;
    637709
    638710        if (argc < 3) {
     
    645717
    646718        for (i=2; i<argc; i++) {
    647                 DOM_SID tmp_sid;
     719                struct dom_sid tmp_sid;
    648720                if (!string_to_sid(&tmp_sid, argv[i])) {
    649721                        printf("%s is not a legal SID\n", argv[i]);
     
    665737
    666738        for (i=0; i<num_sids; i++) {
    667                 sid_array.sids[i].sid = sid_dup_talloc(mem_ctx, &sids[i]);
     739                sid_array.sids[i].sid = dom_sid_dup(mem_ctx, &sids[i]);
    668740                if (!sid_array.sids[i].sid) {
    669741                        return NT_STATUS_NO_MEMORY;
     
    673745        sid_array.num_sids = num_sids;
    674746
    675         result = rpccli_try_samr_connects(cli, mem_ctx,
     747        status = rpccli_try_samr_connects(cli, mem_ctx,
    676748                                          MAXIMUM_ALLOWED_ACCESS,
    677749                                          &connect_pol);
    678 
    679         if (!NT_STATUS_IS_OK(result))
    680                 goto done;
    681 
    682         result = get_domain_handle(cli, mem_ctx, argv[1],
     750        if (!NT_STATUS_IS_OK(status)) {
     751                goto done;
     752        }
     753
     754        status = get_domain_handle(cli, mem_ctx, argv[1],
    683755                                   &connect_pol,
    684756                                   access_mask,
    685757                                   &domain_sid,
    686758                                   &domain_pol);
    687 
    688         if (!NT_STATUS_IS_OK(result))
    689                 goto done;
    690 
    691         result = rpccli_samr_GetAliasMembership(cli, mem_ctx,
     759        if (!NT_STATUS_IS_OK(status)) {
     760                goto done;
     761        }
     762
     763        status = dcerpc_samr_GetAliasMembership(b, mem_ctx,
    692764                                                &domain_pol,
    693765                                                &sid_array,
    694                                                 &alias_rids);
    695         if (!NT_STATUS_IS_OK(result))
    696                 goto done;
     766                                                &alias_rids,
     767                                                &result);
     768        if (!NT_STATUS_IS_OK(status)) {
     769                goto done;
     770        }
     771        if (!NT_STATUS_IS_OK(result)) {
     772                status = result;
     773                goto done;
     774        }
    697775
    698776        for (i = 0; i < alias_rids.count; i++) {
     
    700778        }
    701779
    702         rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    703         rpccli_samr_Close(cli, mem_ctx, &connect_pol);
     780        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     781        dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
    704782 done:
    705         return result;
     783        return status;
    706784}
    707785
     
    713791{
    714792        struct policy_handle connect_pol, domain_pol, group_pol;
    715         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     793        NTSTATUS status, result;
    716794        uint32 group_rid;
    717795        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
    718796        int i;
    719797        unsigned int old_timeout;
    720         struct samr_RidTypeArray *rids = NULL;
     798        struct samr_RidAttrArray *rids = NULL;
     799        struct dcerpc_binding_handle *b = cli->binding_handle;
    721800
    722801        if ((argc < 2) || (argc > 3)) {
     
    730809                sscanf(argv[2], "%x", &access_mask);
    731810
    732         result = rpccli_try_samr_connects(cli, mem_ctx,
     811        status = rpccli_try_samr_connects(cli, mem_ctx,
    733812                                          MAXIMUM_ALLOWED_ACCESS,
    734813                                          &connect_pol);
    735 
    736         if (!NT_STATUS_IS_OK(result))
    737                 goto done;
    738 
    739         result = rpccli_samr_OpenDomain(cli, mem_ctx,
     814        if (!NT_STATUS_IS_OK(status)) {
     815                goto done;
     816        }
     817
     818        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    740819                                        &connect_pol,
    741820                                        MAXIMUM_ALLOWED_ACCESS,
    742821                                        &domain_sid,
    743                                         &domain_pol);
    744 
    745         if (!NT_STATUS_IS_OK(result))
    746                 goto done;
    747 
    748         result = rpccli_samr_OpenGroup(cli, mem_ctx,
     822                                        &domain_pol,
     823                                        &result);
     824        if (!NT_STATUS_IS_OK(status)) {
     825                goto done;
     826        }
     827        if (!NT_STATUS_IS_OK(result)) {
     828                status = result;
     829                goto done;
     830        }
     831
     832        status = dcerpc_samr_OpenGroup(b, mem_ctx,
    749833                                       &domain_pol,
    750834                                       access_mask,
    751835                                       group_rid,
    752                                        &group_pol);
    753 
    754         if (!NT_STATUS_IS_OK(result))
    755                 goto done;
     836                                       &group_pol,
     837                                       &result);
     838        if (!NT_STATUS_IS_OK(status)) {
     839                goto done;
     840        }
     841        if (!NT_STATUS_IS_OK(result)) {
     842                status = result;
     843                goto done;
     844        }
    756845
    757846        /* Make sure to wait for our DC's reply */
     
    759848        rpccli_set_timeout(cli, MAX(30000, old_timeout)); /* At least 30 sec */
    760849
    761         result = rpccli_samr_QueryGroupMember(cli, mem_ctx,
     850        status = dcerpc_samr_QueryGroupMember(b, mem_ctx,
    762851                                              &group_pol,
    763                                               &rids);
     852                                              &rids,
     853                                              &result);
    764854
    765855        rpccli_set_timeout(cli, old_timeout);
    766856
    767         if (!NT_STATUS_IS_OK(result))
    768                 goto done;
     857        if (!NT_STATUS_IS_OK(status)) {
     858                goto done;
     859        }
     860        if (!NT_STATUS_IS_OK(result)) {
     861                status = result;
     862                goto done;
     863        }
    769864
    770865        for (i = 0; i < rids->count; i++) {
    771866                printf("\trid:[0x%x] attr:[0x%x]\n", rids->rids[i],
    772                        rids->types[i]);
    773         }
    774 
    775         rpccli_samr_Close(cli, mem_ctx, &group_pol);
    776         rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    777         rpccli_samr_Close(cli, mem_ctx, &connect_pol);
     867                       rids->attributes[i]);
     868        }
     869
     870        dcerpc_samr_Close(b, mem_ctx, &group_pol, &result);
     871        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     872        dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
    778873 done:
    779         return result;
     874        return status;
    780875}
    781876
     
    787882{
    788883        struct policy_handle connect_pol, domain_pol;
    789         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     884        NTSTATUS status, result;
    790885        uint32 start_idx, num_dom_users, i;
    791886        struct samr_SamArray *dom_users = NULL;
     
    793888        uint32 acb_mask = ACB_NORMAL;
    794889        uint32_t size = 0xffff;
     890        struct dcerpc_binding_handle *b = cli->binding_handle;
    795891
    796892        if ((argc < 1) || (argc > 4)) {
     
    813909        /* Get sam policy handle */
    814910
    815         result = rpccli_try_samr_connects(cli, mem_ctx,
     911        status = rpccli_try_samr_connects(cli, mem_ctx,
    816912                                          MAXIMUM_ALLOWED_ACCESS,
    817913                                          &connect_pol);
    818 
    819         if (!NT_STATUS_IS_OK(result))
    820                 goto done;
     914        if (!NT_STATUS_IS_OK(status)) {
     915                goto done;
     916        }
    821917
    822918        /* Get domain policy handle */
    823919
    824         result = get_domain_handle(cli, mem_ctx, "domain",
     920        status = get_domain_handle(cli, mem_ctx, "domain",
    825921                                   &connect_pol,
    826922                                   access_mask,
    827923                                   &domain_sid,
    828924                                   &domain_pol);
    829         if (!NT_STATUS_IS_OK(result))
    830                 goto done;
     925        if (!NT_STATUS_IS_OK(status)) {
     926                goto done;
     927        }
    831928
    832929        /* Enumerate domain users */
     
    835932
    836933        do {
    837                 result = rpccli_samr_EnumDomainUsers(cli, mem_ctx,
     934                status = dcerpc_samr_EnumDomainUsers(b, mem_ctx,
    838935                                                     &domain_pol,
    839936                                                     &start_idx,
     
    841938                                                     &dom_users,
    842939                                                     size,
    843                                                      &num_dom_users);
    844 
     940                                                     &num_dom_users,
     941                                                     &result);
     942                if (!NT_STATUS_IS_OK(status)) {
     943                        goto done;
     944                }
    845945                if (NT_STATUS_IS_OK(result) ||
    846946                    NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) {
     
    856956 done:
    857957        if (is_valid_policy_hnd(&domain_pol))
    858                 rpccli_samr_Close(cli, mem_ctx, &domain_pol);
     958                dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
    859959
    860960        if (is_valid_policy_hnd(&connect_pol))
    861                 rpccli_samr_Close(cli, mem_ctx, &connect_pol);
    862 
    863         return result;
     961                dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
     962
     963        return status;
    864964}
    865965
     
    871971{
    872972        struct policy_handle connect_pol, domain_pol;
    873         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     973        NTSTATUS status, result;
    874974        uint32 start_idx, num_dom_groups, i;
    875975        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
    876976        struct samr_SamArray *dom_groups = NULL;
    877977        uint32_t size = 0xffff;
     978        struct dcerpc_binding_handle *b = cli->binding_handle;
    878979
    879980        if ((argc < 1) || (argc > 3)) {
     
    892993        /* Get sam policy handle */
    893994
    894         result = rpccli_try_samr_connects(cli, mem_ctx,
     995        status = rpccli_try_samr_connects(cli, mem_ctx,
    895996                                          MAXIMUM_ALLOWED_ACCESS,
    896997                                          &connect_pol);
    897 
    898         if (!NT_STATUS_IS_OK(result))
    899                 goto done;
     998        if (!NT_STATUS_IS_OK(status)) {
     999                goto done;
     1000        }
    9001001
    9011002        /* Get domain policy handle */
    9021003
    903         result = get_domain_handle(cli, mem_ctx, "domain",
     1004        status = get_domain_handle(cli, mem_ctx, "domain",
    9041005                                   &connect_pol,
    9051006                                   access_mask,
    9061007                                   &domain_sid,
    9071008                                   &domain_pol);
    908         if (!NT_STATUS_IS_OK(result))
    909                 goto done;
     1009        if (!NT_STATUS_IS_OK(status)) {
     1010                goto done;
     1011        }
    9101012
    9111013        /* Enumerate domain groups */
     
    9141016
    9151017        do {
    916                 result = rpccli_samr_EnumDomainGroups(cli, mem_ctx,
     1018                status = dcerpc_samr_EnumDomainGroups(b, mem_ctx,
    9171019                                                      &domain_pol,
    9181020                                                      &start_idx,
    9191021                                                      &dom_groups,
    9201022                                                      size,
    921                                                       &num_dom_groups);
     1023                                                      &num_dom_groups,
     1024                                                      &result);
     1025                if (!NT_STATUS_IS_OK(status)) {
     1026                        goto done;
     1027                }
    9221028                if (NT_STATUS_IS_OK(result) ||
    9231029                    NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) {
     
    9331039 done:
    9341040        if (is_valid_policy_hnd(&domain_pol))
    935                 rpccli_samr_Close(cli, mem_ctx, &domain_pol);
     1041                dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
    9361042
    9371043        if (is_valid_policy_hnd(&connect_pol))
    938                 rpccli_samr_Close(cli, mem_ctx, &connect_pol);
    939 
    940         return result;
     1044                dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
     1045
     1046        return status;
    9411047}
    9421048
     
    9481054{
    9491055        struct policy_handle connect_pol, domain_pol;
    950         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     1056        NTSTATUS status, result;
    9511057        uint32 start_idx, num_als_groups, i;
    9521058        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
    9531059        struct samr_SamArray *als_groups = NULL;
    9541060        uint32_t size = 0xffff;
     1061        struct dcerpc_binding_handle *b = cli->binding_handle;
    9551062
    9561063        if ((argc < 2) || (argc > 4)) {
     
    9691076        /* Get sam policy handle */
    9701077
    971         result = rpccli_try_samr_connects(cli, mem_ctx,
     1078        status = rpccli_try_samr_connects(cli, mem_ctx,
    9721079                                          MAXIMUM_ALLOWED_ACCESS,
    9731080                                          &connect_pol);
    974 
    975         if (!NT_STATUS_IS_OK(result))
    976                 goto done;
     1081        if (!NT_STATUS_IS_OK(status)) {
     1082                goto done;
     1083        }
    9771084
    9781085        /* Get domain policy handle */
    9791086
    980         result = get_domain_handle(cli, mem_ctx, argv[1],
     1087        status = get_domain_handle(cli, mem_ctx, argv[1],
    9811088                                   &connect_pol,
    9821089                                   access_mask,
    9831090                                   &domain_sid,
    9841091                                   &domain_pol);
    985 
    986         if (!NT_STATUS_IS_OK(result))
    987                 goto done;
     1092        if (!NT_STATUS_IS_OK(status)) {
     1093                goto done;
     1094        }
    9881095
    9891096        /* Enumerate alias groups */
     
    9921099
    9931100        do {
    994                 result = rpccli_samr_EnumDomainAliases(cli, mem_ctx,
     1101                status = dcerpc_samr_EnumDomainAliases(b, mem_ctx,
    9951102                                                       &domain_pol,
    9961103                                                       &start_idx,
    9971104                                                       &als_groups,
    9981105                                                       size,
    999                                                        &num_als_groups);
    1000 
     1106                                                       &num_als_groups,
     1107                                                       &result);
     1108                if (!NT_STATUS_IS_OK(status)) {
     1109                        goto done;
     1110                }
    10011111                if (NT_STATUS_IS_OK(result) ||
    10021112                    NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) {
     
    10111121 done:
    10121122        if (is_valid_policy_hnd(&domain_pol))
    1013                 rpccli_samr_Close(cli, mem_ctx, &domain_pol);
     1123                dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
    10141124
    10151125        if (is_valid_policy_hnd(&connect_pol))
    1016                 rpccli_samr_Close(cli, mem_ctx, &connect_pol);
    1017 
    1018         return result;
     1126                dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
     1127
     1128        return status;
    10191129}
    10201130
     
    10261136{
    10271137        struct policy_handle connect_pol;
    1028         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     1138        NTSTATUS status, result;
    10291139        uint32 start_idx, size, num_entries, i;
    10301140        uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
    10311141        struct samr_SamArray *sam = NULL;
     1142        struct dcerpc_binding_handle *b = cli->binding_handle;
    10321143
    10331144        if ((argc < 1) || (argc > 2)) {
     
    10421153        /* Get sam policy handle */
    10431154
    1044         result = rpccli_try_samr_connects(cli, mem_ctx,
     1155        status = rpccli_try_samr_connects(cli, mem_ctx,
    10451156                                          access_mask,
    10461157                                          &connect_pol);
    1047 
    1048         if (!NT_STATUS_IS_OK(result)) {
     1158        if (!NT_STATUS_IS_OK(status)) {
    10491159                goto done;
    10501160        }
     
    10561166
    10571167        do {
    1058                 result = rpccli_samr_EnumDomains(cli, mem_ctx,
     1168                status = dcerpc_samr_EnumDomains(b, mem_ctx,
    10591169                                                 &connect_pol,
    10601170                                                 &start_idx,
    10611171                                                 &sam,
    10621172                                                 size,
    1063                                                  &num_entries);
    1064 
     1173                                                 &num_entries,
     1174                                                 &result);
     1175                if (!NT_STATUS_IS_OK(status)) {
     1176                        goto done;
     1177                }
    10651178                if (NT_STATUS_IS_OK(result) ||
    10661179                    NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) {
     
    10751188 done:
    10761189        if (is_valid_policy_hnd(&connect_pol)) {
    1077                 rpccli_samr_Close(cli, mem_ctx, &connect_pol);
    1078         }
    1079 
    1080         return result;
     1190                dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
     1191        }
     1192
     1193        return status;
    10811194}
    10821195
     
    10891202{
    10901203        struct policy_handle connect_pol, domain_pol, alias_pol;
    1091         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     1204        NTSTATUS status, result;
    10921205        uint32 alias_rid, i;
    10931206        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
    10941207        struct lsa_SidArray sid_array;
     1208        struct dcerpc_binding_handle *b = cli->binding_handle;
    10951209
    10961210        if ((argc < 3) || (argc > 4)) {
     
    11061220        /* Open SAMR handle */
    11071221
    1108         result = rpccli_try_samr_connects(cli, mem_ctx,
     1222        status = rpccli_try_samr_connects(cli, mem_ctx,
    11091223                                          MAXIMUM_ALLOWED_ACCESS,
    11101224                                          &connect_pol);
    1111 
    1112         if (!NT_STATUS_IS_OK(result))
    1113                 goto done;
     1225        if (!NT_STATUS_IS_OK(status)) {
     1226                goto done;
     1227        }
    11141228
    11151229        /* Open handle on domain */
    11161230
    1117         result = get_domain_handle(cli, mem_ctx, argv[1],
     1231        status = get_domain_handle(cli, mem_ctx, argv[1],
    11181232                                   &connect_pol,
    11191233                                   MAXIMUM_ALLOWED_ACCESS,
    11201234                                   &domain_sid,
    11211235                                   &domain_pol);
    1122 
    1123         if (!NT_STATUS_IS_OK(result))
    1124                 goto done;
     1236        if (!NT_STATUS_IS_OK(status)) {
     1237                goto done;
     1238        }
    11251239
    11261240        /* Open handle on alias */
    11271241
    1128         result = rpccli_samr_OpenAlias(cli, mem_ctx,
     1242        status = dcerpc_samr_OpenAlias(b, mem_ctx,
    11291243                                       &domain_pol,
    11301244                                       access_mask,
    11311245                                       alias_rid,
    1132                                        &alias_pol);
    1133         if (!NT_STATUS_IS_OK(result))
    1134                 goto done;
    1135 
    1136         result = rpccli_samr_GetMembersInAlias(cli, mem_ctx,
     1246                                       &alias_pol,
     1247                                       &result);
     1248        if (!NT_STATUS_IS_OK(status)) {
     1249                goto done;
     1250        }
     1251        if (!NT_STATUS_IS_OK(result)) {
     1252                status = result;
     1253                goto done;
     1254        }
     1255
     1256        status = dcerpc_samr_GetMembersInAlias(b, mem_ctx,
    11371257                                               &alias_pol,
    1138                                                &sid_array);
    1139 
    1140         if (!NT_STATUS_IS_OK(result))
    1141                 goto done;
     1258                                               &sid_array,
     1259                                               &result);
     1260        if (!NT_STATUS_IS_OK(status)) {
     1261                goto done;
     1262        }
     1263        if (!NT_STATUS_IS_OK(result)) {
     1264                status = result;
     1265                goto done;
     1266        }
    11421267
    11431268        for (i = 0; i < sid_array.num_sids; i++) {
     
    11481273        }
    11491274
    1150         rpccli_samr_Close(cli, mem_ctx, &alias_pol);
    1151         rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    1152         rpccli_samr_Close(cli, mem_ctx, &connect_pol);
     1275        dcerpc_samr_Close(b, mem_ctx, &alias_pol, &result);
     1276        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     1277        dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
    11531278 done:
    1154         return result;
     1279        return status;
    11551280}
    11561281
     
    11621287{
    11631288        struct policy_handle connect_pol, domain_pol, alias_pol;
    1164         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     1289        NTSTATUS status, result;
    11651290        uint32_t alias_rid;
    11661291        uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
    11671292        union samr_AliasInfo *info = NULL;
    11681293        enum samr_AliasInfoEnum level = ALIASINFOALL;
     1294        struct dcerpc_binding_handle *b = cli->binding_handle;
    11691295
    11701296        if ((argc < 3) || (argc > 4)) {
     
    11861312        /* Open SAMR handle */
    11871313
    1188         result = rpccli_try_samr_connects(cli, mem_ctx,
     1314        status = rpccli_try_samr_connects(cli, mem_ctx,
    11891315                                          SEC_FLAG_MAXIMUM_ALLOWED,
    11901316                                          &connect_pol);
    1191 
    1192         if (!NT_STATUS_IS_OK(result)) {
     1317        if (!NT_STATUS_IS_OK(status)) {
    11931318                goto done;
    11941319        }
     
    11961321        /* Open handle on domain */
    11971322
    1198         result = get_domain_handle(cli, mem_ctx, argv[1],
     1323        status = get_domain_handle(cli, mem_ctx, argv[1],
    11991324                                   &connect_pol,
    12001325                                   SEC_FLAG_MAXIMUM_ALLOWED,
    12011326                                   &domain_sid,
    12021327                                   &domain_pol);
    1203 
    1204         if (!NT_STATUS_IS_OK(result)) {
     1328        if (!NT_STATUS_IS_OK(status)) {
    12051329                goto done;
    12061330        }
     
    12081332        /* Open handle on alias */
    12091333
    1210         result = rpccli_samr_OpenAlias(cli, mem_ctx,
     1334        status = dcerpc_samr_OpenAlias(b, mem_ctx,
    12111335                                       &domain_pol,
    12121336                                       access_mask,
    12131337                                       alias_rid,
    1214                                        &alias_pol);
    1215         if (!NT_STATUS_IS_OK(result)) {
    1216                 goto done;
    1217         }
    1218 
    1219         result = rpccli_samr_QueryAliasInfo(cli, mem_ctx,
     1338                                       &alias_pol,
     1339                                       &result);
     1340        if (!NT_STATUS_IS_OK(status)) {
     1341                goto done;
     1342        }
     1343        if (!NT_STATUS_IS_OK(result)) {
     1344                status = result;
     1345                goto done;
     1346        }
     1347
     1348        status = dcerpc_samr_QueryAliasInfo(b, mem_ctx,
    12201349                                            &alias_pol,
    12211350                                            level,
    1222                                             &info);
    1223 
    1224         if (!NT_STATUS_IS_OK(result)) {
     1351                                            &info,
     1352                                            &result);
     1353        if (!NT_STATUS_IS_OK(status)) {
     1354                goto done;
     1355        }
     1356        if (!NT_STATUS_IS_OK(result)) {
     1357                status = result;
    12251358                goto done;
    12261359        }
     
    12421375        }
    12431376
    1244         rpccli_samr_Close(cli, mem_ctx, &alias_pol);
    1245         rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    1246         rpccli_samr_Close(cli, mem_ctx, &connect_pol);
     1377        dcerpc_samr_Close(b, mem_ctx, &alias_pol, &result);
     1378        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     1379        dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
    12471380 done:
    1248         return result;
     1381        return status;
    12491382}
    12501383
     
    12571390{
    12581391        struct policy_handle connect_pol, domain_pol, alias_pol;
    1259         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     1392        NTSTATUS status, result;
    12601393        uint32 alias_rid;
    12611394        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
     1395        struct dcerpc_binding_handle *b = cli->binding_handle;
    12621396
    12631397        if (argc != 3) {
     
    12701404        /* Open SAMR handle */
    12711405
    1272         result = rpccli_try_samr_connects(cli, mem_ctx,
     1406        status = rpccli_try_samr_connects(cli, mem_ctx,
    12731407                                          MAXIMUM_ALLOWED_ACCESS,
    12741408                                          &connect_pol);
    1275 
    1276         if (!NT_STATUS_IS_OK(result))
    1277                 goto done;
     1409        if (!NT_STATUS_IS_OK(status)) {
     1410                goto done;
     1411        }
    12781412
    12791413        /* Open handle on domain */
    12801414
    1281         result = get_domain_handle(cli, mem_ctx, argv[1],
     1415        status = get_domain_handle(cli, mem_ctx, argv[1],
    12821416                                   &connect_pol,
    12831417                                   MAXIMUM_ALLOWED_ACCESS,
    12841418                                   &domain_sid,
    12851419                                   &domain_pol);
    1286 
    1287         if (!NT_STATUS_IS_OK(result))
    1288                 goto done;
     1420        if (!NT_STATUS_IS_OK(status)) {
     1421                goto done;
     1422        }
    12891423
    12901424        /* Open handle on alias */
    12911425
    1292         result = rpccli_samr_OpenAlias(cli, mem_ctx,
     1426        status = dcerpc_samr_OpenAlias(b, mem_ctx,
    12931427                                       &domain_pol,
    12941428                                       access_mask,
    12951429                                       alias_rid,
    1296                                        &alias_pol);
     1430                                       &alias_pol,
     1431                                       &result);
     1432        if (!NT_STATUS_IS_OK(status)) {
     1433                goto done;
     1434        }
    12971435        if (!NT_STATUS_IS_OK(result) && (alias_rid == 0)) {
    12981436                /* Probably this was a user name, try lookupnames */
     
    13021440                init_lsa_String(&lsa_acct_name, argv[2]);
    13031441
    1304                 result = rpccli_samr_LookupNames(cli, mem_ctx,
     1442                status = dcerpc_samr_LookupNames(b, mem_ctx,
    13051443                                                 &domain_pol,
    13061444                                                 1,
    13071445                                                 &lsa_acct_name,
    13081446                                                 &rids,
    1309                                                  &types);
    1310 
     1447                                                 &types,
     1448                                                 &result);
     1449                if (!NT_STATUS_IS_OK(status)) {
     1450                        goto done;
     1451                }
    13111452                if (NT_STATUS_IS_OK(result)) {
    1312                         result = rpccli_samr_OpenAlias(cli, mem_ctx,
     1453                        status = dcerpc_samr_OpenAlias(b, mem_ctx,
    13131454                                                       &domain_pol,
    13141455                                                       access_mask,
    13151456                                                       rids.ids[0],
    1316                                                        &alias_pol);
    1317                 }
    1318         }
    1319 
    1320         result = rpccli_samr_DeleteDomAlias(cli, mem_ctx,
    1321                                             &alias_pol);
    1322 
    1323         if (!NT_STATUS_IS_OK(result))
    1324                 goto done;
    1325 
    1326         rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    1327         rpccli_samr_Close(cli, mem_ctx, &connect_pol);
     1457                                                       &alias_pol,
     1458                                                       &result);
     1459                        if (!NT_STATUS_IS_OK(status)) {
     1460                                goto done;
     1461                        }
     1462                }
     1463        }
     1464
     1465        status = dcerpc_samr_DeleteDomAlias(b, mem_ctx,
     1466                                            &alias_pol,
     1467                                            &result);
     1468        if (!NT_STATUS_IS_OK(status)) {
     1469                goto done;
     1470        }
     1471        if (!NT_STATUS_IS_OK(result)) {
     1472                status = result;
     1473                goto done;
     1474        }
     1475
     1476        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     1477        dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
    13281478 done:
    1329         return result;
     1479        return status;
    13301480}
    13311481
     
    13381488{
    13391489        struct policy_handle connect_pol, domain_pol;
    1340         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     1490        NTSTATUS status, result;
    13411491        uint32 start_idx=0, max_entries=250, max_size = 0xffff, num_entries = 0, i;
    13421492        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
     
    13461496        bool got_params = False; /* Use get_query_dispinfo_params() or not? */
    13471497        uint32_t total_size, returned_size;
     1498        struct dcerpc_binding_handle *b = cli->binding_handle;
    13481499
    13491500        if (argc > 6) {
     
    13731524        /* Get sam policy handle */
    13741525
    1375         result = rpccli_try_samr_connects(cli, mem_ctx,
     1526        status = rpccli_try_samr_connects(cli, mem_ctx,
    13761527                                          MAXIMUM_ALLOWED_ACCESS,
    13771528                                          &connect_pol);
    1378 
    1379         if (!NT_STATUS_IS_OK(result))
    1380                 goto done;
     1529        if (!NT_STATUS_IS_OK(status)) {
     1530                goto done;
     1531        }
    13811532
    13821533        /* Get domain policy handle */
    13831534
    1384         result = rpccli_samr_OpenDomain(cli, mem_ctx,
     1535        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    13851536                                        &connect_pol,
    13861537                                        access_mask,
    13871538                                        &domain_sid,
    1388                                         &domain_pol);
    1389 
    1390         if (!NT_STATUS_IS_OK(result))
    1391                 goto done;
     1539                                        &domain_pol,
     1540                                        &result);
     1541        if (!NT_STATUS_IS_OK(status)) {
     1542                goto done;
     1543        }
     1544        if (!NT_STATUS_IS_OK(result)) {
     1545                status = result;
     1546                goto done;
     1547        }
    13921548
    13931549        /* Query display info */
     
    13961552
    13971553                if (!got_params)
    1398                         get_query_dispinfo_params(
     1554                        dcerpc_get_query_dispinfo_params(
    13991555                                loop_count, &max_entries, &max_size);
    14001556
    14011557                switch (opcode) {
    14021558                case NDR_SAMR_QUERYDISPLAYINFO:
    1403                         result = rpccli_samr_QueryDisplayInfo(cli, mem_ctx,
     1559                        status = dcerpc_samr_QueryDisplayInfo(b, mem_ctx,
    14041560                                                              &domain_pol,
    14051561                                                              info_level,
     
    14091565                                                              &total_size,
    14101566                                                              &returned_size,
    1411                                                               &info);
     1567                                                              &info,
     1568                                                              &result);
    14121569                        break;
    14131570                case NDR_SAMR_QUERYDISPLAYINFO2:
    1414                         result = rpccli_samr_QueryDisplayInfo2(cli, mem_ctx,
     1571                        status = dcerpc_samr_QueryDisplayInfo2(b, mem_ctx,
    14151572                                                               &domain_pol,
    14161573                                                               info_level,
     
    14201577                                                               &total_size,
    14211578                                                               &returned_size,
    1422                                                                &info);
     1579                                                               &info,
     1580                                                               &result);
    14231581
    14241582                        break;
    14251583                case NDR_SAMR_QUERYDISPLAYINFO3:
    1426                         result = rpccli_samr_QueryDisplayInfo3(cli, mem_ctx,
     1584                        status = dcerpc_samr_QueryDisplayInfo3(b, mem_ctx,
    14271585                                                               &domain_pol,
    14281586                                                               info_level,
     
    14321590                                                               &total_size,
    14331591                                                               &returned_size,
    1434                                                                &info);
     1592                                                               &info,
     1593                                                               &result);
    14351594
    14361595                        break;
     
    14391598                }
    14401599
     1600                if (!NT_STATUS_IS_OK(status)) {
     1601                        break;
     1602                }
     1603                status = result;
    14411604                if (!NT_STATUS_IS_OK(result) &&
    14421605                    !NT_STATUS_EQUAL(result, NT_STATUS_NO_MORE_ENTRIES) &&
     
    14931656        } while ( NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES));
    14941657
    1495         rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    1496         rpccli_samr_Close(cli, mem_ctx, &connect_pol);
     1658        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     1659        dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
    14971660 done:
    1498         return result;
     1661        return status;
    14991662}
    15001663
     
    15301693{
    15311694        struct policy_handle connect_pol, domain_pol;
    1532         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     1695        NTSTATUS status, result;
    15331696        uint32 switch_level = 2;
    15341697        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
    15351698        union samr_DomainInfo *info = NULL;
     1699        struct dcerpc_binding_handle *b = cli->binding_handle;
    15361700
    15371701        if (argc > 3) {
     
    15481712        /* Get sam policy handle */
    15491713
    1550         result = rpccli_try_samr_connects(cli, mem_ctx,
     1714        status = rpccli_try_samr_connects(cli, mem_ctx,
    15511715                                          MAXIMUM_ALLOWED_ACCESS,
    15521716                                          &connect_pol);
    1553 
    1554         if (!NT_STATUS_IS_OK(result))
    1555                 goto done;
     1717        if (!NT_STATUS_IS_OK(status)) {
     1718                goto done;
     1719        }
    15561720
    15571721        /* Get domain policy handle */
    15581722
    1559         result = rpccli_samr_OpenDomain(cli, mem_ctx,
     1723        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    15601724                                        &connect_pol,
    15611725                                        access_mask,
    15621726                                        &domain_sid,
    1563                                         &domain_pol);
    1564 
    1565         if (!NT_STATUS_IS_OK(result))
    1566                 goto done;
     1727                                        &domain_pol,
     1728                                        &result);
     1729        if (!NT_STATUS_IS_OK(status)) {
     1730                goto done;
     1731        }
     1732        if (!NT_STATUS_IS_OK(result)) {
     1733                status = result;
     1734                goto done;
     1735        }
    15671736
    15681737        /* Query domain info */
    15691738
    1570         result = rpccli_samr_QueryDomainInfo(cli, mem_ctx,
     1739        status = dcerpc_samr_QueryDomainInfo(b, mem_ctx,
    15711740                                             &domain_pol,
    15721741                                             switch_level,
    1573                                              &info);
    1574 
    1575         if (!NT_STATUS_IS_OK(result))
    1576                 goto done;
     1742                                             &info,
     1743                                             &result);
     1744        if (!NT_STATUS_IS_OK(status)) {
     1745                goto done;
     1746        }
     1747        if (!NT_STATUS_IS_OK(result)) {
     1748                status = result;
     1749                goto done;
     1750        }
    15771751
    15781752        /* Display domain info */
     
    16211795 done:
    16221796
    1623         rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    1624         rpccli_samr_Close(cli, mem_ctx, &connect_pol);
    1625         return result;
     1797        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     1798        dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
     1799        return status;
    16261800}
    16271801
     
    16331807{
    16341808        struct policy_handle connect_pol, domain_pol, user_pol;
    1635         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     1809        NTSTATUS status, result;
    16361810        struct lsa_String acct_name;
    16371811        uint32 acb_info;
     
    16391813        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
    16401814        uint32_t access_granted = 0;
     1815        struct dcerpc_binding_handle *b = cli->binding_handle;
    16411816
    16421817        if ((argc < 2) || (argc > 3)) {
     
    16521827        /* Get sam policy handle */
    16531828
    1654         result = rpccli_try_samr_connects(cli, mem_ctx,
     1829        status = rpccli_try_samr_connects(cli, mem_ctx,
    16551830                                          MAXIMUM_ALLOWED_ACCESS,
    16561831                                          &connect_pol);
    1657 
    1658         if (!NT_STATUS_IS_OK(result))
    1659                 goto done;
     1832        if (!NT_STATUS_IS_OK(status)) {
     1833                goto done;
     1834        }
    16601835
    16611836        /* Get domain policy handle */
    16621837
    1663         result = rpccli_samr_OpenDomain(cli, mem_ctx,
     1838        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    16641839                                        &connect_pol,
    16651840                                        access_mask,
    16661841                                        &domain_sid,
    1667                                         &domain_pol);
    1668 
    1669         if (!NT_STATUS_IS_OK(result))
    1670                 goto done;
     1842                                        &domain_pol,
     1843                                        &result);
     1844        if (!NT_STATUS_IS_OK(status)) {
     1845                goto done;
     1846        }
     1847        if (!NT_STATUS_IS_OK(result)) {
     1848                status = result;
     1849                goto done;
     1850        }
    16711851
    16721852        /* Create domain user */
     
    16791859                     SAMR_USER_ACCESS_SET_ATTRIBUTES;
    16801860
    1681         result = rpccli_samr_CreateUser2(cli, mem_ctx,
     1861        status = dcerpc_samr_CreateUser2(b, mem_ctx,
    16821862                                         &domain_pol,
    16831863                                         &acct_name,
     
    16861866                                         &user_pol,
    16871867                                         &access_granted,
    1688                                          &user_rid);
    1689 
    1690         if (!NT_STATUS_IS_OK(result))
    1691                 goto done;
    1692 
    1693         result = rpccli_samr_Close(cli, mem_ctx, &user_pol);
    1694         if (!NT_STATUS_IS_OK(result)) goto done;
    1695 
    1696         result = rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    1697         if (!NT_STATUS_IS_OK(result)) goto done;
    1698 
    1699         result = rpccli_samr_Close(cli, mem_ctx, &connect_pol);
    1700         if (!NT_STATUS_IS_OK(result)) goto done;
     1868                                         &user_rid,
     1869                                         &result);
     1870        if (!NT_STATUS_IS_OK(status)) {
     1871                goto done;
     1872        }
     1873        if (!NT_STATUS_IS_OK(result)) {
     1874                status = result;
     1875                goto done;
     1876        }
     1877
     1878        status = dcerpc_samr_Close(b, mem_ctx, &user_pol, &result);
     1879        if (!NT_STATUS_IS_OK(status)) goto done;
     1880
     1881        status = dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     1882        if (!NT_STATUS_IS_OK(status)) goto done;
     1883
     1884        status = dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
     1885        if (!NT_STATUS_IS_OK(status)) goto done;
    17011886
    17021887 done:
    1703         return result;
     1888        return status;
    17041889}
    17051890
     
    17111896{
    17121897        struct policy_handle connect_pol, domain_pol, group_pol;
    1713         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     1898        NTSTATUS status, result;
    17141899        struct lsa_String grp_name;
    17151900        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
    17161901        uint32_t rid = 0;
     1902        struct dcerpc_binding_handle *b = cli->binding_handle;
    17171903
    17181904        if ((argc < 2) || (argc > 3)) {
     
    17281914        /* Get sam policy handle */
    17291915
    1730         result = rpccli_try_samr_connects(cli, mem_ctx,
     1916        status = rpccli_try_samr_connects(cli, mem_ctx,
    17311917                                          MAXIMUM_ALLOWED_ACCESS,
    17321918                                          &connect_pol);
    1733 
    1734         if (!NT_STATUS_IS_OK(result))
    1735                 goto done;
     1919        if (!NT_STATUS_IS_OK(status)) {
     1920                goto done;
     1921        }
    17361922
    17371923        /* Get domain policy handle */
    17381924
    1739         result = rpccli_samr_OpenDomain(cli, mem_ctx,
     1925        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    17401926                                        &connect_pol,
    17411927                                        access_mask,
    17421928                                        &domain_sid,
    1743                                         &domain_pol);
    1744 
    1745         if (!NT_STATUS_IS_OK(result))
    1746                 goto done;
     1929                                        &domain_pol,
     1930                                        &result);
     1931        if (!NT_STATUS_IS_OK(status)) {
     1932                goto done;
     1933        }
     1934        if (!NT_STATUS_IS_OK(result)) {
     1935                status = result;
     1936                goto done;
     1937        }
    17471938
    17481939        /* Create domain user */
    1749         result = rpccli_samr_CreateDomainGroup(cli, mem_ctx,
     1940        status = dcerpc_samr_CreateDomainGroup(b, mem_ctx,
    17501941                                               &domain_pol,
    17511942                                               &grp_name,
    17521943                                               MAXIMUM_ALLOWED_ACCESS,
    17531944                                               &group_pol,
    1754                                                &rid);
    1755 
    1756         if (!NT_STATUS_IS_OK(result))
    1757                 goto done;
    1758 
    1759         result = rpccli_samr_Close(cli, mem_ctx, &group_pol);
    1760         if (!NT_STATUS_IS_OK(result)) goto done;
    1761 
    1762         result = rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    1763         if (!NT_STATUS_IS_OK(result)) goto done;
    1764 
    1765         result = rpccli_samr_Close(cli, mem_ctx, &connect_pol);
    1766         if (!NT_STATUS_IS_OK(result)) goto done;
     1945                                               &rid,
     1946                                               &result);
     1947        if (!NT_STATUS_IS_OK(status)) {
     1948                goto done;
     1949        }
     1950        if (!NT_STATUS_IS_OK(result)) {
     1951                status = result;
     1952                goto done;
     1953        }
     1954
     1955        status = dcerpc_samr_Close(b, mem_ctx, &group_pol, &result);
     1956        if (!NT_STATUS_IS_OK(status)) goto done;
     1957
     1958        status = dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     1959        if (!NT_STATUS_IS_OK(status)) goto done;
     1960
     1961        status = dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
     1962        if (!NT_STATUS_IS_OK(status)) goto done;
    17671963
    17681964 done:
    1769         return result;
     1965        return status;
    17701966}
    17711967
     
    17771973{
    17781974        struct policy_handle connect_pol, domain_pol, alias_pol;
    1779         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     1975        NTSTATUS status, result;
    17801976        struct lsa_String alias_name;
    17811977        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
    17821978        uint32_t rid = 0;
     1979        struct dcerpc_binding_handle *b = cli->binding_handle;
    17831980
    17841981        if ((argc < 2) || (argc > 3)) {
     
    17941991        /* Get sam policy handle */
    17951992
    1796         result = rpccli_try_samr_connects(cli, mem_ctx,
     1993        status = rpccli_try_samr_connects(cli, mem_ctx,
    17971994                                          MAXIMUM_ALLOWED_ACCESS,
    17981995                                          &connect_pol);
    1799 
    1800         if (!NT_STATUS_IS_OK(result))
    1801                 goto done;
     1996        if (!NT_STATUS_IS_OK(status)) {
     1997                goto done;
     1998        }
    18021999
    18032000        /* Get domain policy handle */
    18042001
    1805         result = rpccli_samr_OpenDomain(cli, mem_ctx,
     2002        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    18062003                                        &connect_pol,
    18072004                                        access_mask,
    18082005                                        &domain_sid,
    1809                                         &domain_pol);
    1810 
    1811         if (!NT_STATUS_IS_OK(result))
    1812                 goto done;
     2006                                        &domain_pol,
     2007                                        &result);
     2008        if (!NT_STATUS_IS_OK(status)) {
     2009                goto done;
     2010        }
     2011        if (!NT_STATUS_IS_OK(result)) {
     2012                status = result;
     2013                goto done;
     2014        }
    18132015
    18142016        /* Create domain user */
    18152017
    1816         result = rpccli_samr_CreateDomAlias(cli, mem_ctx,
     2018        status = dcerpc_samr_CreateDomAlias(b, mem_ctx,
    18172019                                            &domain_pol,
    18182020                                            &alias_name,
    18192021                                            MAXIMUM_ALLOWED_ACCESS,
    18202022                                            &alias_pol,
    1821                                             &rid);
    1822 
    1823         if (!NT_STATUS_IS_OK(result))
    1824                 goto done;
    1825 
    1826         result = rpccli_samr_Close(cli, mem_ctx, &alias_pol);
    1827         if (!NT_STATUS_IS_OK(result)) goto done;
    1828 
    1829         result = rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    1830         if (!NT_STATUS_IS_OK(result)) goto done;
    1831 
    1832         result = rpccli_samr_Close(cli, mem_ctx, &connect_pol);
    1833         if (!NT_STATUS_IS_OK(result)) goto done;
     2023                                            &rid,
     2024                                            &result);
     2025        if (!NT_STATUS_IS_OK(status)) {
     2026                goto done;
     2027        }
     2028        if (!NT_STATUS_IS_OK(result)) {
     2029                status = result;
     2030                goto done;
     2031        }
     2032
     2033
     2034        status = dcerpc_samr_Close(b, mem_ctx, &alias_pol, &result);
     2035        if (!NT_STATUS_IS_OK(status)) goto done;
     2036
     2037        status = dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     2038        if (!NT_STATUS_IS_OK(status)) goto done;
     2039
     2040        status = dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
     2041        if (!NT_STATUS_IS_OK(status)) goto done;
    18342042
    18352043 done:
    1836         return result;
     2044        return status;
    18372045}
    18382046
     
    18432051                                      int argc, const char **argv)
    18442052{
    1845         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     2053        NTSTATUS status, result;
    18462054        struct policy_handle connect_pol, domain_pol;
    18472055        uint32 num_names;
    18482056        struct samr_Ids rids, name_types;
    18492057        int i;
    1850         struct lsa_String *names = NULL;;
     2058        struct lsa_String *names = NULL;
     2059        struct dcerpc_binding_handle *b = cli->binding_handle;
    18512060
    18522061        if (argc < 3) {
     
    18592068        /* Get sam policy and domain handles */
    18602069
    1861         result = rpccli_try_samr_connects(cli, mem_ctx,
     2070        status = rpccli_try_samr_connects(cli, mem_ctx,
    18622071                                          MAXIMUM_ALLOWED_ACCESS,
    18632072                                          &connect_pol);
    1864 
    1865         if (!NT_STATUS_IS_OK(result))
    1866                 goto done;
    1867 
    1868         result = get_domain_handle(cli, mem_ctx, argv[1],
     2073        if (!NT_STATUS_IS_OK(status)) {
     2074                goto done;
     2075        }
     2076
     2077        status = get_domain_handle(cli, mem_ctx, argv[1],
    18692078                                   &connect_pol,
    18702079                                   MAXIMUM_ALLOWED_ACCESS,
    18712080                                   &domain_sid,
    18722081                                   &domain_pol);
    1873 
    1874         if (!NT_STATUS_IS_OK(result))
    1875                 goto done;
     2082        if (!NT_STATUS_IS_OK(status)) {
     2083                goto done;
     2084        }
    18762085
    18772086        /* Look up names */
     
    18802089
    18812090        if ((names = TALLOC_ARRAY(mem_ctx, struct lsa_String, num_names)) == NULL) {
    1882                 rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    1883                 rpccli_samr_Close(cli, mem_ctx, &connect_pol);
    1884                 result = NT_STATUS_NO_MEMORY;
     2091                dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     2092                dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
     2093                status = NT_STATUS_NO_MEMORY;
    18852094                goto done;
    18862095        }
     
    18902099        }
    18912100
    1892         result = rpccli_samr_LookupNames(cli, mem_ctx,
     2101        status = dcerpc_samr_LookupNames(b, mem_ctx,
    18932102                                         &domain_pol,
    18942103                                         num_names,
    18952104                                         names,
    18962105                                         &rids,
    1897                                          &name_types);
    1898 
    1899         if (!NT_STATUS_IS_OK(result))
    1900                 goto done;
     2106                                         &name_types,
     2107                                         &result);
     2108        if (!NT_STATUS_IS_OK(status)) {
     2109                goto done;
     2110        }
     2111        if (!NT_STATUS_IS_OK(result)) {
     2112                status = result;
     2113                goto done;
     2114        }
    19012115
    19022116        /* Display results */
     
    19062120                       name_types.ids[i]);
    19072121
    1908         rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    1909         rpccli_samr_Close(cli, mem_ctx, &connect_pol);
     2122        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     2123        dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
    19102124 done:
    1911         return result;
     2125        return status;
    19122126}
    19132127
     
    19182132                                     int argc, const char **argv)
    19192133{
    1920         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     2134        NTSTATUS status, result;
    19212135        struct policy_handle connect_pol, domain_pol;
    19222136        uint32_t num_rids, *rids;
    19232137        struct lsa_Strings names;
    19242138        struct samr_Ids types;
     2139        struct dcerpc_binding_handle *b = cli->binding_handle;
    19252140
    19262141        int i;
     
    19332148        /* Get sam policy and domain handles */
    19342149
    1935         result = rpccli_try_samr_connects(cli, mem_ctx,
     2150        status = rpccli_try_samr_connects(cli, mem_ctx,
    19362151                                          MAXIMUM_ALLOWED_ACCESS,
    19372152                                          &connect_pol);
    1938 
    1939         if (!NT_STATUS_IS_OK(result))
    1940                 goto done;
    1941 
    1942         result = get_domain_handle(cli, mem_ctx, argv[1],
     2153        if (!NT_STATUS_IS_OK(status)) {
     2154                goto done;
     2155        }
     2156
     2157        status = get_domain_handle(cli, mem_ctx, argv[1],
    19432158                                   &connect_pol,
    19442159                                   MAXIMUM_ALLOWED_ACCESS,
    19452160                                   &domain_sid,
    19462161                                   &domain_pol);
    1947 
    1948         if (!NT_STATUS_IS_OK(result))
    1949                 goto done;
     2162        if (!NT_STATUS_IS_OK(status)) {
     2163                goto done;
     2164        }
    19502165
    19512166        /* Look up rids */
     
    19542169
    19552170        if ((rids = TALLOC_ARRAY(mem_ctx, uint32, num_rids)) == NULL) {
    1956                 rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    1957                 rpccli_samr_Close(cli, mem_ctx, &connect_pol);
    1958                 result = NT_STATUS_NO_MEMORY;
     2171                dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     2172                dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
     2173                status = NT_STATUS_NO_MEMORY;
    19592174                goto done;
    19602175        }
     
    19632178                sscanf(argv[i + 2], "%i", &rids[i]);
    19642179
    1965         result = rpccli_samr_LookupRids(cli, mem_ctx,
     2180        status = dcerpc_samr_LookupRids(b, mem_ctx,
    19662181                                        &domain_pol,
    19672182                                        num_rids,
    19682183                                        rids,
    19692184                                        &names,
    1970                                         &types);
    1971 
     2185                                        &types,
     2186                                        &result);
     2187        if (!NT_STATUS_IS_OK(status)) {
     2188                goto done;
     2189        }
     2190        status = result;
    19722191        if (!NT_STATUS_IS_OK(result) &&
    19732192            !NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED))
     
    19812200        }
    19822201
    1983         rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    1984         rpccli_samr_Close(cli, mem_ctx, &connect_pol);
     2202        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     2203        dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
    19852204 done:
    1986         return result;
     2205        return status;
    19872206}
    19882207
     
    19932212                                         int argc, const char **argv)
    19942213{
    1995         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     2214        NTSTATUS status, result;
    19962215        struct policy_handle connect_pol, domain_pol, group_pol;
    19972216        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
     2217        struct dcerpc_binding_handle *b = cli->binding_handle;
    19982218
    19992219        if ((argc < 2) || (argc > 3)) {
     
    20072227        /* Get sam policy and domain handles */
    20082228
    2009         result = rpccli_try_samr_connects(cli, mem_ctx,
     2229        status = rpccli_try_samr_connects(cli, mem_ctx,
    20102230                                          MAXIMUM_ALLOWED_ACCESS,
    20112231                                          &connect_pol);
    2012 
    2013         if (!NT_STATUS_IS_OK(result))
    2014                 goto done;
    2015 
    2016         result = rpccli_samr_OpenDomain(cli, mem_ctx,
     2232        if (!NT_STATUS_IS_OK(status)) {
     2233                goto done;
     2234        }
     2235
     2236        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    20172237                                        &connect_pol,
    20182238                                        MAXIMUM_ALLOWED_ACCESS,
    20192239                                        &domain_sid,
    2020                                         &domain_pol);
    2021 
    2022         if (!NT_STATUS_IS_OK(result))
    2023                 goto done;
     2240                                        &domain_pol,
     2241                                        &result);
     2242        if (!NT_STATUS_IS_OK(status)) {
     2243                goto done;
     2244        }
     2245        if (!NT_STATUS_IS_OK(result)) {
     2246                status = result;
     2247                goto done;
     2248        }
    20242249
    20252250        /* Get handle on group */
     
    20312256                init_lsa_String(&lsa_acct_name, argv[1]);
    20322257
    2033                 result = rpccli_samr_LookupNames(cli, mem_ctx,
     2258                status = dcerpc_samr_LookupNames(b, mem_ctx,
    20342259                                                 &domain_pol,
    20352260                                                 1,
    20362261                                                 &lsa_acct_name,
    20372262                                                 &group_rids,
    2038                                                  &name_types);
    2039                 if (!NT_STATUS_IS_OK(result))
     2263                                                 &name_types,
     2264                                                 &result);
     2265                if (!NT_STATUS_IS_OK(status)) {
    20402266                        goto done;
    2041 
    2042                 result = rpccli_samr_OpenGroup(cli, mem_ctx,
     2267                }
     2268                if (!NT_STATUS_IS_OK(result)) {
     2269                        status = result;
     2270                        goto done;
     2271                }
     2272
     2273                status = dcerpc_samr_OpenGroup(b, mem_ctx,
    20432274                                               &domain_pol,
    20442275                                               access_mask,
    20452276                                               group_rids.ids[0],
    2046                                                &group_pol);
    2047 
    2048                 if (!NT_STATUS_IS_OK(result))
     2277                                               &group_pol,
     2278                                               &result);
     2279                if (!NT_STATUS_IS_OK(status)) {
    20492280                        goto done;
     2281                }
     2282                if (!NT_STATUS_IS_OK(result)) {
     2283                        status = result;
     2284                        goto done;
     2285                }
    20502286        }
    20512287
    20522288        /* Delete group */
    20532289
    2054         result = rpccli_samr_DeleteDomainGroup(cli, mem_ctx,
    2055                                                &group_pol);
    2056 
    2057         if (!NT_STATUS_IS_OK(result))
    2058                 goto done;
     2290        status = dcerpc_samr_DeleteDomainGroup(b, mem_ctx,
     2291                                               &group_pol,
     2292                                               &result);
     2293        if (!NT_STATUS_IS_OK(status)) {
     2294                goto done;
     2295        }
     2296        if (!NT_STATUS_IS_OK(result)) {
     2297                status = result;
     2298                goto done;
     2299        }
    20592300
    20602301        /* Display results */
    20612302
    2062         rpccli_samr_Close(cli, mem_ctx, &group_pol);
    2063         rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    2064         rpccli_samr_Close(cli, mem_ctx, &connect_pol);
     2303        dcerpc_samr_Close(b, mem_ctx, &group_pol, &result);
     2304        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     2305        dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
    20652306
    20662307 done:
    2067         return result;
     2308        return status;
    20682309}
    20692310
     
    20742315                                         int argc, const char **argv)
    20752316{
    2076         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     2317        NTSTATUS status, result;
    20772318        struct policy_handle connect_pol, domain_pol, user_pol;
    20782319        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
     2320        struct dcerpc_binding_handle *b = cli->binding_handle;
    20792321
    20802322        if ((argc < 2) || (argc > 3)) {
     
    20882330        /* Get sam policy and domain handles */
    20892331
    2090         result = rpccli_try_samr_connects(cli, mem_ctx,
     2332        status = rpccli_try_samr_connects(cli, mem_ctx,
    20912333                                          MAXIMUM_ALLOWED_ACCESS,
    20922334                                          &connect_pol);
    2093 
    2094         if (!NT_STATUS_IS_OK(result))
    2095                 goto done;
    2096 
    2097         result = rpccli_samr_OpenDomain(cli, mem_ctx,
     2335        if (!NT_STATUS_IS_OK(status)) {
     2336                goto done;
     2337        }
     2338
     2339        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    20982340                                        &connect_pol,
    20992341                                        MAXIMUM_ALLOWED_ACCESS,
    21002342                                        &domain_sid,
    2101                                         &domain_pol);
    2102 
    2103         if (!NT_STATUS_IS_OK(result))
    2104                 goto done;
     2343                                        &domain_pol,
     2344                                        &result);
     2345        if (!NT_STATUS_IS_OK(status)) {
     2346                goto done;
     2347        }
     2348        if (!NT_STATUS_IS_OK(result)) {
     2349                status = result;
     2350                goto done;
     2351        }
    21052352
    21062353        /* Get handle on user */
     
    21122359                init_lsa_String(&lsa_acct_name, argv[1]);
    21132360
    2114                 result = rpccli_samr_LookupNames(cli, mem_ctx,
     2361                status = dcerpc_samr_LookupNames(b, mem_ctx,
    21152362                                                 &domain_pol,
    21162363                                                 1,
    21172364                                                 &lsa_acct_name,
    21182365                                                 &user_rids,
    2119                                                  &name_types);
    2120 
    2121                 if (!NT_STATUS_IS_OK(result))
     2366                                                 &name_types,
     2367                                                 &result);
     2368                if (!NT_STATUS_IS_OK(status)) {
    21222369                        goto done;
    2123 
    2124                 result = rpccli_samr_OpenUser(cli, mem_ctx,
     2370                }
     2371                if (!NT_STATUS_IS_OK(result)) {
     2372                        status = result;
     2373                        goto done;
     2374                }
     2375
     2376                status = dcerpc_samr_OpenUser(b, mem_ctx,
    21252377                                              &domain_pol,
    21262378                                              access_mask,
    21272379                                              user_rids.ids[0],
    2128                                               &user_pol);
    2129 
    2130                 if (!NT_STATUS_IS_OK(result))
     2380                                              &user_pol,
     2381                                              &result);
     2382                if (!NT_STATUS_IS_OK(status)) {
    21312383                        goto done;
     2384                }
     2385                if (!NT_STATUS_IS_OK(result)) {
     2386                        status = result;
     2387                        goto done;
     2388                }
    21322389        }
    21332390
    21342391        /* Delete user */
    21352392
    2136         result = rpccli_samr_DeleteUser(cli, mem_ctx,
    2137                                         &user_pol);
    2138 
    2139         if (!NT_STATUS_IS_OK(result))
    2140                 goto done;
     2393        status = dcerpc_samr_DeleteUser(b, mem_ctx,
     2394                                        &user_pol,
     2395                                        &result);
     2396        if (!NT_STATUS_IS_OK(status)) {
     2397                goto done;
     2398        }
     2399        if (!NT_STATUS_IS_OK(result)) {
     2400                status = result;
     2401                goto done;
     2402        }
    21412403
    21422404        /* Display results */
    21432405
    2144         rpccli_samr_Close(cli, mem_ctx, &user_pol);
    2145         rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    2146         rpccli_samr_Close(cli, mem_ctx, &connect_pol);
     2406        dcerpc_samr_Close(b, mem_ctx, &user_pol, &result);
     2407        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     2408        dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
    21472409
    21482410 done:
    2149         return result;
     2411        return status;
    21502412}
    21512413
     
    21582420{
    21592421        struct policy_handle connect_pol, domain_pol, user_pol, *pol;
    2160         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
    2161         uint32 sec_info = DACL_SECURITY_INFORMATION;
     2422        NTSTATUS status, result;
     2423        uint32 sec_info = SECINFO_DACL;
    21622424        uint32 user_rid = 0;
    21632425        TALLOC_CTX *ctx = NULL;
    2164         SEC_DESC_BUF *sec_desc_buf=NULL;
     2426        struct sec_desc_buf *sec_desc_buf=NULL;
    21652427        bool domain = False;
     2428        struct dcerpc_binding_handle *b = cli->binding_handle;
    21662429
    21672430        ctx=talloc_init("cmd_samr_query_sec_obj");
     
    21852448        }
    21862449
    2187         result = rpccli_try_samr_connects(cli, mem_ctx,
     2450        status = rpccli_try_samr_connects(cli, mem_ctx,
    21882451                                          MAXIMUM_ALLOWED_ACCESS,
    21892452                                          &connect_pol);
    2190 
    2191         if (!NT_STATUS_IS_OK(result))
    2192                 goto done;
    2193 
    2194         if (domain || user_rid)
    2195                 result = rpccli_samr_OpenDomain(cli, mem_ctx,
     2453        if (!NT_STATUS_IS_OK(status)) {
     2454                goto done;
     2455        }
     2456
     2457        if (domain || user_rid) {
     2458                status = dcerpc_samr_OpenDomain(b, mem_ctx,
    21962459                                                &connect_pol,
    21972460                                                MAXIMUM_ALLOWED_ACCESS,
    21982461                                                &domain_sid,
    2199                                                 &domain_pol);
    2200 
    2201         if (!NT_STATUS_IS_OK(result))
    2202                 goto done;
    2203 
    2204         if (user_rid)
    2205                 result = rpccli_samr_OpenUser(cli, mem_ctx,
     2462                                                &domain_pol,
     2463                                                &result);
     2464                if (!NT_STATUS_IS_OK(status)) {
     2465                        goto done;
     2466                }
     2467                if (!NT_STATUS_IS_OK(result)) {
     2468                        status = result;
     2469                        goto done;
     2470                }
     2471        }
     2472
     2473        if (user_rid) {
     2474                status = dcerpc_samr_OpenUser(b, mem_ctx,
    22062475                                              &domain_pol,
    22072476                                              MAXIMUM_ALLOWED_ACCESS,
    22082477                                              user_rid,
    2209                                               &user_pol);
    2210 
    2211         if (!NT_STATUS_IS_OK(result))
    2212                 goto done;
     2478                                              &user_pol,
     2479                                              &result);
     2480                if (!NT_STATUS_IS_OK(status)) {
     2481                        goto done;
     2482                }
     2483                if (!NT_STATUS_IS_OK(result)) {
     2484                        status = result;
     2485                        goto done;
     2486                }
     2487        }
    22132488
    22142489        /* Pick which query pol to use */
     
    22242499        /* Query SAM security object */
    22252500
    2226         result = rpccli_samr_QuerySecurity(cli, mem_ctx,
     2501        status = dcerpc_samr_QuerySecurity(b, mem_ctx,
    22272502                                           pol,
    22282503                                           sec_info,
    2229                                            &sec_desc_buf);
    2230 
    2231         if (!NT_STATUS_IS_OK(result))
    2232                 goto done;
     2504                                           &sec_desc_buf,
     2505                                           &result);
     2506        if (!NT_STATUS_IS_OK(status)) {
     2507                goto done;
     2508        }
     2509        if (!NT_STATUS_IS_OK(result)) {
     2510                status = result;
     2511                goto done;
     2512        }
    22332513
    22342514        display_sec_desc(sec_desc_buf->sd);
    22352515
    2236         rpccli_samr_Close(cli, mem_ctx, &user_pol);
    2237         rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    2238         rpccli_samr_Close(cli, mem_ctx, &connect_pol);
     2516        dcerpc_samr_Close(b, mem_ctx, &user_pol, &result);
     2517        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     2518        dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
    22392519done:
    22402520        talloc_destroy(ctx);
    2241         return result;
     2521        return status;
    22422522}
    22432523
     
    22462526                                           int argc, const char **argv)
    22472527{
    2248         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     2528        NTSTATUS status, result;
    22492529        struct policy_handle connect_pol, domain_pol, user_pol;
    22502530        struct samr_PwInfo info;
    22512531        uint32_t rid;
     2532        struct dcerpc_binding_handle *b = cli->binding_handle;
    22522533
    22532534        if (argc != 2) {
     
    22582539        sscanf(argv[1], "%i", &rid);
    22592540
    2260         result = rpccli_try_samr_connects(cli, mem_ctx,
     2541        status = rpccli_try_samr_connects(cli, mem_ctx,
    22612542                                          MAXIMUM_ALLOWED_ACCESS,
    22622543                                          &connect_pol);
    2263 
    2264         if (!NT_STATUS_IS_OK(result)) {
    2265                 goto done;
    2266         }
    2267 
    2268         result = rpccli_samr_OpenDomain(cli, mem_ctx,
     2544        if (!NT_STATUS_IS_OK(status)) {
     2545                goto done;
     2546        }
     2547
     2548        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    22692549                                        &connect_pol,
    22702550                                        MAXIMUM_ALLOWED_ACCESS,
    22712551                                        &domain_sid,
    2272                                         &domain_pol);
    2273 
    2274         if (!NT_STATUS_IS_OK(result)) {
    2275                 goto done;
    2276         }
    2277 
    2278         result = rpccli_samr_OpenUser(cli, mem_ctx,
     2552                                        &domain_pol,
     2553                                        &result);
     2554        if (!NT_STATUS_IS_OK(status)) {
     2555                goto done;
     2556        }
     2557        if (!NT_STATUS_IS_OK(result)) {
     2558                status = result;
     2559                goto done;
     2560        }
     2561
     2562        status = dcerpc_samr_OpenUser(b, mem_ctx,
    22792563                                      &domain_pol,
    22802564                                      MAXIMUM_ALLOWED_ACCESS,
    22812565                                      rid,
    2282                                       &user_pol);
    2283 
    2284         if (!NT_STATUS_IS_OK(result)) {
    2285                 goto done;
    2286         }
    2287 
    2288         result = rpccli_samr_GetUserPwInfo(cli, mem_ctx, &user_pol, &info);
     2566                                      &user_pol,
     2567                                      &result);
     2568        if (!NT_STATUS_IS_OK(status)) {
     2569                goto done;
     2570        }
     2571        if (!NT_STATUS_IS_OK(result)) {
     2572                status = result;
     2573                goto done;
     2574        }
     2575
     2576        status = dcerpc_samr_GetUserPwInfo(b, mem_ctx,
     2577                                           &user_pol,
     2578                                           &info,
     2579                                           &result);
     2580        if (!NT_STATUS_IS_OK(status)) {
     2581                goto done;
     2582        }
     2583        status = result;
    22892584        if (NT_STATUS_IS_OK(result)) {
    22902585                printf("min_password_length: %d\n", info.min_password_length);
     
    22952590
    22962591 done:
    2297         rpccli_samr_Close(cli, mem_ctx, &user_pol);
    2298         rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    2299         rpccli_samr_Close(cli, mem_ctx, &connect_pol);
    2300 
    2301         return result;
     2592        dcerpc_samr_Close(b, mem_ctx, &user_pol, &result);
     2593        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     2594        dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
     2595
     2596        return status;
    23022597}
    23032598
     
    23062601                                        int argc, const char **argv)
    23072602{
    2308         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     2603        NTSTATUS status, result;
    23092604        struct lsa_String domain_name;
    23102605        struct samr_PwInfo info;
     2606        struct dcerpc_binding_handle *b = cli->binding_handle;
    23112607
    23122608        if (argc < 1 || argc > 3) {
     
    23172613        init_lsa_String(&domain_name, argv[1]);
    23182614
    2319         result = rpccli_samr_GetDomPwInfo(cli, mem_ctx, &domain_name, &info);
    2320 
     2615        status = dcerpc_samr_GetDomPwInfo(b, mem_ctx,
     2616                                          &domain_name,
     2617                                          &info,
     2618                                          &result);
     2619        if (!NT_STATUS_IS_OK(status)) {
     2620                return status;
     2621        }
    23212622        if (NT_STATUS_IS_OK(result)) {
    23222623                printf("min_password_length: %d\n", info.min_password_length);
     
    23342635{
    23352636        struct policy_handle connect_pol, domain_pol;
    2336         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     2637        NTSTATUS status, result;
    23372638        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
    23382639        fstring sid_string;
    23392640        struct lsa_String domain_name;
    2340         DOM_SID *sid = NULL;
     2641        struct dom_sid *sid = NULL;
     2642        struct dcerpc_binding_handle *b = cli->binding_handle;
    23412643
    23422644        if (argc != 2) {
     
    23472649        init_lsa_String(&domain_name, argv[1]);
    23482650
    2349         result = rpccli_try_samr_connects(cli, mem_ctx,
     2651        status = rpccli_try_samr_connects(cli, mem_ctx,
    23502652                                          access_mask,
    23512653                                          &connect_pol);
    2352 
    2353         if (!NT_STATUS_IS_OK(result))
    2354                 goto done;
    2355 
    2356         result = rpccli_samr_OpenDomain(cli, mem_ctx,
     2654        if (!NT_STATUS_IS_OK(status)) {
     2655                goto done;
     2656        }
     2657
     2658        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    23572659                                        &connect_pol,
    23582660                                        access_mask,
    23592661                                        &domain_sid,
    2360                                         &domain_pol);
    2361 
    2362         if (!NT_STATUS_IS_OK(result))
    2363                 goto done;
    2364 
    2365         result = rpccli_samr_LookupDomain(cli, mem_ctx,
     2662                                        &domain_pol,
     2663                                        &result);
     2664        if (!NT_STATUS_IS_OK(status)) {
     2665                goto done;
     2666        }
     2667        if (!NT_STATUS_IS_OK(result)) {
     2668                status = result;
     2669                goto done;
     2670        }
     2671
     2672        status = dcerpc_samr_LookupDomain(b, mem_ctx,
    23662673                                          &connect_pol,
    23672674                                          &domain_name,
    2368                                           &sid);
     2675                                          &sid,
     2676                                          &result);
     2677        if (!NT_STATUS_IS_OK(status)) {
     2678                goto done;
     2679        }
     2680        if (!NT_STATUS_IS_OK(result)) {
     2681                status = result;
     2682                goto done;
     2683        }
    23692684
    23702685        if (NT_STATUS_IS_OK(result)) {
     
    23742689        }
    23752690
    2376         rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    2377         rpccli_samr_Close(cli, mem_ctx, &connect_pol);
     2691        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     2692        dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
    23782693done:
    2379         return result;
     2694        return status;
    23802695}
    23812696
     
    23872702{
    23882703        struct policy_handle connect_pol, domain_pol, user_pol;
    2389         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     2704        NTSTATUS status, result;
    23902705        const char *user, *oldpass, *newpass;
    23912706        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
    23922707        struct samr_Ids rids, types;
    23932708        struct lsa_String lsa_acct_name;
     2709        struct dcerpc_binding_handle *b = cli->binding_handle;
    23942710
    23952711        if (argc < 3) {
     
    24042720        /* Get sam policy handle */
    24052721
    2406         result = rpccli_try_samr_connects(cli, mem_ctx,
     2722        status = rpccli_try_samr_connects(cli, mem_ctx,
    24072723                                          MAXIMUM_ALLOWED_ACCESS,
    24082724                                          &connect_pol);
    2409 
    2410         if (!NT_STATUS_IS_OK(result)) {
     2725        if (!NT_STATUS_IS_OK(status)) {
    24112726                goto done;
    24122727        }
     
    24142729        /* Get domain policy handle */
    24152730
    2416         result = rpccli_samr_OpenDomain(cli, mem_ctx,
     2731        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    24172732                                        &connect_pol,
    24182733                                        access_mask,
    24192734                                        &domain_sid,
    2420                                         &domain_pol);
    2421 
    2422         if (!NT_STATUS_IS_OK(result)) {
     2735                                        &domain_pol,
     2736                                        &result);
     2737        if (!NT_STATUS_IS_OK(status)) {
     2738                goto done;
     2739        }
     2740        if (!NT_STATUS_IS_OK(result)) {
     2741                status = result;
    24232742                goto done;
    24242743        }
     
    24262745        init_lsa_String(&lsa_acct_name, user);
    24272746
    2428         result = rpccli_samr_LookupNames(cli, mem_ctx,
     2747        status = dcerpc_samr_LookupNames(b, mem_ctx,
    24292748                                         &domain_pol,
    24302749                                         1,
    24312750                                         &lsa_acct_name,
    24322751                                         &rids,
    2433                                          &types);
    2434 
    2435         if (!NT_STATUS_IS_OK(result)) {
    2436                 goto done;
    2437         }
    2438 
    2439         result = rpccli_samr_OpenUser(cli, mem_ctx,
     2752                                         &types,
     2753                                         &result);
     2754        if (!NT_STATUS_IS_OK(status)) {
     2755                goto done;
     2756        }
     2757        if (!NT_STATUS_IS_OK(result)) {
     2758                status = result;
     2759                goto done;
     2760        }
     2761
     2762        status = dcerpc_samr_OpenUser(b, mem_ctx,
    24402763                                      &domain_pol,
    24412764                                      access_mask,
    24422765                                      rids.ids[0],
    2443                                       &user_pol);
    2444 
    2445         if (!NT_STATUS_IS_OK(result)) {
     2766                                      &user_pol,
     2767                                      &result);
     2768        if (!NT_STATUS_IS_OK(status)) {
     2769                goto done;
     2770        }
     2771        if (!NT_STATUS_IS_OK(result)) {
     2772                status = result;
    24462773                goto done;
    24472774        }
    24482775
    24492776        /* Change user password */
    2450         result = rpccli_samr_chgpasswd_user(cli, mem_ctx,
     2777        status = rpccli_samr_chgpasswd_user(cli, mem_ctx,
    24512778                                            &user_pol,
    24522779                                            newpass,
    24532780                                            oldpass);
    2454 
    2455         if (!NT_STATUS_IS_OK(result)) {
     2781        if (!NT_STATUS_IS_OK(status)) {
    24562782                goto done;
    24572783        }
     
    24592785 done:
    24602786        if (is_valid_policy_hnd(&user_pol)) {
    2461                 rpccli_samr_Close(cli, mem_ctx, &user_pol);
     2787                dcerpc_samr_Close(b, mem_ctx, &user_pol, &result);
    24622788        }
    24632789        if (is_valid_policy_hnd(&domain_pol)) {
    2464                 rpccli_samr_Close(cli, mem_ctx, &domain_pol);
     2790                dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
    24652791        }
    24662792        if (is_valid_policy_hnd(&connect_pol)) {
    2467                 rpccli_samr_Close(cli, mem_ctx, &connect_pol);
    2468         }
    2469 
    2470         return result;
     2793                dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
     2794        }
     2795
     2796        return status;
    24712797}
    24722798
     
    24792805{
    24802806        struct policy_handle connect_pol, domain_pol;
    2481         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     2807        NTSTATUS status, result;
    24822808        const char *user, *oldpass, *newpass;
    24832809        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
     2810        struct dcerpc_binding_handle *b = cli->binding_handle;
    24842811
    24852812        if (argc < 3) {
     
    24942821        /* Get sam policy handle */
    24952822
    2496         result = rpccli_try_samr_connects(cli, mem_ctx,
     2823        status = rpccli_try_samr_connects(cli, mem_ctx,
    24972824                                          MAXIMUM_ALLOWED_ACCESS,
    24982825                                          &connect_pol);
    2499 
    2500         if (!NT_STATUS_IS_OK(result))
    2501                 goto done;
     2826        if (!NT_STATUS_IS_OK(status)) {
     2827                goto done;
     2828        }
    25022829
    25032830        /* Get domain policy handle */
    25042831
    2505         result = rpccli_samr_OpenDomain(cli, mem_ctx,
     2832        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    25062833                                        &connect_pol,
    25072834                                        access_mask,
    25082835                                        &domain_sid,
    2509                                         &domain_pol);
    2510 
    2511         if (!NT_STATUS_IS_OK(result))
    2512                 goto done;
     2836                                        &domain_pol,
     2837                                        &result);
     2838        if (!NT_STATUS_IS_OK(status)) {
     2839                goto done;
     2840        }
     2841        if (!NT_STATUS_IS_OK(result)) {
     2842                status = result;
     2843                goto done;
     2844        }
    25132845
    25142846        /* Change user password */
    2515         result = rpccli_samr_chgpasswd_user2(cli, mem_ctx, user, newpass, oldpass);
    2516 
    2517         if (!NT_STATUS_IS_OK(result))
    2518                 goto done;
    2519 
    2520         result = rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    2521         if (!NT_STATUS_IS_OK(result)) goto done;
    2522 
    2523         result = rpccli_samr_Close(cli, mem_ctx, &connect_pol);
    2524         if (!NT_STATUS_IS_OK(result)) goto done;
     2847        status = rpccli_samr_chgpasswd_user2(cli, mem_ctx, user, newpass, oldpass);
     2848
     2849        if (!NT_STATUS_IS_OK(status)) {
     2850                goto done;
     2851        }
     2852
     2853        status = dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     2854        if (!NT_STATUS_IS_OK(status)) goto done;
     2855
     2856        status = dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
     2857        if (!NT_STATUS_IS_OK(status)) goto done;
    25252858
    25262859 done:
    2527         return result;
     2860        return status;
    25282861}
    25292862
     
    25362869{
    25372870        struct policy_handle connect_pol, domain_pol;
    2538         NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
     2871        NTSTATUS status, result;
    25392872        const char *user, *oldpass, *newpass;
    25402873        uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
    25412874        struct samr_DomInfo1 *info = NULL;
    2542         struct samr_ChangeReject *reject = NULL;
     2875        struct userPwdChangeFailureInformation *reject = NULL;
     2876        struct dcerpc_binding_handle *b = cli->binding_handle;
    25432877
    25442878        if (argc < 3) {
     
    25532887        /* Get sam policy handle */
    25542888
    2555         result = rpccli_try_samr_connects(cli, mem_ctx,
     2889        status = rpccli_try_samr_connects(cli, mem_ctx,
    25562890                                          MAXIMUM_ALLOWED_ACCESS,
    25572891                                          &connect_pol);
    2558 
    2559         if (!NT_STATUS_IS_OK(result))
    2560                 goto done;
     2892        if (!NT_STATUS_IS_OK(status)) {
     2893                goto done;
     2894        }
    25612895
    25622896        /* Get domain policy handle */
    25632897
    2564         result = rpccli_samr_OpenDomain(cli, mem_ctx,
     2898        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    25652899                                        &connect_pol,
    25662900                                        access_mask,
    25672901                                        &domain_sid,
    2568                                         &domain_pol);
    2569 
    2570         if (!NT_STATUS_IS_OK(result))
    2571                 goto done;
     2902                                        &domain_pol,
     2903                                        &result);
     2904        if (!NT_STATUS_IS_OK(status)) {
     2905                goto done;
     2906        }
     2907        if (!NT_STATUS_IS_OK(result)) {
     2908                status = result;
     2909                goto done;
     2910        }
    25722911
    25732912        /* Change user password */
    2574         result = rpccli_samr_chgpasswd_user3(cli, mem_ctx,
     2913        status = rpccli_samr_chgpasswd_user3(cli, mem_ctx,
    25752914                                             user,
    25762915                                             newpass,
     
    25782917                                             &info,
    25792918                                             &reject);
     2919        if (!NT_STATUS_IS_OK(status)) {
     2920                goto done;
     2921        }
    25802922
    25812923        if (NT_STATUS_EQUAL(result, NT_STATUS_PASSWORD_RESTRICTION)) {
     
    25832925                display_sam_dom_info_1(info);
    25842926
    2585                 switch (reject->reason) {
    2586                         case SAMR_REJECT_TOO_SHORT:
    2587                                 d_printf("SAMR_REJECT_TOO_SHORT\n");
     2927                switch (reject->extendedFailureReason) {
     2928                        case SAM_PWD_CHANGE_PASSWORD_TOO_SHORT:
     2929                                d_printf("SAM_PWD_CHANGE_PASSWORD_TOO_SHORT\n");
    25882930                                break;
    2589                         case SAMR_REJECT_IN_HISTORY:
    2590                                 d_printf("SAMR_REJECT_IN_HISTORY\n");
     2931                        case SAM_PWD_CHANGE_PWD_IN_HISTORY:
     2932                                d_printf("SAM_PWD_CHANGE_PWD_IN_HISTORY\n");
    25912933                                break;
    2592                         case SAMR_REJECT_COMPLEXITY:
    2593                                 d_printf("SAMR_REJECT_COMPLEXITY\n");
    2594                                 break;
    2595                         case SAMR_REJECT_OTHER:
    2596                                 d_printf("SAMR_REJECT_OTHER\n");
     2934                        case SAM_PWD_CHANGE_NOT_COMPLEX:
     2935                                d_printf("SAM_PWD_CHANGE_NOT_COMPLEX\n");
    25972936                                break;
    25982937                        default:
    25992938                                d_printf("unknown reject reason: %d\n",
    2600                                         reject->reason);
     2939                                        reject->extendedFailureReason);
    26012940                                break;
    26022941                }
    26032942        }
    26042943
    2605         if (!NT_STATUS_IS_OK(result))
    2606                 goto done;
    2607 
    2608         result = rpccli_samr_Close(cli, mem_ctx, &domain_pol);
    2609         if (!NT_STATUS_IS_OK(result)) goto done;
    2610 
    2611         result = rpccli_samr_Close(cli, mem_ctx, &connect_pol);
    2612         if (!NT_STATUS_IS_OK(result)) goto done;
     2944        if (!NT_STATUS_IS_OK(result)) {
     2945                status = result;
     2946                goto done;
     2947        }
     2948
     2949        status = dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
     2950        if (!NT_STATUS_IS_OK(status)) goto done;
     2951
     2952        status = dcerpc_samr_Close(b, mem_ctx, &connect_pol, &result);
     2953        if (!NT_STATUS_IS_OK(status)) goto done;
    26132954
    26142955 done:
    2615         return result;
     2956        return status;
    26162957}
    26172958
     
    26222963{
    26232964        struct policy_handle connect_pol, domain_pol, user_pol;
    2624         NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
     2965        NTSTATUS status, result;
    26252966        const char *user, *param;
    26262967        uint32_t access_mask = MAXIMUM_ALLOWED_ACCESS;
     
    26342975        DATA_BLOB session_key;
    26352976        uint8_t password_expired = 0;
     2977        struct dcerpc_binding_handle *b = cli->binding_handle;
    26362978
    26372979        if (argc < 4) {
     
    27633105                                          MAXIMUM_ALLOWED_ACCESS,
    27643106                                          &connect_pol);
    2765 
    2766         if (!NT_STATUS_IS_OK(status))
    2767                 goto done;
     3107        if (!NT_STATUS_IS_OK(status)) {
     3108                goto done;
     3109        }
    27683110
    27693111        /* Get domain policy handle */
    27703112
    2771         status = rpccli_samr_OpenDomain(cli, mem_ctx,
     3113        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    27723114                                        &connect_pol,
    27733115                                        access_mask,
    27743116                                        &domain_sid,
    2775                                         &domain_pol);
     3117                                        &domain_pol,
     3118                                        &result);
    27763119
    27773120        if (!NT_STATUS_IS_OK(status))
    27783121                goto done;
     3122        if (!NT_STATUS_IS_OK(result)) {
     3123                status = result;
     3124                goto done;
     3125        }
    27793126
    27803127        user_rid = strtol(user, NULL, 0);
    27813128        if (user_rid) {
    2782                 status = rpccli_samr_OpenUser(cli, mem_ctx,
     3129                status = dcerpc_samr_OpenUser(b, mem_ctx,
    27833130                                              &domain_pol,
    27843131                                              access_mask,
    27853132                                              user_rid,
    2786                                               &user_pol);
     3133                                              &user_pol,
     3134                                              &result);
     3135                if (!NT_STATUS_IS_OK(status)) {
     3136                        goto done;
     3137                }
     3138
     3139                status = result;
    27873140        }
    27883141
     
    27963149                init_lsa_String(&lsa_acct_name, user);
    27973150
    2798                 status = rpccli_samr_LookupNames(cli, mem_ctx,
     3151                status = dcerpc_samr_LookupNames(b, mem_ctx,
    27993152                                                 &domain_pol,
    28003153                                                 1,
    28013154                                                 &lsa_acct_name,
    28023155                                                 &rids,
    2803                                                  &types);
     3156                                                 &types,
     3157                                                 &result);
    28043158                if (!NT_STATUS_IS_OK(status)) {
    28053159                        return status;
    28063160                }
    2807 
    2808                 status = rpccli_samr_OpenUser(cli, mem_ctx,
     3161                if (!NT_STATUS_IS_OK(result)) {
     3162                        return result;
     3163                }
     3164
     3165
     3166                status = dcerpc_samr_OpenUser(b, mem_ctx,
    28093167                                              &domain_pol,
    28103168                                              access_mask,
    28113169                                              rids.ids[0],
    2812                                               &user_pol);
     3170                                              &user_pol,
     3171                                              &result);
    28133172                if (!NT_STATUS_IS_OK(status)) {
    28143173                        return status;
    28153174                }
     3175                if (!NT_STATUS_IS_OK(result)) {
     3176                        return result;
     3177                }
    28163178        }
    28173179
    28183180        switch (opcode) {
    28193181        case NDR_SAMR_SETUSERINFO:
    2820                 status = rpccli_samr_SetUserInfo(cli, mem_ctx,
     3182                status = dcerpc_samr_SetUserInfo(b, mem_ctx,
    28213183                                                 &user_pol,
    28223184                                                 level,
    2823                                                  &info);
     3185                                                 &info,
     3186                                                 &result);
    28243187                break;
    28253188        case NDR_SAMR_SETUSERINFO2:
    2826                 status = rpccli_samr_SetUserInfo2(cli, mem_ctx,
     3189                status = dcerpc_samr_SetUserInfo2(b, mem_ctx,
    28273190                                                  &user_pol,
    28283191                                                  level,
    2829                                                   &info);
     3192                                                  &info,
     3193                                                  &result);
    28303194                break;
    28313195        default:
    28323196                return NT_STATUS_INVALID_PARAMETER;
    28333197        }
    2834 
     3198        if (!NT_STATUS_IS_OK(status)) {
     3199                DEBUG(0,("status: %s\n", nt_errstr(status)));
     3200                goto done;
     3201        }
     3202        if (!NT_STATUS_IS_OK(result)) {
     3203                status = result;
     3204                DEBUG(0,("result: %s\n", nt_errstr(status)));
     3205                goto done;
     3206        }
    28353207 done:
    28363208        return status;
     
    28573229                                          int argc, const char **argv)
    28583230{
    2859         NTSTATUS status;
     3231        NTSTATUS status, result;
    28603232        struct policy_handle connect_handle;
    28613233        struct policy_handle domain_handle;
     
    28633235        struct lsa_String name;
    28643236        uint32_t idx = 0;
     3237        struct dcerpc_binding_handle *b = cli->binding_handle;
    28653238
    28663239        if (argc < 2 || argc > 3) {
     
    28783251                                          SEC_FLAG_MAXIMUM_ALLOWED,
    28793252                                          &connect_handle);
    2880 
    2881         if (!NT_STATUS_IS_OK(status)) {
    2882                 goto done;
    2883         }
    2884 
    2885         status = rpccli_samr_OpenDomain(cli, mem_ctx,
     3253        if (!NT_STATUS_IS_OK(status)) {
     3254                goto done;
     3255        }
     3256
     3257        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    28863258                                        &connect_handle,
    28873259                                        SEC_FLAG_MAXIMUM_ALLOWED,
    28883260                                        &domain_sid,
    2889                                         &domain_handle);
    2890 
    2891         if (!NT_STATUS_IS_OK(status))
    2892                 goto done;
    2893 
    2894 
    2895         status = rpccli_samr_GetDisplayEnumerationIndex(cli, mem_ctx,
     3261                                        &domain_handle,
     3262                                        &result);
     3263        if (!NT_STATUS_IS_OK(status)) {
     3264                goto done;
     3265        }
     3266        if (!NT_STATUS_IS_OK(result)) {
     3267                status = result;
     3268                goto done;
     3269        }
     3270
     3271        status = dcerpc_samr_GetDisplayEnumerationIndex(b, mem_ctx,
    28963272                                                        &domain_handle,
    28973273                                                        level,
    28983274                                                        &name,
    2899                                                         &idx);
     3275                                                        &idx,
     3276                                                        &result);
     3277        if (!NT_STATUS_IS_OK(status)) {
     3278                goto done;
     3279        }
     3280
     3281        status = result;
    29003282
    29013283        if (NT_STATUS_IS_OK(status) ||
     
    29063288
    29073289        if (is_valid_policy_hnd(&domain_handle)) {
    2908                 rpccli_samr_Close(cli, mem_ctx, &domain_handle);
     3290                dcerpc_samr_Close(b, mem_ctx, &domain_handle, &result);
    29093291        }
    29103292        if (is_valid_policy_hnd(&connect_handle)) {
    2911                 rpccli_samr_Close(cli, mem_ctx, &connect_handle);
     3293                dcerpc_samr_Close(b, mem_ctx, &connect_handle, &result);
    29123294        }
    29133295
  • vendor/current/source3/rpcclient/cmd_spoolss.c

    r594 r740  
    2525#include "includes.h"
    2626#include "rpcclient.h"
    27 #include "../librpc/gen_ndr/cli_spoolss.h"
     27#include "../librpc/gen_ndr/ndr_spoolss_c.h"
     28#include "rpc_client/cli_spoolss.h"
     29#include "rpc_client/init_spoolss.h"
     30#include "registry/reg_objects.h"
     31#include "nt_printing.h"
     32#include "../libcli/security/display_sec.h"
     33#include "../libcli/security/security_descriptor.h"
     34#include "../libcli/registry/util_reg.h"
     35#include "libsmb/libsmb.h"
    2836
    2937#define RPCCLIENT_PRINTERNAME(_printername, _cli, _arg) \
     
    7280        int i=-1;
    7381
    74         DEBUG(107,("Getting architecture dependant directory\n"));
     82        DEBUG(107,("Getting architecture dependent directory\n"));
    7583        do {
    7684                i++;
     
    102110        WERROR          werror;
    103111        struct policy_handle    hnd;
    104 
    105         if (argc != 2) {
    106                 printf("Usage: %s <printername>\n", argv[0]);
     112        uint32_t access_mask = PRINTER_ALL_ACCESS;
     113        struct dcerpc_binding_handle *b = cli->binding_handle;
     114
     115        if (argc < 2) {
     116                printf("Usage: %s <printername> [access_mask]\n", argv[0]);
    107117                return WERR_OK;
    108118        }
    109119
    110         if (!cli)
    111             return WERR_GENERAL_FAILURE;
     120        if (argc >= 3) {
     121                sscanf(argv[2], "%x", &access_mask);
     122        }
    112123
    113124        /* Open the printer handle */
     
    115126        werror = rpccli_spoolss_openprinter_ex(cli, mem_ctx,
    116127                                               argv[1],
    117                                                PRINTER_ALL_ACCESS,
     128                                               access_mask,
    118129                                               &hnd);
    119130        if (W_ERROR_IS_OK(werror)) {
    120131                printf("Printer %s opened successfully\n", argv[1]);
    121                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, &werror);
     132                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &werror);
    122133
    123134                if (!W_ERROR_IS_OK(werror)) {
     
    130141}
    131142
     143/****************************************************************************
     144****************************************************************************/
     145
     146static WERROR cmd_spoolss_open_printer(struct rpc_pipe_client *cli,
     147                                       TALLOC_CTX *mem_ctx,
     148                                       int argc, const char **argv)
     149{
     150        WERROR          werror;
     151        struct policy_handle    hnd;
     152        uint32_t access_mask = PRINTER_ALL_ACCESS;
     153        NTSTATUS status;
     154        struct spoolss_DevmodeContainer devmode_ctr;
     155        struct dcerpc_binding_handle *b = cli->binding_handle;
     156
     157        ZERO_STRUCT(devmode_ctr);
     158
     159        if (argc < 2) {
     160                printf("Usage: %s <printername> [access_mask]\n", argv[0]);
     161                return WERR_OK;
     162        }
     163
     164        if (argc >= 3) {
     165                sscanf(argv[2], "%x", &access_mask);
     166        }
     167
     168        /* Open the printer handle */
     169
     170        status = dcerpc_spoolss_OpenPrinter(b, mem_ctx,
     171                                            argv[1],
     172                                            NULL,
     173                                            devmode_ctr,
     174                                            access_mask,
     175                                            &hnd,
     176                                            &werror);
     177        if (!NT_STATUS_IS_OK(status)) {
     178                return ntstatus_to_werror(status);
     179        }
     180        if (W_ERROR_IS_OK(werror)) {
     181                printf("Printer %s opened successfully\n", argv[1]);
     182                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &werror);
     183
     184                if (!W_ERROR_IS_OK(werror)) {
     185                        printf("Error closing printer handle! (%s)\n",
     186                                get_dos_error_msg(werror));
     187                }
     188        }
     189
     190        return werror;
     191}
    132192
    133193/****************************************************************************
     
    467527        struct spoolss_DevmodeContainer devmode_ctr;
    468528        struct sec_desc_buf secdesc_ctr;
     529        struct dcerpc_binding_handle *b = cli->binding_handle;
    469530
    470531        if (argc == 1 || argc > 3) {
     
    509570        info_ctr.info.info2 = &info2;
    510571
    511         status = rpccli_spoolss_SetPrinter(cli, mem_ctx,
     572        status = dcerpc_spoolss_SetPrinter(b, mem_ctx,
    512573                                           &pol,
    513574                                           &info_ctr,
     
    516577                                           0, /* command */
    517578                                           &result);
     579        if (!NT_STATUS_IS_OK(status)) {
     580                result = ntstatus_to_werror(status);
     581                goto done;
     582        }
    518583        if (W_ERROR_IS_OK(result))
    519584                printf("Success in setting comment.\n");
    520585
    521586 done:
    522         if (is_valid_policy_hnd(&pol))
    523                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
     587        if (is_valid_policy_hnd(&pol)) {
     588                WERROR _result;
     589                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &_result);
     590        }
    524591
    525592        return result;
     
    544611        struct spoolss_DevmodeContainer devmode_ctr;
    545612        struct sec_desc_buf secdesc_ctr;
     613        struct dcerpc_binding_handle *b = cli->binding_handle;
    546614
    547615        ZERO_STRUCT(devmode_ctr);
     
    585653        info_ctr.info.info2 = &info2;
    586654
    587         status = rpccli_spoolss_SetPrinter(cli, mem_ctx,
     655        status = dcerpc_spoolss_SetPrinter(b, mem_ctx,
    588656                                           &pol,
    589657                                           &info_ctr,
     
    592660                                           0, /* command */
    593661                                           &result);
     662        if (!NT_STATUS_IS_OK(status)) {
     663                result = ntstatus_to_werror(status);
     664                goto done;
     665        }
    594666        if (W_ERROR_IS_OK(result))
    595667                printf("Success in setting printername.\n");
    596668
    597669 done:
    598         if (is_valid_policy_hnd(&pol))
    599                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
     670        if (is_valid_policy_hnd(&pol)) {
     671                WERROR _result;
     672                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &_result);
     673        }
    600674
    601675        return result;
     
    614688        const char      *printername;
    615689        union spoolss_PrinterInfo info;
     690        struct dcerpc_binding_handle *b = cli->binding_handle;
    616691
    617692        if (argc == 1 || argc > 3) {
     
    680755 done:
    681756        if (is_valid_policy_hnd(&pol)) {
    682                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
     757                WERROR _result;
     758                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &_result);
    683759        }
    684760
     
    689765****************************************************************************/
    690766
    691 static void display_reg_value(struct regval_blob value)
     767static void display_reg_value(struct regval_blob *value)
    692768{
    693769        const char *text = NULL;
    694770        DATA_BLOB blob;
    695771
    696         switch(value.type) {
     772        switch(regval_type(value)) {
    697773        case REG_DWORD:
    698                 printf("%s: REG_DWORD: 0x%08x\n", value.valuename,
    699                        *((uint32_t *) value.data_p));
     774                printf("%s: REG_DWORD: 0x%08x\n", regval_name(value),
     775                       *((uint32_t *) regval_data_p(value)));
    700776                break;
    701777        case REG_SZ:
    702                 blob = data_blob_const(value.data_p, value.size);
     778                blob = data_blob_const(regval_data_p(value), regval_size(value));
    703779                pull_reg_sz(talloc_tos(), &blob, &text);
    704                 printf("%s: REG_SZ: %s\n", value.valuename, text ? text : "");
     780                printf("%s: REG_SZ: %s\n", regval_name(value), text ? text : "");
    705781                break;
    706782        case REG_BINARY: {
    707                 char *hex = hex_encode_talloc(NULL, value.data_p, value.size);
     783                char *hex = hex_encode_talloc(NULL, regval_data_p(value), regval_size(value));
    708784                size_t i, len;
    709                 printf("%s: REG_BINARY:", value.valuename);
     785                printf("%s: REG_BINARY:", regval_name(value));
    710786                len = strlen(hex);
    711787                for (i=0; i<len; i++) {
     
    725801                uint32_t i;
    726802                const char **values;
    727                 blob = data_blob_const(value.data_p, value.size);
     803                blob = data_blob_const(regval_data_p(value), regval_size(value));
    728804
    729805                if (!pull_reg_multi_sz(NULL, &blob, &values)) {
     
    732808                }
    733809
    734                 printf("%s: REG_MULTI_SZ: \n", value.valuename);
     810                printf("%s: REG_MULTI_SZ: \n", regval_name(value));
    735811                for (i=0; values[i] != NULL; i++) {
    736812                        d_printf("%s\n", values[i]);
     
    740816        }
    741817        default:
    742                 printf("%s: unknown type %d\n", value.valuename, value.type);
     818                printf("%s: unknown type %d\n", regval_name(value), regval_type(value));
    743819        }
    744820
     
    816892        uint8_t *data;
    817893        uint32_t needed;
     894        struct dcerpc_binding_handle *b = cli->binding_handle;
    818895
    819896        if (argc != 3) {
     
    858935
    859936 done:
    860         if (is_valid_policy_hnd(&pol))
    861                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
     937        if (is_valid_policy_hnd(&pol)) {
     938                WERROR _result;
     939                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &_result);
     940        }
    862941
    863942        return result;
     
    881960        uint32_t offered = 0;
    882961        uint32_t needed;
     962        struct dcerpc_binding_handle *b = cli->binding_handle;
    883963
    884964        if (argc != 4) {
     
    915995        }
    916996
    917         status = rpccli_spoolss_GetPrinterDataEx(cli, mem_ctx,
     997        status = dcerpc_spoolss_GetPrinterDataEx(b, mem_ctx,
    918998                                                 &pol,
    919999                                                 keyname,
     
    9241004                                                 &needed,
    9251005                                                 &result);
     1006        if (!NT_STATUS_IS_OK(status)) {
     1007                result = ntstatus_to_werror(status);
     1008                goto done;
     1009        }
    9261010        if (W_ERROR_EQUAL(result, WERR_MORE_DATA)) {
    9271011                offered = needed;
     
    9301014                        goto done;
    9311015                }
    932                 status = rpccli_spoolss_GetPrinterDataEx(cli, mem_ctx,
     1016                status = dcerpc_spoolss_GetPrinterDataEx(b, mem_ctx,
    9331017                                                         &pol,
    9341018                                                         keyname,
     
    9421026
    9431027        if (!NT_STATUS_IS_OK(status)) {
     1028                result = ntstatus_to_werror(status);
    9441029                goto done;
    9451030        }
     
    9541039
    9551040 done:
    956         if (is_valid_policy_hnd(&pol))
    957                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
     1041        if (is_valid_policy_hnd(&pol)) {
     1042                WERROR _result;
     1043                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &_result);
     1044        }
    9581045
    9591046        return result;
     
    11871274        uint32_t server_major_version;
    11881275        uint32_t server_minor_version;
     1276        struct dcerpc_binding_handle *b = cli->binding_handle;
    11891277
    11901278        if ((argc == 1) || (argc > 3)) {
     
    12671355
    12681356        if (is_valid_policy_hnd(&pol)) {
    1269                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
     1357                WERROR _result;
     1358                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &_result);
    12701359        }
    12711360
     
    14291518        union spoolss_DriverDirectoryInfo info;
    14301519        uint32_t needed;
     1520        struct dcerpc_binding_handle *b = cli->binding_handle;
    14311521
    14321522        if (argc > 2) {
     
    14431533        /* Get the directory.  Only use Info level 1 */
    14441534
    1445         status = rpccli_spoolss_GetPrinterDriverDirectory(cli, mem_ctx,
     1535        status = dcerpc_spoolss_GetPrinterDriverDirectory(b, mem_ctx,
    14461536                                                          cli->srv_name_slash,
    14471537                                                          env,
     
    14521542                                                          &needed,
    14531543                                                          &result);
     1544        if (!NT_STATUS_IS_OK(status)) {
     1545                return ntstatus_to_werror(status);
     1546        }
    14541547        if (W_ERROR_EQUAL(result, WERR_INSUFFICIENT_BUFFER)) {
    14551548                offered = needed;
    14561549                buffer = data_blob_talloc_zero(mem_ctx, needed);
    14571550
    1458                 status = rpccli_spoolss_GetPrinterDriverDirectory(cli, mem_ctx,
     1551                status = dcerpc_spoolss_GetPrinterDriverDirectory(b, mem_ctx,
    14591552                                                                  cli->srv_name_slash,
    14601553                                                                  env,
     
    14651558                                                                  &needed,
    14661559                                                                  &result);
     1560                if (!NT_STATUS_IS_OK(status)) {
     1561                        return ntstatus_to_werror(status);
     1562                }
    14671563        }
    14681564
     
    16101706        const char              *arch;
    16111707        char                    *driver_args;
     1708        struct dcerpc_binding_handle *b = cli->binding_handle;
    16121709
    16131710        /* parse the command arguments */
     
    16281725        arch = cmd_spoolss_get_short_archi(argv[1]);
    16291726        if (!arch) {
    1630                 printf ("Error Unknown architechture [%s]\n", argv[1]);
     1727                printf ("Error Unknown architecture [%s]\n", argv[1]);
    16311728                return WERR_INVALID_PARAM;
    16321729        }
     
    16531750        info_ctr.info.info3     = &info3;
    16541751
    1655         status = rpccli_spoolss_AddPrinterDriver(cli, mem_ctx,
     1752        status = dcerpc_spoolss_AddPrinterDriver(b, mem_ctx,
    16561753                                                 cli->srv_name_slash,
    16571754                                                 &info_ctr,
     
    17411838        struct spoolss_DevmodeContainer devmode_ctr;
    17421839        struct sec_desc_buf secdesc_ctr;
     1840        struct dcerpc_binding_handle *b = cli->binding_handle;
    17431841
    17441842        ZERO_STRUCT(devmode_ctr);
     
    17831881        info_ctr.info.info2 = &info2;
    17841882
    1785         status = rpccli_spoolss_SetPrinter(cli, mem_ctx,
     1883        status = dcerpc_spoolss_SetPrinter(b, mem_ctx,
    17861884                                           &pol,
    17871885                                           &info_ctr,
     
    17901888                                           0, /* command */
    17911889                                           &result);
     1890        if (!NT_STATUS_IS_OK(status)) {
     1891                result = ntstatus_to_werror(status);
     1892                goto done;
     1893        }
    17921894        if (!W_ERROR_IS_OK(result)) {
    17931895                printf("SetPrinter call failed!\n");
    1794                 goto done;;
     1896                goto done;
    17951897        }
    17961898
     
    18001902        /* Cleanup */
    18011903
    1802         if (is_valid_policy_hnd(&pol))
    1803                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
     1904        if (is_valid_policy_hnd(&pol)) {
     1905                WERROR _result;
     1906                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &_result);
     1907        }
    18041908
    18051909        return result;
     
    18161920        WERROR result, ret = WERR_UNKNOWN_PRINTER_DRIVER;
    18171921        NTSTATUS status;
     1922        struct dcerpc_binding_handle *b = cli->binding_handle;
    18181923
    18191924        int   i;
     
    18481953
    18491954                /* make the call to remove the driver */
    1850                 status = rpccli_spoolss_DeletePrinterDriverEx(cli, mem_ctx,
     1955                status = dcerpc_spoolss_DeletePrinterDriverEx(b, mem_ctx,
    18511956                                                              cli->srv_name_slash,
    18521957                                                              archi_table[i].long_archi,
     
    18551960                                                              archi_table[i].version,
    18561961                                                              &result);
    1857 
     1962                if (!NT_STATUS_IS_OK(status)) {
     1963                        return ntstatus_to_werror(status);
     1964                }
    18581965                if ( !W_ERROR_IS_OK(result) )
    18591966                {
     
    18851992        NTSTATUS status;
    18861993        int                     i;
     1994        struct dcerpc_binding_handle *b = cli->binding_handle;
    18871995
    18881996        /* parse the command arguments */
     
    18972005
    18982006                /* make the call to remove the driver */
    1899                 status = rpccli_spoolss_DeletePrinterDriver(cli, mem_ctx,
     2007                status = dcerpc_spoolss_DeletePrinterDriver(b, mem_ctx,
    19002008                                                            cli->srv_name_slash,
    19012009                                                            archi_table[i].long_archi,
     
    19032011                                                            &result);
    19042012                if (!NT_STATUS_IS_OK(status)) {
    1905                         if (W_ERROR_IS_OK(result)) {
    1906                                 result = ntstatus_to_werror(status);
    1907                         }
     2013                        result = ntstatus_to_werror(status);
     2014                        continue;
    19082015                }
    19092016                if ( !W_ERROR_IS_OK(result) ) {
    19102017                        if ( !W_ERROR_EQUAL(result, WERR_UNKNOWN_PRINTER_DRIVER) ) {
    1911                                 printf ("Failed to remove driver %s for arch [%s] - error 0x%x!\n",
     2018                                printf ("Failed to remove driver %s for arch [%s] - error %s!\n",
    19122019                                        argv[1], archi_table[i].long_archi,
    1913                                         W_ERROR_V(result));
     2020                                        win_errstr(result));
    19142021                        }
    19152022                } else {
     
    19362043        union spoolss_PrintProcessorDirectoryInfo info;
    19372044        uint32_t needed;
     2045        struct dcerpc_binding_handle *b = cli->binding_handle;
    19382046
    19392047        /* parse the command arguments */
     
    19472055        }
    19482056
    1949         status = rpccli_spoolss_GetPrintProcessorDirectory(cli, mem_ctx,
     2057        status = dcerpc_spoolss_GetPrintProcessorDirectory(b, mem_ctx,
    19502058                                                           cli->srv_name_slash,
    19512059                                                           environment,
     
    19562064                                                           &needed,
    19572065                                                           &result);
     2066        if (!NT_STATUS_IS_OK(status)) {
     2067                return ntstatus_to_werror(status);
     2068        }
    19582069        if (W_ERROR_EQUAL(result, WERR_INSUFFICIENT_BUFFER)) {
    19592070                offered = needed;
    19602071                buffer = data_blob_talloc_zero(mem_ctx, needed);
    19612072
    1962                 status = rpccli_spoolss_GetPrintProcessorDirectory(cli, mem_ctx,
     2073                status = dcerpc_spoolss_GetPrintProcessorDirectory(b, mem_ctx,
    19632074                                                                   cli->srv_name_slash,
    19642075                                                                   environment,
     
    19692080                                                                   &needed,
    19702081                                                                   &result);
     2082                if (!NT_STATUS_IS_OK(status)) {
     2083                        return ntstatus_to_werror(status);
     2084                }
    19712085        }
    19722086
     
    19922106        struct spoolss_AddFormInfo2 info2;
    19932107        uint32_t level = 1;
     2108        struct dcerpc_binding_handle *b = cli->binding_handle;
    19942109
    19952110        /* Parse the command arguments */
     
    20502165
    20512166                break;
     2167        default:
     2168                werror = WERR_INVALID_PARAM;
     2169                goto done;
    20522170        }
    20532171
     
    20552173
    20562174
    2057         status = rpccli_spoolss_AddForm(cli, mem_ctx,
     2175        status = dcerpc_spoolss_AddForm(b, mem_ctx,
    20582176                                        &handle,
    20592177                                        level,
    20602178                                        info,
    20612179                                        &werror);
    2062 
     2180        if (!NT_STATUS_IS_OK(status)) {
     2181                werror = ntstatus_to_werror(status);
     2182                goto done;
     2183        }
    20632184 done:
    2064         if (is_valid_policy_hnd(&handle))
    2065                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
     2185        if (is_valid_policy_hnd(&handle)) {
     2186                WERROR _result;
     2187                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &handle, &_result);
     2188        }
    20662189
    20672190        return werror;
     
    20802203        union spoolss_AddFormInfo info;
    20812204        struct spoolss_AddFormInfo1 info1;
     2205        struct dcerpc_binding_handle *b = cli->binding_handle;
    20822206
    20832207        /* Parse the command arguments */
     
    21142238        /* Set the form */
    21152239
    2116         status = rpccli_spoolss_SetForm(cli, mem_ctx,
     2240        status = dcerpc_spoolss_SetForm(b, mem_ctx,
    21172241                                        &handle,
    21182242                                        argv[2],
     
    21202244                                        info,
    21212245                                        &werror);
    2122 
     2246        if (!NT_STATUS_IS_OK(status)) {
     2247                werror = ntstatus_to_werror(status);
     2248                goto done;
     2249        }
    21232250 done:
    2124         if (is_valid_policy_hnd(&handle))
    2125                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
     2251        if (is_valid_policy_hnd(&handle)) {
     2252                WERROR _result;
     2253                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &handle, &_result);
     2254        }
    21262255
    21272256        return werror;
     
    21972326        uint32_t needed;
    21982327        uint32_t level = 1;
     2328        struct dcerpc_binding_handle *b = cli->binding_handle;
    21992329
    22002330        /* Parse the command arguments */
     
    22222352        /* Get the form */
    22232353
    2224         status = rpccli_spoolss_GetForm(cli, mem_ctx,
     2354        status = dcerpc_spoolss_GetForm(b, mem_ctx,
    22252355                                        &handle,
    22262356                                        argv[2],
     
    22312361                                        &needed,
    22322362                                        &werror);
     2363        if (!NT_STATUS_IS_OK(status)) {
     2364                werror = ntstatus_to_werror(status);
     2365                goto done;
     2366        }
    22332367        if (W_ERROR_EQUAL(werror, WERR_INSUFFICIENT_BUFFER)) {
    22342368                buffer = data_blob_talloc_zero(mem_ctx, needed);
    22352369                offered = needed;
    2236                 status = rpccli_spoolss_GetForm(cli, mem_ctx,
     2370                status = dcerpc_spoolss_GetForm(b, mem_ctx,
    22372371                                                &handle,
    22382372                                                argv[2],
     
    22432377                                                &needed,
    22442378                                                &werror);
    2245         }
    2246 
    2247         if (!NT_STATUS_IS_OK(status)) {
    2248                 return werror;
     2379                if (!NT_STATUS_IS_OK(status)) {
     2380                        werror = ntstatus_to_werror(status);
     2381                        goto done;
     2382                }
     2383        }
     2384
     2385        if (!W_ERROR_IS_OK(werror)) {
     2386                goto done;
    22492387        }
    22502388
     
    22592397
    22602398 done:
    2261         if (is_valid_policy_hnd(&handle))
    2262                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
     2399        if (is_valid_policy_hnd(&handle)) {
     2400                WERROR _result;
     2401                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &handle, &_result);
     2402        }
    22632403
    22642404        return werror;
     
    22762416        NTSTATUS status;
    22772417        const char *printername;
     2418        struct dcerpc_binding_handle *b = cli->binding_handle;
    22782419
    22792420        /* Parse the command arguments */
     
    22972438        /* Delete the form */
    22982439
    2299         status = rpccli_spoolss_DeleteForm(cli, mem_ctx,
     2440        status = dcerpc_spoolss_DeleteForm(b, mem_ctx,
    23002441                                           &handle,
    23012442                                           argv[2],
    23022443                                           &werror);
    23032444        if (!NT_STATUS_IS_OK(status)) {
    2304                 return ntstatus_to_werror(status);
     2445                werror = ntstatus_to_werror(status);
     2446                goto done;
    23052447        }
    23062448
    23072449 done:
    2308         if (is_valid_policy_hnd(&handle))
    2309                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
     2450        if (is_valid_policy_hnd(&handle)) {
     2451                WERROR _result;
     2452                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &handle, &_result);
     2453        }
    23102454
    23112455        return werror;
     
    23242468        uint32_t num_forms, level = 1, i;
    23252469        union spoolss_FormInfo *forms;
     2470        struct dcerpc_binding_handle *b = cli->binding_handle;
    23262471
    23272472        /* Parse the command arguments */
     
    23732518
    23742519 done:
    2375         if (is_valid_policy_hnd(&handle))
    2376                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
     2520        if (is_valid_policy_hnd(&handle)) {
     2521                WERROR _result;
     2522                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &handle, &_result);
     2523        }
    23772524
    23782525        return werror;
     
    23942541        union spoolss_PrinterData data;
    23952542        DATA_BLOB blob;
     2543        struct dcerpc_binding_handle *b = cli->binding_handle;
    23962544
    23972545        /* parse the command arguments */
     
    24002548                        " <value> <data>\n",
    24012549                        argv[0]);
    2402                 result = WERR_INVALID_PARAM;
    2403                 goto done;
     2550                return WERR_OK;
    24042551        }
    24052552
     
    25012648        }
    25022649
    2503         status = rpccli_spoolss_SetPrinterData(cli, mem_ctx,
     2650        status = dcerpc_spoolss_SetPrinterData(b, mem_ctx,
    25042651                                               &pol,
    25052652                                               argv[3], /* value_name */
     
    25082655                                               blob.length,
    25092656                                               &result);
     2657        if (!NT_STATUS_IS_OK(status)) {
     2658                printf ("Unable to set [%s=%s]!\n", argv[3], argv[4]);
     2659                result = ntstatus_to_werror(status);
     2660                goto done;
     2661        }
    25102662        if (!W_ERROR_IS_OK(result)) {
    25112663                printf ("Unable to set [%s=%s]!\n", argv[3], argv[4]);
     
    25292681        /* cleanup */
    25302682        if (is_valid_policy_hnd(&pol)) {
    2531                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
     2683                WERROR _result;
     2684                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &_result);
    25322685        }
    25332686
     
    25882741        struct policy_handle hnd;
    25892742        union spoolss_JobInfo *info;
     2743        struct dcerpc_binding_handle *b = cli->binding_handle;
    25902744
    25912745        if (argc < 2 || argc > 3) {
     
    26392793done:
    26402794        if (is_valid_policy_hnd(&hnd)) {
    2641                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL);
     2795                WERROR _result;
     2796                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &_result);
    26422797        }
    26432798
     
    26582813        uint32_t level = 1;
    26592814        union spoolss_JobInfo info;
     2815        struct dcerpc_binding_handle *b = cli->binding_handle;
    26602816
    26612817        if (argc < 3 || argc > 4) {
     
    27152871done:
    27162872        if (is_valid_policy_hnd(&hnd)) {
    2717                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL);
     2873                WERROR _result;
     2874                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &_result);
    27182875        }
    27192876
     
    27232880/****************************************************************************
    27242881****************************************************************************/
     2882
     2883static struct {
     2884        const char *name;
     2885        enum spoolss_JobControl val;
     2886} cmdvals[] = {
     2887        {"PAUSE", SPOOLSS_JOB_CONTROL_PAUSE},
     2888        {"RESUME", SPOOLSS_JOB_CONTROL_RESUME},
     2889        {"CANCEL", SPOOLSS_JOB_CONTROL_CANCEL},
     2890        {"RESTART", SPOOLSS_JOB_CONTROL_RESTART},
     2891        {"DELETE", SPOOLSS_JOB_CONTROL_DELETE},
     2892        {"SEND_TO_PRINTER", SPOOLSS_JOB_CONTROL_SEND_TO_PRINTER},
     2893        {"EJECTED", SPOOLSS_JOB_CONTROL_LAST_PAGE_EJECTED},
     2894        {"RETAIN", SPOOLSS_JOB_CONTROL_RETAIN},
     2895        {"RELEASE", SPOOLSS_JOB_CONTROL_RELEASE}
     2896};
     2897
     2898static enum spoolss_JobControl parse_setjob_command(const char *cmd)
     2899{
     2900        int i;
     2901
     2902        for (i = 0; i < sizeof(cmdvals)/sizeof(cmdvals[0]); i++) {
     2903                if (strequal(cmdvals[i].name, cmd)) {
     2904                        return cmdvals[i].val;
     2905                }
     2906        }
     2907        return (enum spoolss_JobControl)atoi(cmd);
     2908}
    27252909
    27262910static WERROR cmd_spoolss_set_job(struct rpc_pipe_client *cli,
     
    27342918        uint32_t job_id;
    27352919        enum spoolss_JobControl command;
     2920        struct dcerpc_binding_handle *b = cli->binding_handle;
    27362921
    27372922        if (argc != 4) {
    27382923                printf("Usage: %s printername job_id command\n", argv[0]);
     2924                printf("command = [PAUSE|RESUME|CANCEL|RESTART|DELETE|"
     2925                        "SEND_TO_PRINTER|EJECTED|RETAIN|RELEASE]\n");
    27392926                return WERR_OK;
    27402927        }
    27412928
    27422929        job_id = atoi(argv[2]);
    2743         command = atoi(argv[3]);
     2930        command = parse_setjob_command(argv[3]);
    27442931
    27452932        /* Open printer handle */
     
    27572944        /* Set Job */
    27582945
    2759         status = rpccli_spoolss_SetJob(cli, mem_ctx,
     2946        status = dcerpc_spoolss_SetJob(b, mem_ctx,
    27602947                                       &hnd,
    27612948                                       job_id,
     
    27632950                                       command,
    27642951                                       &result);
    2765 
     2952        if (!NT_STATUS_IS_OK(status)) {
     2953                result = ntstatus_to_werror(status);
     2954                goto done;
     2955        }
    27662956        if (!W_ERROR_IS_OK(result)) {
    27672957                goto done;
     
    27702960done:
    27712961        if (is_valid_policy_hnd(&hnd)) {
    2772                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL);
     2962                WERROR _result;
     2963                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &_result);
    27732964        }
    27742965
     
    27852976        WERROR result;
    27862977        NTSTATUS status;
    2787         uint32_t i = 0;
    27882978        const char *printername;
    27892979        struct policy_handle hnd;
    2790         uint32_t value_offered = 0;
    2791         const char *value_name = NULL;
    27922980        uint32_t value_needed;
    27932981        enum winreg_Type type;
    2794         uint8_t *data = NULL;
    2795         uint32_t data_offered = 0;
    27962982        uint32_t data_needed;
     2983        struct dcerpc_binding_handle *b = cli->binding_handle;
     2984        struct spoolss_EnumPrinterData r;
    27972985
    27982986        if (argc != 2) {
     
    28153003        /* Enumerate data */
    28163004
    2817         status = rpccli_spoolss_EnumPrinterData(cli, mem_ctx,
    2818                                                 &hnd,
    2819                                                 i,
    2820                                                 value_name,
    2821                                                 value_offered,
    2822                                                 &value_needed,
    2823                                                 &type,
    2824                                                 data,
    2825                                                 data_offered,
    2826                                                 &data_needed,
    2827                                                 &result);
    2828 
    2829         data_offered    = data_needed;
    2830         value_offered   = value_needed;
    2831         data            = talloc_zero_array(mem_ctx, uint8_t, data_needed);
    2832         value_name      = talloc_zero_array(mem_ctx, char, value_needed);
    2833 
    2834         while (NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(result)) {
    2835 
    2836                 status = rpccli_spoolss_EnumPrinterData(cli, mem_ctx,
    2837                                                         &hnd,
    2838                                                         i++,
    2839                                                         value_name,
    2840                                                         value_offered,
    2841                                                         &value_needed,
    2842                                                         &type,
    2843                                                         data,
    2844                                                         data_offered,
    2845                                                         &data_needed,
    2846                                                         &result);
    2847                 if (NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(result)) {
    2848                         struct regval_blob v;
    2849                         fstrcpy(v.valuename, value_name);
    2850                         v.type = type;
    2851                         v.size = data_offered;
    2852                         v.data_p = data;
     3005        r.in.handle = &hnd;
     3006        r.in.enum_index = 0;
     3007        r.in.value_offered = 0;
     3008        r.in.data_offered = 0;
     3009        r.out.value_name = NULL;
     3010        r.out.value_needed = &value_needed;
     3011        r.out.type = &type;
     3012        r.out.data = NULL;
     3013        r.out.data_needed = &data_needed;
     3014
     3015        status = dcerpc_spoolss_EnumPrinterData_r(b, mem_ctx, &r);
     3016        if (!NT_STATUS_IS_OK(status)) {
     3017                result = ntstatus_to_werror(status);
     3018                goto done;
     3019        }
     3020
     3021        if (!W_ERROR_IS_OK(r.out.result)) {
     3022                result = r.out.result;
     3023                goto done;
     3024        }
     3025
     3026        r.in.data_offered       = *r.out.data_needed;
     3027        r.in.value_offered      = *r.out.value_needed;
     3028        r.out.data              = talloc_zero_array(mem_ctx, uint8_t, r.in.data_offered);
     3029        r.out.value_name        = talloc_zero_array(mem_ctx, char, r.in.value_offered);
     3030
     3031        do {
     3032
     3033                status = dcerpc_spoolss_EnumPrinterData_r(b, mem_ctx, &r);
     3034                if (!NT_STATUS_IS_OK(status)) {
     3035                        result = ntstatus_to_werror(status);
     3036                        goto done;
     3037                }
     3038
     3039                if (W_ERROR_EQUAL(r.out.result, WERR_NO_MORE_ITEMS)) {
     3040                        result = WERR_OK;
     3041                        break;
     3042                }
     3043
     3044                r.in.enum_index++;
     3045
     3046                {
     3047                        struct regval_blob *v;
     3048
     3049                        v = regval_compose(talloc_tos(),
     3050                                           r.out.value_name,
     3051                                           *r.out.type,
     3052                                           r.out.data,
     3053                                           r.in.data_offered);
     3054                        if (v == NULL) {
     3055                                result = WERR_NOMEM;
     3056                                goto done;
     3057                        }
     3058
    28533059                        display_reg_value(v);
    2854                 }
    2855         }
    2856 
    2857         if (W_ERROR_V(result) == ERRnomoreitems) {
    2858                 result = W_ERROR(ERRsuccess);
    2859         }
     3060                        talloc_free(v);
     3061                }
     3062
     3063        } while (W_ERROR_IS_OK(r.out.result));
    28603064
    28613065done:
    28623066        if (is_valid_policy_hnd(&hnd)) {
    2863                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL);
     3067                WERROR _result;
     3068                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &_result);
    28643069        }
    28653070
     
    28803085        uint32_t count;
    28813086        struct spoolss_PrinterEnumValues *info;
     3087        struct dcerpc_binding_handle *b = cli->binding_handle;
    28823088
    28833089        if (argc != 3) {
     
    29193125 done:
    29203126        if (is_valid_policy_hnd(&hnd)) {
    2921                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL);
     3127                WERROR _result;
     3128                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &_result);
    29223129        }
    29233130
     
    29393146        int i;
    29403147        uint32_t offered = 0;
     3148        struct dcerpc_binding_handle *b = cli->binding_handle;
    29413149
    29423150        if (argc < 2 || argc > 4) {
     
    29863194
    29873195        if (is_valid_policy_hnd(&hnd)) {
    2988                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL);
     3196                WERROR _result;
     3197                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &_result);
    29893198        }
    29903199
     
    30053214        NTSTATUS status;
    30063215        struct spoolss_NotifyOption option;
     3216        struct dcerpc_binding_handle *b = cli->binding_handle;
    30073217
    30083218        if (argc != 2) {
     
    30623272        /* Send rffpcnex */
    30633273
    3064         status = rpccli_spoolss_RemoteFindFirstPrinterChangeNotifyEx(cli, mem_ctx,
     3274        status = dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx(b, mem_ctx,
    30653275                                                                     &hnd,
    30663276                                                                     0,
     
    30703280                                                                     &option,
    30713281                                                                     &result);
     3282        if (!NT_STATUS_IS_OK(status)) {
     3283                result = ntstatus_to_werror(status);
     3284                goto done;
     3285        }
    30723286        if (!W_ERROR_IS_OK(result)) {
    30733287                printf("Error rffpcnex %s\n", argv[1]);
     
    30763290
    30773291done:
    3078         if (is_valid_policy_hnd(&hnd))
    3079                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &hnd, NULL);
     3292        if (is_valid_policy_hnd(&hnd)) {
     3293                WERROR _result;
     3294                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &_result);
     3295        }
    30803296
    30813297        return result;
     
    31323348        WERROR werror;
    31333349        TALLOC_CTX *mem_ctx = talloc_init("compare_printer_secdesc");
    3134         SEC_DESC *sd1, *sd2;
     3350        struct security_descriptor *sd1, *sd2;
    31353351        bool result = true;
    31363352
     
    32213437                                        get_cmdline_auth_info_password(rpcclient_auth_info),
    32223438                                        get_cmdline_auth_info_use_kerberos(rpcclient_auth_info) ? CLI_FULL_CONNECTION_USE_KERBEROS : 0,
    3223                                         get_cmdline_auth_info_signing_state(rpcclient_auth_info), NULL);
     3439                                        get_cmdline_auth_info_signing_state(rpcclient_auth_info));
    32243440
    32253441        if ( !NT_STATUS_IS_OK(nt_status) )
     
    32743490
    32753491        printf("Closing printers...");
    3276         rpccli_spoolss_ClosePrinter( cli, mem_ctx, &hPrinter1, NULL );
    3277         rpccli_spoolss_ClosePrinter( cli2, mem_ctx, &hPrinter2, NULL );
     3492        {
     3493                WERROR _result;
     3494                dcerpc_spoolss_ClosePrinter(cli->binding_handle, mem_ctx, &hPrinter1, &_result);
     3495                dcerpc_spoolss_ClosePrinter(cli2->binding_handle, mem_ctx, &hPrinter2, &_result);
     3496        }
    32783497        printf("ok\n");
    32793498
     
    34633682        const char *printername;
    34643683        struct spoolss_DevmodeContainer devmode_ctr;
     3684        struct dcerpc_binding_handle *b = cli->binding_handle;
    34653685
    34663686        RPCCLIENT_PRINTERNAME(printername, cli, argv[1]);
     
    34763696        ZERO_STRUCT(devmode_ctr);
    34773697
    3478         status = rpccli_spoolss_CreatePrinterIC(cli, mem_ctx,
     3698        status = dcerpc_spoolss_CreatePrinterIC(b, mem_ctx,
    34793699                                                &handle,
    34803700                                                &gdi_handle,
    34813701                                                &devmode_ctr,
    34823702                                                &result);
     3703        if (!NT_STATUS_IS_OK(status)) {
     3704                result = ntstatus_to_werror(status);
     3705                goto done;
     3706        }
    34833707        if (!W_ERROR_IS_OK(result)) {
    34843708                goto done;
     
    34873711 done:
    34883712        if (is_valid_policy_hnd(&gdi_handle)) {
    3489                 rpccli_spoolss_DeletePrinterIC(cli, mem_ctx, &gdi_handle, NULL);
     3713                WERROR _result;
     3714                dcerpc_spoolss_DeletePrinterIC(b, mem_ctx, &gdi_handle, &_result);
    34903715        }
    34913716        if (is_valid_policy_hnd(&handle)) {
    3492                 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &handle, NULL);
     3717                WERROR _result;
     3718                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &handle, &_result);
    34933719        }
    34943720
     
    35193745        { "getdriverdir",       RPC_RTYPE_WERROR, NULL, cmd_spoolss_getdriverdir,       &ndr_table_spoolss.syntax_id, NULL, "Get print driver upload directory",   "" },
    35203746        { "getprinter",         RPC_RTYPE_WERROR, NULL, cmd_spoolss_getprinter,         &ndr_table_spoolss.syntax_id, NULL, "Get printer info",                    "" },
    3521         { "openprinter",        RPC_RTYPE_WERROR, NULL, cmd_spoolss_open_printer_ex,    &ndr_table_spoolss.syntax_id, NULL, "Open printer handle",                 "" },
     3747        { "openprinter",        RPC_RTYPE_WERROR, NULL, cmd_spoolss_open_printer,       &ndr_table_spoolss.syntax_id, NULL, "Open printer handle",                 "" },
     3748        { "openprinter_ex",     RPC_RTYPE_WERROR, NULL, cmd_spoolss_open_printer_ex,    &ndr_table_spoolss.syntax_id, NULL, "Open printer handle",                 "" },
    35223749        { "setdriver",          RPC_RTYPE_WERROR, NULL, cmd_spoolss_setdriver,          &ndr_table_spoolss.syntax_id, NULL, "Set printer driver",                  "" },
    35233750        { "getprintprocdir",    RPC_RTYPE_WERROR, NULL, cmd_spoolss_getprintprocdir,    &ndr_table_spoolss.syntax_id, NULL, "Get print processor directory",       "" },
  • vendor/current/source3/rpcclient/cmd_srvsvc.c

    r414 r740  
    2323#include "includes.h"
    2424#include "rpcclient.h"
    25 #include "../librpc/gen_ndr/cli_srvsvc.h"
     25#include "../librpc/gen_ndr/ndr_srvsvc.h"
     26#include "../librpc/gen_ndr/ndr_srvsvc_c.h"
     27#include "../libcli/security/display_sec.h"
    2628
    2729/* Display server query info */
     
    174176        WERROR result;
    175177        NTSTATUS status;
    176 
    177         if (argc > 2) {
    178                 printf("Usage: %s [infolevel]\n", argv[0]);
    179                 return WERR_OK;
    180         }
    181 
    182         if (argc == 2)
     178        const char *server_unc = cli->srv_name_slash;
     179        struct dcerpc_binding_handle *b = cli->binding_handle;
     180
     181        if (argc > 3) {
     182                printf("Usage: %s [infolevel] [server_unc]\n", argv[0]);
     183                return WERR_OK;
     184        }
     185
     186        if (argc >= 2) {
    183187                info_level = atoi(argv[1]);
    184 
    185         status = rpccli_srvsvc_NetSrvGetInfo(cli, mem_ctx,
    186                                              cli->srv_name_slash,
     188        }
     189
     190        if (argc >= 3) {
     191                server_unc = argv[2];
     192        }
     193
     194        status = dcerpc_srvsvc_NetSrvGetInfo(b, mem_ctx,
     195                                             server_unc,
    187196                                             info_level,
    188197                                             &info,
     
    268277        uint32_t *resume_handle_p = NULL;
    269278        uint32 preferred_len = 0xffffffff, i;
     279        struct dcerpc_binding_handle *b = cli->binding_handle;
    270280
    271281        if (argc > 3) {
     
    332342        switch (opcode) {
    333343                case NDR_SRVSVC_NETSHAREENUM:
    334                         status = rpccli_srvsvc_NetShareEnum(cli, mem_ctx,
     344                        status = dcerpc_srvsvc_NetShareEnum(b, mem_ctx,
    335345                                                            cli->desthost,
    336346                                                            &info_ctr,
     
    341351                        break;
    342352                case NDR_SRVSVC_NETSHAREENUMALL:
    343                         status = rpccli_srvsvc_NetShareEnumAll(cli, mem_ctx,
     353                        status = dcerpc_srvsvc_NetShareEnumAll(b, mem_ctx,
    344354                                                               cli->desthost,
    345355                                                               &info_ctr,
     
    353363        }
    354364
    355         if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
     365        if (!NT_STATUS_IS_OK(status)) {
     366                result = ntstatus_to_werror(status);
     367                goto done;
     368        }
     369        if (!W_ERROR_IS_OK(result)) {
    356370                goto done;
    357371        }
     
    407421        WERROR result;
    408422        NTSTATUS status;
     423        struct dcerpc_binding_handle *b = cli->binding_handle;
    409424
    410425        if (argc < 2 || argc > 3) {
     
    416431                info_level = atoi(argv[2]);
    417432
    418         status = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx,
     433        status = dcerpc_srvsvc_NetShareGetInfo(b, mem_ctx,
    419434                                               cli->desthost,
    420435                                               argv[1],
     
    423438                                               &result);
    424439
    425         if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
     440        if (!NT_STATUS_IS_OK(status)) {
     441                result = ntstatus_to_werror(status);
     442                goto done;
     443        }
     444        if (!W_ERROR_IS_OK(result)) {
    426445                goto done;
    427446        }
     
    457476        NTSTATUS status;
    458477        uint32_t parm_err = 0;
     478        struct dcerpc_binding_handle *b = cli->binding_handle;
    459479
    460480        if (argc > 3) {
     
    464484
    465485        /* retrieve share info */
    466         status = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx,
     486        status = dcerpc_srvsvc_NetShareGetInfo(b, mem_ctx,
    467487                                               cli->desthost,
    468488                                               argv[1],
     
    471491                                               &result);
    472492
    473         if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
     493        if (!NT_STATUS_IS_OK(status)) {
     494                result = ntstatus_to_werror(status);
     495                goto done;
     496        }
     497        if (!W_ERROR_IS_OK(result)) {
    474498                goto done;
    475499        }
     
    478502
    479503        /* set share info */
    480         status = rpccli_srvsvc_NetShareSetInfo(cli, mem_ctx,
     504        status = dcerpc_srvsvc_NetShareSetInfo(b, mem_ctx,
    481505                                               cli->desthost,
    482506                                               argv[1],
     
    486510                                               &result);
    487511
    488         if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
     512        if (!NT_STATUS_IS_OK(status)) {
     513                result = ntstatus_to_werror(status);
     514                goto done;
     515        }
     516        if (!W_ERROR_IS_OK(result)) {
    489517                goto done;
    490518        }
    491519
    492520        /* re-retrieve share info and display */
    493         status = rpccli_srvsvc_NetShareGetInfo(cli, mem_ctx,
     521        status = dcerpc_srvsvc_NetShareGetInfo(b, mem_ctx,
    494522                                               cli->desthost,
    495523                                               argv[1],
     
    497525                                               &info_get,
    498526                                               &result);
    499 
    500         if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
     527        if (!NT_STATUS_IS_OK(status)) {
     528                result = ntstatus_to_werror(status);
     529                goto done;
     530        }
     531        if (!W_ERROR_IS_OK(result)) {
    501532                goto done;
    502533        }
     
    515546        WERROR result;
    516547        NTSTATUS status;
     548        struct dcerpc_binding_handle *b = cli->binding_handle;
    517549
    518550        if (argc > 1) {
     
    521553        }
    522554
    523         status = rpccli_srvsvc_NetRemoteTOD(cli, mem_ctx,
     555        status = dcerpc_srvsvc_NetRemoteTOD(b, mem_ctx,
    524556                                            cli->srv_name_slash,
    525557                                            &tod,
     
    549581        uint32_t total_entries = 0;
    550582        uint32_t resume_handle = 0;
     583        struct dcerpc_binding_handle *b = cli->binding_handle;
    551584
    552585        if (argc > 2) {
     
    564597        info_ctr.ctr.ctr3 = &ctr3;
    565598
    566         status = rpccli_srvsvc_NetFileEnum(cli, mem_ctx,
     599        status = dcerpc_srvsvc_NetFileEnum(b, mem_ctx,
    567600                                           cli->desthost,
    568601                                           NULL,
     
    573606                                           &resume_handle,
    574607                                           &result);
    575 
    576         if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result))
    577                 goto done;
     608        if (!NT_STATUS_IS_OK(status)) {
     609                result = ntstatus_to_werror(status);
     610                goto done;
     611        }
     612
     613        if (!W_ERROR_IS_OK(result)) {
     614                goto done;
     615        }
    578616
    579617 done:
     
    589627        uint32_t name_type = 9;
    590628        uint32_t flags = 0;
     629        struct dcerpc_binding_handle *b = cli->binding_handle;
    591630
    592631        if (argc < 2 || argc > 3) {
     
    599638        }
    600639
    601         status = rpccli_srvsvc_NetNameValidate(cli, mem_ctx,
     640        status = dcerpc_srvsvc_NetNameValidate(b, mem_ctx,
    602641                                               cli->desthost,
    603642                                               argv[1],
     
    605644                                               flags,
    606645                                               &result);
     646        if (!NT_STATUS_IS_OK(status)) {
     647                result = ntstatus_to_werror(status);
     648                goto done;
     649        }
    607650
    608651        if (!W_ERROR_IS_OK(result))
     
    620663        NTSTATUS status;
    621664        struct sec_desc_buf *sd_buf = NULL;
     665        struct dcerpc_binding_handle *b = cli->binding_handle;
    622666
    623667        if (argc < 2 || argc > 4) {
     
    626670        }
    627671
    628         status = rpccli_srvsvc_NetGetFileSecurity(cli, mem_ctx,
     672        status = dcerpc_srvsvc_NetGetFileSecurity(b, mem_ctx,
    629673                                                  cli->desthost,
    630674                                                  argv[1],
     
    633677                                                  &sd_buf,
    634678                                                  &result);
    635 
    636         if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
     679        if (!NT_STATUS_IS_OK(status)) {
     680                result = ntstatus_to_werror(status);
     681                goto done;
     682        }
     683
     684        if (!W_ERROR_IS_OK(result)) {
    637685                goto done;
    638686        }
     
    650698        WERROR result;
    651699        NTSTATUS status;
     700        struct dcerpc_binding_handle *b = cli->binding_handle;
    652701
    653702        if (argc < 2 || argc > 4) {
     
    656705        }
    657706
    658         status = rpccli_srvsvc_NetSessDel(cli, mem_ctx,
     707        status = dcerpc_srvsvc_NetSessDel(b, mem_ctx,
    659708                                          cli->desthost,
    660709                                          argv[1],
    661710                                          argv[2],
    662711                                          &result);
    663 
    664         if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
     712        if (!NT_STATUS_IS_OK(status)) {
     713                result = ntstatus_to_werror(status);
     714                goto done;
     715        }
     716
     717        if (!W_ERROR_IS_OK(result)) {
    665718                goto done;
    666719        }
     
    688741        const char *client = NULL;
    689742        const char *user = NULL;
     743        struct dcerpc_binding_handle *b = cli->binding_handle;
    690744
    691745        if (argc > 6) {
     
    740794        }
    741795
    742         status = rpccli_srvsvc_NetSessEnum(cli, mem_ctx,
     796        status = dcerpc_srvsvc_NetSessEnum(b, mem_ctx,
    743797                                          cli->desthost,
    744798                                          client,
     
    750804                                          &result);
    751805
    752         if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
     806        if (!NT_STATUS_IS_OK(status)) {
     807                result = ntstatus_to_werror(status);
     808                goto done;
     809        }
     810
     811        if (!W_ERROR_IS_OK(result)) {
    753812                goto done;
    754813        }
     
    768827        uint32_t resume_handle = 0;
    769828        uint32_t level = 0;
     829        struct dcerpc_binding_handle *b = cli->binding_handle;
    770830
    771831        if (argc > 4) {
     
    784844        ZERO_STRUCT(info);
    785845
    786         status = rpccli_srvsvc_NetDiskEnum(cli, mem_ctx,
     846        status = dcerpc_srvsvc_NetDiskEnum(b, mem_ctx,
    787847                                           cli->desthost,
    788848                                           level,
     
    792852                                           &resume_handle,
    793853                                           &result);
    794 
    795         if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
     854        if (!NT_STATUS_IS_OK(status)) {
     855                result = ntstatus_to_werror(status);
     856                goto done;
     857        }
     858
     859        if (!W_ERROR_IS_OK(result)) {
    796860                goto done;
    797861        }
     
    815879        uint32_t level = 1;
    816880        const char *path = "IPC$";
     881        struct dcerpc_binding_handle *b = cli->binding_handle;
    817882
    818883        if (argc > 4) {
     
    851916        }
    852917
    853         status = rpccli_srvsvc_NetConnEnum(cli, mem_ctx,
     918        status = dcerpc_srvsvc_NetConnEnum(b, mem_ctx,
    854919                                           cli->desthost,
    855920                                           path,
     
    860925                                           &result);
    861926
    862         if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) {
     927        if (!NT_STATUS_IS_OK(status)) {
     928                result = ntstatus_to_werror(status);
     929                goto done;
     930        }
     931
     932        if (!W_ERROR_IS_OK(result)) {
    863933                goto done;
    864934        }
  • vendor/current/source3/rpcclient/cmd_test.c

    r414 r740  
    2121#include "includes.h"
    2222#include "rpcclient.h"
    23 #include "../librpc/gen_ndr/cli_lsa.h"
     23#include "../librpc/gen_ndr/ndr_lsa_c.h"
     24#include "rpc_client/cli_lsarpc.h"
     25#include "../librpc/gen_ndr/ndr_samr.h"
     26#include "../librpc/gen_ndr/winreg.h"
    2427
    2528static NTSTATUS cmd_testme(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
     
    2730{
    2831        struct rpc_pipe_client *lsa_pipe = NULL, *samr_pipe = NULL;
    29         NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
     32        NTSTATUS status = NT_STATUS_UNSUCCESSFUL, result;
    3033        struct policy_handle pol;
     34        struct dcerpc_binding_handle *b;
    3135
    3236        d_printf("testme\n");
     
    4650        }
    4751
     52        b = lsa_pipe->binding_handle;
     53
    4854        status = rpccli_lsa_open_policy(lsa_pipe, mem_ctx, False,
    4955                                        KEY_QUERY_VALUE, &pol);
     
    5258                goto done;
    5359
    54         status = rpccli_lsa_Close(lsa_pipe, mem_ctx, &pol);
     60        status = dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
    5561
    5662        if (!NT_STATUS_IS_OK(status))
    5763                goto done;
     64        if (!NT_STATUS_IS_OK(result)) {
     65                status = result;
     66                goto done;
     67        }
    5868
    5969 done:
  • vendor/current/source3/rpcclient/cmd_wkssvc.c

    r414 r740  
    2121#include "includes.h"
    2222#include "rpcclient.h"
    23 #include "../librpc/gen_ndr/cli_wkssvc.h"
     23#include "../librpc/gen_ndr/ndr_wkssvc_c.h"
    2424
    2525static WERROR cmd_wkssvc_wkstagetinfo(struct rpc_pipe_client *cli,
     
    3333        union wkssvc_NetWkstaInfo info;
    3434        const char *server_name;
     35        struct dcerpc_binding_handle *b = cli->binding_handle;
    3536
    3637        if (argc > 2) {
     
    4546        server_name = cli->desthost;
    4647
    47         status = rpccli_wkssvc_NetWkstaGetInfo(cli, mem_ctx,
     48        status = dcerpc_wkssvc_NetWkstaGetInfo(b, mem_ctx,
    4849                                               server_name,
    4950                                               level,
     
    6768        NTSTATUS status;
    6869        WERROR werr;
     70        struct dcerpc_binding_handle *b = cli->binding_handle;
    6971
    7072        server_name = cli->desthost;
    7173        name_buffer = "";
    7274
    73         status = rpccli_wkssvc_NetrGetJoinInformation(cli, mem_ctx,
     75        status = dcerpc_wkssvc_NetrGetJoinInformation(b, mem_ctx,
    7476                                                      server_name,
    7577                                                      &name_buffer,
     
    100102        NTSTATUS status;
    101103        WERROR werr;
     104        struct dcerpc_binding_handle *b = cli->binding_handle;
    102105
    103106        if (argc > 1) {
     
    111114        }
    112115
    113         status = rpccli_wkssvc_NetrMessageBufferSend(cli, mem_ctx,
     116        status = dcerpc_wkssvc_NetrMessageBufferSend(b, mem_ctx,
    114117                                                     server_name,
    115118                                                     message_name,
     
    135138        struct wkssvc_ComputerNamesCtr *ctr = NULL;
    136139        WERROR werr;
     140        struct dcerpc_binding_handle *b = cli->binding_handle;
    137141
    138142        server_name = cli->desthost;
     
    142146        }
    143147
    144         status = rpccli_wkssvc_NetrEnumerateComputerNames(cli, mem_ctx,
     148        status = dcerpc_wkssvc_NetrEnumerateComputerNames(b, mem_ctx,
    145149                                                          server_name,
    146150                                                          name_type, 0,
     
    171175        WERROR werr;
    172176        uint32_t i, num_entries, resume_handle;
     177        struct dcerpc_binding_handle *b = cli->binding_handle;
    173178
    174179        server_name = cli->desthost;
     
    180185        }
    181186
    182         status = rpccli_wkssvc_NetWkstaEnumUsers(cli, mem_ctx, server_name,
     187        status = dcerpc_wkssvc_NetWkstaEnumUsers(b, mem_ctx, server_name,
    183188                                                 &info, 1000, &num_entries,
    184189                                                 &resume_handle, &werr);
  • vendor/current/source3/rpcclient/rpcclient.c

    r587 r740  
    1010   the Free Software Foundation; either version 3 of the License, or
    1111   (at your option) any later version.
    12    
     12
    1313   This program is distributed in the hope that it will be useful,
    1414   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1616   GNU General Public License for more details.
    17    
     17
    1818   You should have received a copy of the GNU General Public License
    1919   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    2121
    2222#include "includes.h"
     23#include "popt_common.h"
    2324#include "rpcclient.h"
    2425#include "../libcli/auth/libcli_auth.h"
    25 #include "../librpc/gen_ndr/cli_lsa.h"
    26 
    27 DOM_SID domain_sid;
    28 
    29 static enum pipe_auth_type pipe_default_auth_type = PIPE_AUTH_TYPE_NONE;
     26#include "../librpc/gen_ndr/ndr_lsa_c.h"
     27#include "rpc_client/cli_lsarpc.h"
     28#include "../librpc/gen_ndr/ndr_netlogon.h"
     29#include "rpc_client/cli_netlogon.h"
     30#include "../libcli/smbreadline/smbreadline.h"
     31#include "../libcli/security/security.h"
     32#include "passdb.h"
     33#include "libsmb/libsmb.h"
     34
     35enum pipe_auth_type_spnego {
     36        PIPE_AUTH_TYPE_SPNEGO_NONE = 0,
     37        PIPE_AUTH_TYPE_SPNEGO_NTLMSSP,
     38        PIPE_AUTH_TYPE_SPNEGO_KRB5
     39};
     40
     41struct dom_sid domain_sid;
     42
     43static enum dcerpc_AuthType pipe_default_auth_type = DCERPC_AUTH_TYPE_NONE;
     44static enum pipe_auth_type_spnego pipe_default_auth_spnego_type = 0;
    3045static enum dcerpc_AuthLevel pipe_default_auth_level = DCERPC_AUTH_LEVEL_NONE;
    3146static unsigned int timeout = 0;
     
    8398                        break;
    8499                }
    85                
     100
    86101                for (i=0; commands->cmd_set[i].name; i++) {
    87102                        if ((strncmp(text, commands->cmd_set[i].name, strlen(text)) == 0) &&
     
    102117                }
    103118                commands = commands->next;
    104                
    105119        }
    106120
     
    117131        char *command;
    118132        char                    *p;
    119        
     133
    120134        if (!cmdstr || !(*cmdstr))
    121135                return NULL;
    122        
     136
    123137        p = strchr_m(*cmdstr, ';');
    124138        if (p)
     
    129143        else
    130144                *cmdstr = NULL;
    131        
     145
    132146        return command;
    133147}
     
    138152{
    139153        struct policy_handle pol;
    140         NTSTATUS result = NT_STATUS_OK;
     154        NTSTATUS result = NT_STATUS_OK, status;
    141155        static bool got_domain_sid;
    142156        TALLOC_CTX *mem_ctx;
    143157        struct rpc_pipe_client *lsapipe = NULL;
    144158        union lsa_PolicyInformation *info = NULL;
     159        struct dcerpc_binding_handle *b;
    145160
    146161        if (got_domain_sid) return;
     
    157172                goto error;
    158173        }
    159        
     174
     175        b = lsapipe->binding_handle;
     176
    160177        result = rpccli_lsa_open_policy(lsapipe, mem_ctx, True,
    161178                                     SEC_FLAG_MAXIMUM_ALLOWED,
     
    165182        }
    166183
    167         result = rpccli_lsa_QueryInfoPolicy(lsapipe, mem_ctx,
     184        status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx,
    168185                                            &pol,
    169186                                            LSA_POLICY_INFO_ACCOUNT_DOMAIN,
    170                                             &info);
     187                                            &info,
     188                                            &result);
     189        if (!NT_STATUS_IS_OK(status)) {
     190                result = status;
     191                goto error;
     192        }
    171193        if (!NT_STATUS_IS_OK(result)) {
    172194                goto error;
     
    176198        sid_copy(&domain_sid, info->account_domain.sid);
    177199
    178         rpccli_lsa_Close(lsapipe, mem_ctx, &pol);
     200        dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
    179201        TALLOC_FREE(lsapipe);
    180202        talloc_destroy(mem_ctx);
     
    218240        {
    219241                tmp_set = tmp->cmd_set;
    220                
     242
    221243                if (!StrCaseCmp(argv[1], tmp_set->name))
    222244                {
     
    232254                                        printf("\n");
    233255                        }
    234                        
     256
    235257                        /* drop out of the loop */
    236258                        break;
     
    261283        if (argc == 2) {
    262284                for (tmp = cmd_list; tmp; tmp = tmp->next) {
    263                        
     285
    264286                        tmp_set = tmp->cmd_set;
    265287
     
    313335
    314336        if (argc == 2) {
    315                 DEBUGLEVEL = atoi(argv[1]);
     337                lp_set_cmdline("log level", argv[1]);
    316338        }
    317339
     
    380402                         int argc, const char **argv)
    381403{
     404        const char *p = "[KRB5|KRB5_SPNEGO|NTLMSSP|NTLMSSP_SPNEGO|SCHANNEL]";
    382405        const char *type = "NTLMSSP";
    383406
    384407        pipe_default_auth_level = DCERPC_AUTH_LEVEL_INTEGRITY;
    385         pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP;
     408        pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP;
    386409
    387410        if (argc > 2) {
    388                 printf("Usage: %s [NTLMSSP|NTLMSSP_SPNEGO|SCHANNEL]\n", argv[0]);
     411                printf("Usage: %s %s\n", argv[0], p);
    389412                return NT_STATUS_OK;
    390413        }
     
    392415        if (argc == 2) {
    393416                type = argv[1];
    394                 if (strequal(type, "NTLMSSP")) {
    395                         pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP;
     417                if (strequal(type, "KRB5")) {
     418                        pipe_default_auth_type = DCERPC_AUTH_TYPE_KRB5;
     419                } else if (strequal(type, "KRB5_SPNEGO")) {
     420                        pipe_default_auth_type = DCERPC_AUTH_TYPE_SPNEGO;
     421                        pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_KRB5;
     422                } else if (strequal(type, "NTLMSSP")) {
     423                        pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP;
    396424                } else if (strequal(type, "NTLMSSP_SPNEGO")) {
    397                         pipe_default_auth_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP;
     425                        pipe_default_auth_type = DCERPC_AUTH_TYPE_SPNEGO;
     426                        pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP;
    398427                } else if (strequal(type, "SCHANNEL")) {
    399                         pipe_default_auth_type = PIPE_AUTH_TYPE_SCHANNEL;
     428                        pipe_default_auth_type = DCERPC_AUTH_TYPE_SCHANNEL;
    400429                } else {
    401430                        printf("unknown type %s\n", type);
     431                        printf("Usage: %s %s\n", argv[0], p);
    402432                        return NT_STATUS_INVALID_LEVEL;
    403433                }
     
    412442                         int argc, const char **argv)
    413443{
     444        const char *p = "[KRB5|KRB5_SPNEGO|NTLMSSP|NTLMSSP_SPNEGO|SCHANNEL]";
    414445        const char *type = "NTLMSSP";
    415446
    416447        pipe_default_auth_level = DCERPC_AUTH_LEVEL_PRIVACY;
    417         pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP;
     448        pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP;
    418449
    419450        if (argc > 2) {
    420                 printf("Usage: %s [NTLMSSP|NTLMSSP_SPNEGO|SCHANNEL]\n", argv[0]);
     451                printf("Usage: %s %s\n", argv[0], p);
    421452                return NT_STATUS_OK;
    422453        }
     
    424455        if (argc == 2) {
    425456                type = argv[1];
    426                 if (strequal(type, "NTLMSSP")) {
    427                         pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP;
     457                if (strequal(type, "KRB5")) {
     458                        pipe_default_auth_type = DCERPC_AUTH_TYPE_KRB5;
     459                } else if (strequal(type, "KRB5_SPNEGO")) {
     460                        pipe_default_auth_type = DCERPC_AUTH_TYPE_SPNEGO;
     461                        pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_KRB5;
     462                } else if (strequal(type, "NTLMSSP")) {
     463                        pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP;
    428464                } else if (strequal(type, "NTLMSSP_SPNEGO")) {
    429                         pipe_default_auth_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP;
     465                        pipe_default_auth_type = DCERPC_AUTH_TYPE_SPNEGO;
     466                        pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP;
    430467                } else if (strequal(type, "SCHANNEL")) {
    431                         pipe_default_auth_type = PIPE_AUTH_TYPE_SCHANNEL;
     468                        pipe_default_auth_type = DCERPC_AUTH_TYPE_SCHANNEL;
    432469                } else {
    433470                        printf("unknown type %s\n", type);
     471                        printf("Usage: %s %s\n", argv[0], p);
    434472                        return NT_STATUS_INVALID_LEVEL;
    435473                }
     
    455493
    456494                for (tmp = cmd_list; tmp; tmp = tmp->next) {
    457                        
     495
    458496                        struct cmd_set *tmp_set;
    459497
     
    478516{
    479517        pipe_default_auth_level = DCERPC_AUTH_LEVEL_NONE;
    480         pipe_default_auth_type = PIPE_AUTH_TYPE_NONE;
     518        pipe_default_auth_type = DCERPC_AUTH_TYPE_NONE;
     519        pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_NONE;
    481520
    482521        return cmd_set_ss_level();
     
    488527        d_printf("Setting schannel - sign and seal\n");
    489528        pipe_default_auth_level = DCERPC_AUTH_LEVEL_PRIVACY;
    490         pipe_default_auth_type = PIPE_AUTH_TYPE_SCHANNEL;
     529        pipe_default_auth_type = DCERPC_AUTH_TYPE_SCHANNEL;
    491530
    492531        return cmd_set_ss_level();
     
    498537        d_printf("Setting schannel - sign only\n");
    499538        pipe_default_auth_level = DCERPC_AUTH_LEVEL_INTEGRITY;
    500         pipe_default_auth_type = PIPE_AUTH_TYPE_SCHANNEL;
     539        pipe_default_auth_type = DCERPC_AUTH_TYPE_SCHANNEL;
    501540
    502541        return cmd_set_ss_level();
     
    549588        { "schannel", RPC_RTYPE_NTSTATUS, cmd_schannel, NULL,     NULL, NULL,   "Force RPC pipe connections to be sealed with 'schannel'.  Assumes valid machine account to this domain controller.", "" },
    550589        { "schannelsign", RPC_RTYPE_NTSTATUS, cmd_schannel_sign, NULL,    NULL, NULL, "Force RPC pipe connections to be signed (not sealed) with 'schannel'.  Assumes valid machine account to this domain controller.", "" },
    551         { "timeout", RPC_RTYPE_NTSTATUS, cmd_timeout, NULL,       NULL, NULL, "Set timeout (in milliseonds) for RPC operations", "" },
     590        { "timeout", RPC_RTYPE_NTSTATUS, cmd_timeout, NULL,       NULL, NULL, "Set timeout (in milliseconds) for RPC operations", "" },
    552591        { "transport", RPC_RTYPE_NTSTATUS, cmd_choose_transport, NULL,    NULL, NULL, "Choose ncacn transport for RPC operations", "" },
    553592        { "none", RPC_RTYPE_NTSTATUS, cmd_none, NULL,     NULL, NULL, "Force RPC pipe connections to have no special properties", "" },
     
    579618extern struct cmd_set drsuapi_commands[];
    580619extern struct cmd_set eventlog_commands[];
     620extern struct cmd_set winreg_commands[];
    581621
    582622static struct cmd_set *rpcclient_command_list[] = {
     
    597637        drsuapi_commands,
    598638        eventlog_commands,
     639        winreg_commands,
    599640        NULL
    600641};
     
    629670        NTSTATUS ntresult;
    630671        WERROR wresult;
    631        
     672
    632673        TALLOC_CTX *mem_ctx;
    633674
     
    643684        if ((cmd_entry->interface != NULL) && (cmd_entry->rpc_pipe == NULL)) {
    644685                switch (pipe_default_auth_type) {
    645                         case PIPE_AUTH_TYPE_NONE:
    646                                 ntresult = cli_rpc_pipe_open_noauth_transport(
    647                                         cli, default_transport,
    648                                         cmd_entry->interface,
    649                                         &cmd_entry->rpc_pipe);
    650                                 break;
     686                case DCERPC_AUTH_TYPE_NONE:
     687                        ntresult = cli_rpc_pipe_open_noauth_transport(
     688                                cli, default_transport,
     689                                cmd_entry->interface,
     690                                &cmd_entry->rpc_pipe);
     691                        break;
     692                case DCERPC_AUTH_TYPE_SPNEGO:
     693                        switch (pipe_default_auth_spnego_type) {
    651694                        case PIPE_AUTH_TYPE_SPNEGO_NTLMSSP:
    652695                                ntresult = cli_rpc_pipe_open_spnego_ntlmssp(
    653                                         cli, cmd_entry->interface,
    654                                         default_transport,
    655                                         pipe_default_auth_level,
    656                                         get_cmdline_auth_info_domain(auth_info),
    657                                         get_cmdline_auth_info_username(auth_info),
    658                                         get_cmdline_auth_info_password(auth_info),
    659                                         &cmd_entry->rpc_pipe);
     696                                                cli, cmd_entry->interface,
     697                                                default_transport,
     698                                                pipe_default_auth_level,
     699                                                get_cmdline_auth_info_domain(auth_info),
     700                                                get_cmdline_auth_info_username(auth_info),
     701                                                get_cmdline_auth_info_password(auth_info),
     702                                                &cmd_entry->rpc_pipe);
    660703                                break;
    661                         case PIPE_AUTH_TYPE_NTLMSSP:
    662                                 ntresult = cli_rpc_pipe_open_ntlmssp(
    663                                         cli, cmd_entry->interface,
    664                                         default_transport,
    665                                         pipe_default_auth_level,
    666                                         get_cmdline_auth_info_domain(auth_info),
    667                                         get_cmdline_auth_info_username(auth_info),
    668                                         get_cmdline_auth_info_password(auth_info),
    669                                         &cmd_entry->rpc_pipe);
    670                                 break;
    671                         case PIPE_AUTH_TYPE_SCHANNEL:
    672                                 ntresult = cli_rpc_pipe_open_schannel(
    673                                         cli, cmd_entry->interface,
    674                                         default_transport,
    675                                         pipe_default_auth_level,
    676                                         get_cmdline_auth_info_domain(auth_info),
    677                                         &cmd_entry->rpc_pipe);
     704                        case PIPE_AUTH_TYPE_SPNEGO_KRB5:
     705                                ntresult = cli_rpc_pipe_open_spnego_krb5(
     706                                                cli, cmd_entry->interface,
     707                                                default_transport,
     708                                                pipe_default_auth_level,
     709                                                cli->desthost,
     710                                                NULL, NULL,
     711                                                &cmd_entry->rpc_pipe);
    678712                                break;
    679713                        default:
    680                                 DEBUG(0, ("Could not initialise %s. Invalid "
    681                                           "auth type %u\n",
    682                                           get_pipe_name_from_syntax(
    683                                                   talloc_tos(),
    684                                                   cmd_entry->interface),
    685                                           pipe_default_auth_type ));
    686                                 return NT_STATUS_UNSUCCESSFUL;
     714                                ntresult = NT_STATUS_INTERNAL_ERROR;
     715                        }
     716                        break;
     717                case DCERPC_AUTH_TYPE_NTLMSSP:
     718                        ntresult = cli_rpc_pipe_open_ntlmssp(
     719                                cli, cmd_entry->interface,
     720                                default_transport,
     721                                pipe_default_auth_level,
     722                                get_cmdline_auth_info_domain(auth_info),
     723                                get_cmdline_auth_info_username(auth_info),
     724                                get_cmdline_auth_info_password(auth_info),
     725                                &cmd_entry->rpc_pipe);
     726                        break;
     727                case DCERPC_AUTH_TYPE_SCHANNEL:
     728                        ntresult = cli_rpc_pipe_open_schannel(
     729                                cli, cmd_entry->interface,
     730                                default_transport,
     731                                pipe_default_auth_level,
     732                                get_cmdline_auth_info_domain(auth_info),
     733                                &cmd_entry->rpc_pipe);
     734                        break;
     735                case DCERPC_AUTH_TYPE_KRB5:
     736                        ntresult = cli_rpc_pipe_open_krb5(
     737                                cli, cmd_entry->interface,
     738                                default_transport,
     739                                pipe_default_auth_level,
     740                                cli->desthost,
     741                                NULL, NULL,
     742                                &cmd_entry->rpc_pipe);
     743                        break;
     744                default:
     745                        DEBUG(0, ("Could not initialise %s. Invalid "
     746                                  "auth type %u\n",
     747                                  get_pipe_name_from_syntax(
     748                                          talloc_tos(),
     749                                          cmd_entry->interface),
     750                                  pipe_default_auth_type ));
     751                        return NT_STATUS_UNSUCCESSFUL;
    687752                }
    688753                if (!NT_STATUS_IS_OK(ntresult)) {
     
    858923        /* the following functions are part of the Samba debugging
    859924           facilities.  See lib/debug.c */
    860         setup_logging("rpcclient", True);
     925        setup_logging("rpcclient", DEBUG_STDOUT);
    861926
    862927        rpcclient_auth_info = user_auth_info_init(frame);
     
    9691034        if (binding->flags & DCERPC_SIGN) {
    9701035                pipe_default_auth_level = DCERPC_AUTH_LEVEL_INTEGRITY;
    971                 pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP;
     1036                pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP;
    9721037        }
    9731038        if (binding->flags & DCERPC_SEAL) {
    9741039                pipe_default_auth_level = DCERPC_AUTH_LEVEL_PRIVACY;
    975                 pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP;
     1040                pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP;
    9761041        }
    9771042        if (binding->flags & DCERPC_AUTH_SPNEGO) {
    978                 pipe_default_auth_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP;
     1043                pipe_default_auth_type = DCERPC_AUTH_TYPE_SPNEGO;
     1044                pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP;
    9791045        }
    9801046        if (binding->flags & DCERPC_AUTH_NTLM) {
    981                 pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP;
     1047                /* If neither Integrity or Privacy are requested then
     1048                 * Use just Connect level */
     1049                if (pipe_default_auth_level == DCERPC_AUTH_LEVEL_NONE) {
     1050                        pipe_default_auth_level = DCERPC_AUTH_LEVEL_CONNECT;
     1051                }
     1052
     1053                if (pipe_default_auth_type == DCERPC_AUTH_TYPE_SPNEGO) {
     1054                        pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP;
     1055                } else {
     1056                        pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP;
     1057                }
    9821058        }
    9831059        if (binding->flags & DCERPC_AUTH_KRB5) {
    984                 pipe_default_auth_type = PIPE_AUTH_TYPE_SPNEGO_KRB5;
     1060                /* If neither Integrity or Privacy are requested then
     1061                 * Use just Connect level */
     1062                if (pipe_default_auth_level == DCERPC_AUTH_LEVEL_NONE) {
     1063                        pipe_default_auth_level = DCERPC_AUTH_LEVEL_CONNECT;
     1064                }
     1065
     1066                if (pipe_default_auth_type == DCERPC_AUTH_TYPE_SPNEGO) {
     1067                        pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_KRB5;
     1068                } else {
     1069                        pipe_default_auth_type = DCERPC_AUTH_TYPE_KRB5;
     1070                }
    9851071        }
    9861072
     
    10131099                                        get_cmdline_auth_info_password(rpcclient_auth_info),
    10141100                                        flags,
    1015                                         get_cmdline_auth_info_signing_state(rpcclient_auth_info),
    1016                                         NULL);
     1101                                        get_cmdline_auth_info_signing_state(rpcclient_auth_info));
    10171102
    10181103        if (!NT_STATUS_IS_OK(nt_status)) {
  • vendor/current/source3/rpcclient/rpcclient.h

    r414 r740  
    2222#define RPCCLIENT_H
    2323
     24#include "rpc_client/cli_pipe.h"
     25
    2426typedef enum {
    2527        RPC_RTYPE_NTSTATUS = 0,
Note: See TracChangeset for help on using the changeset viewer.