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/lib/netapi
Files:
1 added
20 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/lib/netapi/cm.c

    r587 r740  
    1919
    2020#include "includes.h"
     21#include "popt_common.h"
    2122
    2223#include "lib/netapi/netapi.h"
    2324#include "lib/netapi/netapi_private.h"
     25#include "libsmb/libsmb.h"
     26#include "rpc_client/cli_pipe.h"
    2427
    2528/********************************************************************
     
    251254        return WERR_OK;
    252255}
     256
     257/********************************************************************
     258********************************************************************/
     259
     260WERROR libnetapi_get_binding_handle(struct libnetapi_ctx *ctx,
     261                                    const char *server_name,
     262                                    const struct ndr_syntax_id *interface,
     263                                    struct dcerpc_binding_handle **binding_handle)
     264{
     265        struct rpc_pipe_client *pipe_cli;
     266        WERROR result;
     267
     268        *binding_handle = NULL;
     269
     270        result = libnetapi_open_pipe(ctx, server_name, interface, &pipe_cli);
     271        if (!W_ERROR_IS_OK(result)) {
     272                return result;
     273        }
     274
     275        *binding_handle = pipe_cli->binding_handle;
     276
     277        return WERR_OK;
     278}
  • vendor/current/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c

    r478 r740  
    479479                        p = strchr(newname, '.');
    480480                        if (p) {
    481                                 *p = NULL;
     481                                *p = '\0';
    482482                        }
    483483
  • vendor/current/source3/lib/netapi/examples/netlogon/nltest.c

    r414 r740  
    3131
    3232enum {
    33         OPT_DBFLAG = 1,
     33        OPT_SERVER = 1,
     34        OPT_DBFLAG,
    3435        OPT_SC_QUERY,
    3536        OPT_SC_RESET,
    3637        OPT_SC_VERIFY,
    37         OPT_SC_CHANGE_PWD
     38        OPT_SC_CHANGE_PWD,
     39        OPT_DSGETDC,
     40        OPT_PDC,
     41        OPT_DS,
     42        OPT_DSP,
     43        OPT_GC,
     44        OPT_KDC,
     45        OPT_TIMESERV,
     46        OPT_GTIMESERV,
     47        OPT_WS,
     48        OPT_NETBIOS,
     49        OPT_DNS,
     50        OPT_IP,
     51        OPT_FORCE,
     52        OPT_WRITABLE,
     53        OPT_AVOIDSELF,
     54        OPT_LDAPONLY,
     55        OPT_BACKG,
     56        OPT_DS_6,
     57        OPT_TRY_NEXT_CLOSEST_SITE,
     58        OPT_SITE,
     59        OPT_ACCOUNT,
     60        OPT_RET_DNS,
     61        OPT_RET_NETBIOS,
     62        OPT_DSREGDNS
    3863};
    3964
     
    4166****************************************************************/
    4267
    43 static void print_result(uint32_t level,
    44                         uint8_t *buffer)
     68static void print_netlogon_info_result(uint32_t level,
     69                                      uint8_t *buffer)
    4570{
    4671        struct NETLOGON_INFO_1 *i1 = NULL;
     
    101126****************************************************************/
    102127
     128static void print_dc_info_flags(uint32_t flags)
     129{
     130        if (flags & DS_PDC_FLAG)
     131                printf("PDC ");
     132        if (flags & DS_GC_FLAG)
     133                printf("GC ");
     134        if (flags & DS_DS_FLAG)
     135                printf("DS ");
     136        if (flags & DS_LDAP_FLAG)
     137                printf("LDAP ");
     138        if (flags & DS_KDC_FLAG)
     139                printf("KDC ");
     140        if (flags & DS_TIMESERV_FLAG)
     141                printf("TIMESERV ");
     142        if (flags & DS_GOOD_TIMESERV_FLAG)
     143                printf("GTIMESERV ");
     144        if (flags & DS_WRITABLE_FLAG)
     145                printf("WRITABLE ");
     146        if (flags & DS_DNS_FOREST_FLAG)
     147                printf("DNS_FOREST ");
     148        if (flags & DS_CLOSEST_FLAG)
     149                printf("CLOSE_SITE ");
     150        if (flags & DS_FULL_SECRET_DOMAIN_6_FLAG)
     151                printf("FULL_SECRET ");
     152        /* "WS" */
     153        printf("\n");
     154}
     155
     156/****************************************************************
     157****************************************************************/
     158
     159static void print_dc_info(struct DOMAIN_CONTROLLER_INFO *dc_info)
     160{
     161        if (dc_info->flags) {
     162                printf("           DC: %s\n", dc_info->domain_controller_name);
     163                printf("      Address: %s\n", dc_info->domain_controller_address);
     164/*              printf("     Dom Guid: %s\n", X(domain_guid)); */
     165                printf("     Dom Name: %s\n", dc_info->domain_name);
     166                printf("  Forest Name: %s\n", dc_info->dns_forest_name);
     167                printf(" Dc Site Name: %s\n", dc_info->dc_site_name);
     168                printf("Our Site Name: %s\n", dc_info->client_site_name);
     169                printf("        Flags: ");
     170                print_dc_info_flags(dc_info->flags);
     171        } else {
     172                printf("           DC: %s\n", dc_info->domain_controller_name);
     173                printf("      Address: %s\n", dc_info->domain_controller_address);
     174                printf("     Dom Name: %s\n", dc_info->domain_name);
     175        }
     176}
     177
     178/****************************************************************
     179****************************************************************/
     180
    103181int main(int argc, const char **argv)
    104182{
     
    106184        NET_API_STATUS status;
    107185        struct libnetapi_ctx *ctx = NULL;
    108         const char *server_name = NULL;
     186        char *opt_server = NULL;
    109187        char *opt_domain = NULL;
    110188        int opt_dbflag = 0;
    111         uint32_t query_level;
     189        int opt_pdc = 0;
     190        int opt_ds = 0;
     191        int opt_dsp = 0;
     192        int opt_gc = 0;
     193        int opt_kdc = 0;
     194        int opt_timeserv = 0;
     195        int opt_gtimeserv = 0;
     196        int opt_ws = 0;
     197        int opt_netbios = 0;
     198        int opt_dns = 0;
     199        int opt_ip = 0;
     200        int opt_force = 0;
     201        int opt_writable = 0;
     202        int opt_avoidself = 0;
     203        int opt_ldaponly = 0;
     204        int opt_backg = 0;
     205        int opt_ds_6 = 0;
     206        int opt_try_next_closest_site = 0;
     207        char *opt_site = NULL;
     208        char *opt_account = NULL;
     209        int opt_ret_dns = 0;
     210        int opt_ret_netbios = 0;
     211        int opt_dsregdns = 0;
     212        uint32_t query_level = 0;
    112213        uint8_t *buffer = NULL;
     214        uint32_t flags = 0;
     215        struct DOMAIN_CONTROLLER_INFO *dc_info = NULL;
    113216
    114217        poptContext pc;
    115218        struct poptOption long_options[] = {
    116219                POPT_AUTOHELP
     220                {"server", 0, POPT_ARG_STRING, &opt_server, OPT_SERVER, "Servername", "SERVER"},
    117221                {"dbflag", 0, POPT_ARG_INT,   &opt_dbflag, OPT_DBFLAG, "New Debug Flag", "HEXFLAGS"},
    118222                {"sc_query", 0, POPT_ARG_STRING,   &opt_domain, OPT_SC_QUERY, "Query secure channel for domain on server", "DOMAIN"},
     
    120224                {"sc_verify", 0, POPT_ARG_STRING,   &opt_domain, OPT_SC_VERIFY, "Verify secure channel for domain on server", "DOMAIN"},
    121225                {"sc_change_pwd", 0, POPT_ARG_STRING,   &opt_domain, OPT_SC_CHANGE_PWD, "Change a secure channel password for domain on server", "DOMAIN"},
     226                {"dsgetdc", 0, POPT_ARG_STRING, &opt_domain, OPT_DSGETDC, "Call DsGetDcName", "DOMAIN"},
     227                {"pdc", 0, POPT_ARG_NONE, &opt_pdc, OPT_PDC, NULL},
     228                {"ds", 0, POPT_ARG_NONE, &opt_ds, OPT_DS, NULL},
     229                {"dsp", 0, POPT_ARG_NONE, &opt_dsp, OPT_DSP, NULL},
     230                {"gc", 0, POPT_ARG_NONE, &opt_gc, OPT_GC, NULL},
     231                {"kdc", 0, POPT_ARG_NONE, &opt_kdc, OPT_KDC, NULL},
     232                {"timeserv", 0, POPT_ARG_NONE, &opt_timeserv, OPT_TIMESERV, NULL},
     233                {"gtimeserv", 0, POPT_ARG_NONE, &opt_gtimeserv, OPT_GTIMESERV, NULL},
     234                {"ws", 0, POPT_ARG_NONE, &opt_ws, OPT_WS, NULL},
     235                {"netbios", 0, POPT_ARG_NONE, &opt_netbios, OPT_NETBIOS, NULL},
     236                {"dns", 0, POPT_ARG_NONE, &opt_dns, OPT_DNS, NULL},
     237                {"ip", 0, POPT_ARG_NONE, &opt_ip, OPT_IP, NULL},
     238                {"force", 0, POPT_ARG_NONE, &opt_force, OPT_FORCE, NULL},
     239                {"writable", 0, POPT_ARG_NONE, &opt_writable, OPT_WRITABLE, NULL},
     240                {"avoidself", 0, POPT_ARG_NONE, &opt_avoidself, OPT_AVOIDSELF, NULL},
     241                {"ldaponly", 0, POPT_ARG_NONE, &opt_ldaponly, OPT_LDAPONLY, NULL},
     242                {"backg", 0, POPT_ARG_NONE, &opt_backg, OPT_BACKG, NULL},
     243                {"ds_6", 0, POPT_ARG_NONE, &opt_ds_6, OPT_DS_6, NULL},
     244                {"try_next_closest_site", 0, POPT_ARG_NONE, &opt_try_next_closest_site, OPT_TRY_NEXT_CLOSEST_SITE, NULL},
     245                {"site", 0, POPT_ARG_STRING, &opt_site, OPT_SITE, "SITE"},
     246                {"account", 0, POPT_ARG_STRING, &opt_account, OPT_ACCOUNT, "ACCOUNT"},
     247                {"ret_dns", 0, POPT_ARG_NONE, &opt_ret_dns, OPT_RET_DNS, NULL},
     248                {"ret_netbios", 0, POPT_ARG_NONE, &opt_ret_netbios, OPT_RET_NETBIOS, NULL},
     249                {"dsregdns", 0, POPT_ARG_NONE, &opt_dsregdns, OPT_DSREGDNS, "Force registration of all DC-specific DNS records"},
    122250                POPT_COMMON_LIBNETAPI_EXAMPLES
    123251                POPT_TABLEEND
     
    131259        pc = poptGetContext("nltest", argc, argv, long_options, 0);
    132260
    133         poptSetOtherOptionHelp(pc, "server_name");
     261        poptSetOtherOptionHelp(pc, "<options>");
    134262        while((opt = poptGetNextOpt(pc)) != -1) {
    135263        }
    136 
    137         if (!poptPeekArg(pc)) {
    138                 poptPrintHelp(pc, stderr, 0);
    139                 goto done;
    140         }
    141         server_name = poptGetArg(pc);
    142264
    143265        if (argc == 1) {
     
    146268        }
    147269
    148         if (!server_name || poptGetArg(pc)) {
    149                 poptPrintHelp(pc, stderr, 0);
    150                 goto done;
    151         }
    152 
    153         if ((server_name[0] == '/' && server_name[1] == '/') ||
    154             (server_name[0] == '\\' && server_name[1] ==  '\\')) {
    155                 server_name += 2;
    156         }
    157 
    158270        poptResetContext(pc);
    159271
     
    161273                switch (opt) {
    162274
     275                case OPT_SERVER:
     276
     277                        if ((opt_server[0] == '/' && opt_server[1] == '/') ||
     278                            (opt_server[0] == '\\' && opt_server[1] ==  '\\')) {
     279                                opt_server += 2;
     280                        }
     281
     282                        break;
     283
    163284                case OPT_DBFLAG:
    164285                        query_level = 1;
    165                         status = I_NetLogonControl2(server_name,
     286                        status = I_NetLogonControl2(opt_server,
    166287                                                    NETLOGON_CONTROL_SET_DBFLAG,
    167288                                                    query_level,
     
    174295                                goto done;
    175296                        }
     297
     298                        print_netlogon_info_result(query_level, buffer);
     299
    176300                        break;
    177301                case OPT_SC_QUERY:
    178302                        query_level = 2;
    179                         status = I_NetLogonControl2(server_name,
     303                        status = I_NetLogonControl2(opt_server,
    180304                                                    NETLOGON_CONTROL_TC_QUERY,
    181305                                                    query_level,
     
    188312                                goto done;
    189313                        }
     314
     315                        print_netlogon_info_result(query_level, buffer);
     316
    190317                        break;
    191318                case OPT_SC_VERIFY:
    192319                        query_level = 2;
    193                         status = I_NetLogonControl2(server_name,
     320                        status = I_NetLogonControl2(opt_server,
    194321                                                    NETLOGON_CONTROL_TC_VERIFY,
    195322                                                    query_level,
     
    202329                                goto done;
    203330                        }
     331
     332                        print_netlogon_info_result(query_level, buffer);
     333
    204334                        break;
    205335                case OPT_SC_RESET:
    206336                        query_level = 2;
    207                         status = I_NetLogonControl2(server_name,
     337                        status = I_NetLogonControl2(opt_server,
    208338                                                    NETLOGON_CONTROL_REDISCOVER,
    209339                                                    query_level,
     
    216346                                goto done;
    217347                        }
     348
     349                        print_netlogon_info_result(query_level, buffer);
     350
    218351                        break;
    219352                case OPT_SC_CHANGE_PWD:
    220353                        query_level = 1;
    221                         status = I_NetLogonControl2(server_name,
     354                        status = I_NetLogonControl2(opt_server,
    222355                                                    NETLOGON_CONTROL_CHANGE_PASSWORD,
    223356                                                    query_level,
     
    230363                                goto done;
    231364                        }
     365
     366                        print_netlogon_info_result(query_level, buffer);
     367
     368                        break;
     369                case OPT_DSREGDNS:
     370                        query_level = 1;
     371                        status = I_NetLogonControl2(opt_server,
     372                                                    NETLOGON_CONTROL_FORCE_DNS_REG,
     373                                                    query_level,
     374                                                    NULL,
     375                                                    &buffer);
     376                        if (status != 0) {
     377                                fprintf(stderr, "I_NetlogonControl failed: Status = %d 0x%x %s\n",
     378                                        status, status,
     379                                        libnetapi_get_error_string(ctx, status));
     380                                goto done;
     381                        }
     382
     383                        print_netlogon_info_result(query_level, buffer);
     384
     385                        break;
     386                case OPT_DSGETDC:
     387                        if (opt_pdc)
     388                                flags |= DS_PDC_REQUIRED;
     389                        if (opt_ds)
     390                                flags |= DS_DIRECTORY_SERVICE_REQUIRED;
     391                        if (opt_dsp)
     392                                flags |= DS_DIRECTORY_SERVICE_PREFERRED;
     393                        if (opt_kdc)
     394                                flags |= DS_KDC_REQUIRED;
     395                        if (opt_timeserv)
     396                                flags |= DS_TIMESERV_REQUIRED;
     397                        if (opt_gtimeserv)
     398                                flags |= DS_GOOD_TIMESERV_PREFERRED;
     399                        if (opt_ws)
     400                                flags |= DS_WEB_SERVICE_REQUIRED;
     401                        if (opt_netbios)
     402                                flags |= DS_IS_FLAT_NAME;
     403                        if (opt_dns)
     404                                flags |= DS_IS_DNS_NAME;
     405                        if (opt_ip)
     406                                flags |= DS_IP_REQUIRED;
     407                        if (opt_force)
     408                                flags |= DS_FORCE_REDISCOVERY;
     409                        if (opt_writable)
     410                                flags |= DS_WRITABLE_REQUIRED;
     411                        if (opt_avoidself)
     412                                flags |= DS_AVOID_SELF;
     413                        if (opt_ldaponly)
     414                                flags |= DS_ONLY_LDAP_NEEDED;
     415                        if (opt_backg)
     416                                flags |= DS_BACKGROUND_ONLY;
     417                        if (opt_ds_6)
     418                                flags |= DS_DIRECTORY_SERVICE_6_REQUIRED;
     419                        if (opt_try_next_closest_site)
     420                                flags |= DS_TRY_NEXTCLOSEST_SITE;
     421                        if (opt_ret_dns)
     422                                flags |= DS_RETURN_DNS_NAME;
     423                        if (opt_ret_netbios)
     424                                flags |= DS_RETURN_FLAT_NAME;
     425
     426                        status = DsGetDcName(opt_server,
     427                                             opt_domain,
     428                                             NULL, /* domain_guid */
     429                                             opt_site,
     430                                             flags,
     431                                             &dc_info);
     432                        if (status != 0) {
     433                                fprintf(stderr, "DsGetDcName failed: Status = %d 0x%x %s\n",
     434                                        status, status,
     435                                        libnetapi_get_error_string(ctx, status));
     436                                goto done;
     437                        }
     438
     439                        print_dc_info(dc_info);
     440
    232441                        break;
    233442                default:
    234                         poptPrintHelp(pc, stderr, 0);
    235                         goto done;
     443                        continue;
    236444                }
    237445        }
    238 
    239         print_result(query_level, buffer);
    240446
    241447        printf("The command completed successfully\n");
  • vendor/current/source3/lib/netapi/file.c

    r594 r740  
    2424#include "lib/netapi/netapi_private.h"
    2525#include "lib/netapi/libnetapi.h"
    26 #include "../librpc/gen_ndr/cli_srvsvc.h"
     26#include "../librpc/gen_ndr/ndr_srvsvc_c.h"
    2727
    2828/****************************************************************
     
    3434        WERROR werr;
    3535        NTSTATUS status;
    36         struct rpc_pipe_client *pipe_cli = NULL;
    37 
    38         werr = libnetapi_open_pipe(ctx, r->in.server_name,
    39                                    &ndr_table_srvsvc.syntax_id,
    40                                    &pipe_cli);
    41         if (!W_ERROR_IS_OK(werr)) {
    42                 goto done;
    43         }
    44 
    45         status = rpccli_srvsvc_NetFileClose(pipe_cli, talloc_tos(),
     36        struct dcerpc_binding_handle *b;
     37
     38        werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     39                                            &ndr_table_srvsvc.syntax_id,
     40                                            &b);
     41        if (!W_ERROR_IS_OK(werr)) {
     42                goto done;
     43        }
     44
     45        status = dcerpc_srvsvc_NetFileClose(b, talloc_tos(),
    4646                                            r->in.server_name,
    4747                                            r->in.fileid,
     
    114114        WERROR werr;
    115115        NTSTATUS status;
    116         struct rpc_pipe_client *pipe_cli = NULL;
    117116        union srvsvc_NetFileInfo info;
    118117        uint32_t num_entries = 0;
     118        struct dcerpc_binding_handle *b;
    119119
    120120        if (!r->out.buffer) {
     
    130130        }
    131131
    132         werr = libnetapi_open_pipe(ctx, r->in.server_name,
    133                                    &ndr_table_srvsvc.syntax_id,
    134                                    &pipe_cli);
    135         if (!W_ERROR_IS_OK(werr)) {
    136                 goto done;
    137         }
    138 
    139         status = rpccli_srvsvc_NetFileGetInfo(pipe_cli, talloc_tos(),
     132        werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     133                                            &ndr_table_srvsvc.syntax_id,
     134                                            &b);
     135        if (!W_ERROR_IS_OK(werr)) {
     136                goto done;
     137        }
     138
     139        status = dcerpc_srvsvc_NetFileGetInfo(b, talloc_tos(),
    140140                                              r->in.server_name,
    141141                                              r->in.fileid,
     
    143143                                              &info,
    144144                                              &werr);
     145        if (!NT_STATUS_IS_OK(status)) {
     146                werr = ntstatus_to_werror(status);
     147                goto done;
     148        }
     149
    145150        if (!W_ERROR_IS_OK(werr)) {
    146151                goto done;
     
    177182        WERROR werr;
    178183        NTSTATUS status;
    179         struct rpc_pipe_client *pipe_cli = NULL;
    180184        struct srvsvc_NetFileInfoCtr info_ctr;
    181185        struct srvsvc_NetFileCtr2 ctr2;
     
    183187        uint32_t num_entries = 0;
    184188        uint32_t i;
     189        struct dcerpc_binding_handle *b;
    185190
    186191        if (!r->out.buffer) {
     
    196201        }
    197202
    198         werr = libnetapi_open_pipe(ctx, r->in.server_name,
    199                                    &ndr_table_srvsvc.syntax_id,
    200                                    &pipe_cli);
     203        werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     204                                            &ndr_table_srvsvc.syntax_id,
     205                                            &b);
    201206        if (!W_ERROR_IS_OK(werr)) {
    202207                goto done;
     
    217222        }
    218223
    219         status = rpccli_srvsvc_NetFileEnum(pipe_cli, talloc_tos(),
     224        status = dcerpc_srvsvc_NetFileEnum(b, talloc_tos(),
    220225                                           r->in.server_name,
    221226                                           r->in.base_path,
     
    226231                                           r->out.resume_handle,
    227232                                           &werr);
    228         if (NT_STATUS_IS_ERR(status)) {
     233        if (!NT_STATUS_IS_OK(status)) {
     234                werr = ntstatus_to_werror(status);
     235                goto done;
     236        }
     237
     238        if (!W_ERROR_IS_OK(werr) && !W_ERROR_EQUAL(werr, WERR_MORE_DATA)) {
    229239                goto done;
    230240        }
  • vendor/current/source3/lib/netapi/getdc.c

    r594 r740  
    2020#include "includes.h"
    2121
     22#include "../librpc/gen_ndr/ndr_netlogon_c.h"
    2223#include "librpc/gen_ndr/libnetapi.h"
    2324#include "lib/netapi/netapi.h"
    2425#include "lib/netapi/netapi_private.h"
    2526#include "lib/netapi/libnetapi.h"
    26 #include "libnet/libnet.h"
    27 #include "../librpc/gen_ndr/cli_netlogon.h"
    2827
    2928/********************************************************************
     
    4241                      struct NetGetDCName *r)
    4342{
    44         struct rpc_pipe_client *pipe_cli = NULL;
    4543        NTSTATUS status;
    4644        WERROR werr;
     45        struct dcerpc_binding_handle *b;
    4746
    48         werr = libnetapi_open_pipe(ctx, r->in.server_name,
    49                                    &ndr_table_netlogon.syntax_id,
    50                                    &pipe_cli);
     47        werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     48                                            &ndr_table_netlogon.syntax_id,
     49                                            &b);
    5150        if (!W_ERROR_IS_OK(werr)) {
    5251                goto done;
    5352        }
    5453
    55         status = rpccli_netr_GetDcName(pipe_cli, talloc_tos(),
     54        status = dcerpc_netr_GetDcName(b, talloc_tos(),
    5655                                       r->in.server_name,
    5756                                       r->in.domain_name,
     
    8281                         struct NetGetAnyDCName *r)
    8382{
    84         struct rpc_pipe_client *pipe_cli = NULL;
    8583        NTSTATUS status;
    8684        WERROR werr;
     85        struct dcerpc_binding_handle *b;
    8786
    88         werr = libnetapi_open_pipe(ctx, r->in.server_name,
    89                                    &ndr_table_netlogon.syntax_id,
    90                                    &pipe_cli);
     87        werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     88                                            &ndr_table_netlogon.syntax_id,
     89                                            &b);
    9190        if (!W_ERROR_IS_OK(werr)) {
    9291                goto done;
    9392        }
    9493
    95         status = rpccli_netr_GetAnyDCName(pipe_cli, talloc_tos(),
     94        status = dcerpc_netr_GetAnyDCName(b, talloc_tos(),
    9695                                          r->in.server_name,
    9796                                          r->in.domain_name,
     
    9998                                          &werr);
    10099        if (!NT_STATUS_IS_OK(status)) {
     100                werr = ntstatus_to_werror(status);
    101101                goto done;
    102102        }
     
    114114{
    115115        NTSTATUS status;
     116        struct libnetapi_private_ctx *priv;
     117
     118        priv = talloc_get_type_abort(ctx->private_data,
     119                struct libnetapi_private_ctx);
    116120
    117121        status = dsgetdcname(ctx,
    118                              NULL,
     122                             priv->msg_ctx,
    119123                             r->in.domain_name,
    120124                             r->in.domain_guid,
     
    139143        WERROR werr;
    140144        NTSTATUS status = NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND;
    141         struct rpc_pipe_client *pipe_cli = NULL;
     145        struct dcerpc_binding_handle *b;
    142146
    143         werr = libnetapi_open_pipe(ctx, r->in.server_name,
    144                                    &ndr_table_netlogon.syntax_id,
    145                                    &pipe_cli);
     147        werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     148                                            &ndr_table_netlogon.syntax_id,
     149                                            &b);
    146150        if (!W_ERROR_IS_OK(werr)) {
    147151                goto done;
    148152        }
    149153
    150         status = rpccli_netr_DsRGetDCName(pipe_cli,
     154        status = dcerpc_netr_DsRGetDCNameEx(b,
     155                                            ctx,
     156                                            r->in.server_name,
     157                                            r->in.domain_name,
     158                                            r->in.domain_guid,
     159                                            r->in.site_name,
     160                                            r->in.flags,
     161                                            (struct netr_DsRGetDCNameInfo **)r->out.dc_info,
     162                                            &werr);
     163        if (NT_STATUS_IS_OK(status) && W_ERROR_IS_OK(werr)) {
     164                goto done;
     165        }
     166
     167        status = dcerpc_netr_DsRGetDCName(b,
    151168                                          ctx,
    152169                                          r->in.server_name,
  • vendor/current/source3/lib/netapi/group.c

    r594 r740  
    2424#include "lib/netapi/netapi_private.h"
    2525#include "lib/netapi/libnetapi.h"
    26 #include "../librpc/gen_ndr/cli_samr.h"
     26#include "rpc_client/rpc_client.h"
     27#include "../librpc/gen_ndr/ndr_samr_c.h"
     28#include "rpc_client/init_lsa.h"
     29#include "../libcli/security/security.h"
    2730
    2831/****************************************************************
     
    3336{
    3437        struct rpc_pipe_client *pipe_cli = NULL;
    35         NTSTATUS status;
     38        NTSTATUS status, result;
    3639        WERROR werr;
    3740        struct policy_handle connect_handle, domain_handle, group_handle;
     
    3942        struct dom_sid2 *domain_sid = NULL;
    4043        uint32_t rid = 0;
     44        struct dcerpc_binding_handle *b = NULL;
    4145
    4246        struct GROUP_INFO_0 *info0 = NULL;
     
    7882                goto done;
    7983        }
     84
     85        b = pipe_cli->binding_handle;
    8086
    8187        werr = libnetapi_samr_open_domain(ctx, pipe_cli,
     
    106112        }
    107113
    108         status = rpccli_samr_CreateDomainGroup(pipe_cli, talloc_tos(),
     114        status = dcerpc_samr_CreateDomainGroup(b, talloc_tos(),
    109115                                               &domain_handle,
    110116                                               &lsa_group_name,
     
    112118                                               SAMR_GROUP_ACCESS_SET_INFO,
    113119                                               &group_handle,
    114                                                &rid);
    115 
    116         if (!NT_STATUS_IS_OK(status)) {
    117                 werr = ntstatus_to_werror(status);
     120                                               &rid,
     121                                               &result);
     122
     123        if (!NT_STATUS_IS_OK(status)) {
     124                werr = ntstatus_to_werror(status);
     125                goto done;
     126        }
     127        if (!NT_STATUS_IS_OK(result)) {
     128                werr = ntstatus_to_werror(result);
    118129                goto done;
    119130        }
     
    125136                                                info1->grpi1_comment);
    126137
    127                                 status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),
     138                                status = dcerpc_samr_SetGroupInfo(b, talloc_tos(),
    128139                                                                  &group_handle,
    129140                                                                  GROUPINFODESCRIPTION,
    130                                                                   &info);
     141                                                                  &info,
     142                                                                  &result);
    131143                        }
    132144                        break;
     
    136148                                                info2->grpi2_comment);
    137149
    138                                 status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),
     150                                status = dcerpc_samr_SetGroupInfo(b, talloc_tos(),
    139151                                                                  &group_handle,
    140152                                                                  GROUPINFODESCRIPTION,
    141                                                                   &info);
     153                                                                  &info,
     154                                                                  &result);
    142155                                if (!NT_STATUS_IS_OK(status)) {
    143156                                        werr = ntstatus_to_werror(status);
    144157                                        goto failed;
    145158                                }
     159                                if (!NT_STATUS_IS_OK(result)) {
     160                                        werr = ntstatus_to_werror(result);
     161                                        goto failed;
     162                                }
    146163                        }
    147164
    148165                        if (info2->grpi2_attributes != 0) {
    149166                                info.attributes.attributes = info2->grpi2_attributes;
    150                                 status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),
     167                                status = dcerpc_samr_SetGroupInfo(b, talloc_tos(),
    151168                                                                  &group_handle,
    152169                                                                  GROUPINFOATTRIBUTES,
    153                                                                   &info);
     170                                                                  &info,
     171                                                                  &result);
    154172
    155173                        }
     
    160178                                                info3->grpi3_comment);
    161179
    162                                 status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),
     180                                status = dcerpc_samr_SetGroupInfo(b, talloc_tos(),
    163181                                                                  &group_handle,
    164182                                                                  GROUPINFODESCRIPTION,
    165                                                                   &info);
     183                                                                  &info,
     184                                                                  &result);
    166185                                if (!NT_STATUS_IS_OK(status)) {
    167186                                        werr = ntstatus_to_werror(status);
    168187                                        goto failed;
    169188                                }
     189                                if (!NT_STATUS_IS_OK(result)) {
     190                                        werr = ntstatus_to_werror(result);
     191                                        goto failed;
     192                                }
    170193                        }
    171194
    172195                        if (info3->grpi3_attributes != 0) {
    173196                                info.attributes.attributes = info3->grpi3_attributes;
    174                                 status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),
     197                                status = dcerpc_samr_SetGroupInfo(b, talloc_tos(),
    175198                                                                  &group_handle,
    176199                                                                  GROUPINFOATTRIBUTES,
    177                                                                   &info);
     200                                                                  &info,
     201                                                                  &result);
    178202                        }
    179203                        break;
     
    184208        if (!NT_STATUS_IS_OK(status)) {
    185209                werr = ntstatus_to_werror(status);
     210                goto failed;
     211        }
     212        if (!NT_STATUS_IS_OK(result)) {
     213                werr = ntstatus_to_werror(result);
    186214                goto failed;
    187215        }
     
    191219
    192220 failed:
    193         rpccli_samr_DeleteDomainGroup(pipe_cli, talloc_tos(),
    194                                       &group_handle);
     221        dcerpc_samr_DeleteDomainGroup(b, talloc_tos(),
     222                                      &group_handle, &result);
    195223
    196224 done:
    197225        if (is_valid_policy_hnd(&group_handle)) {
    198                 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);
     226                dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result);
    199227        }
    200228
     
    223251{
    224252        struct rpc_pipe_client *pipe_cli = NULL;
    225         NTSTATUS status;
     253        NTSTATUS status, result;
    226254        WERROR werr;
    227255        struct policy_handle connect_handle, domain_handle, group_handle;
     
    229257        struct dom_sid2 *domain_sid = NULL;
    230258        int i = 0;
     259        struct dcerpc_binding_handle *b = NULL;
    231260
    232261        struct samr_Ids rids;
    233262        struct samr_Ids types;
    234263        union samr_GroupInfo *info = NULL;
    235         struct samr_RidTypeArray *rid_array = NULL;
     264        struct samr_RidAttrArray *rid_array = NULL;
    236265
    237266        ZERO_STRUCT(connect_handle);
     
    249278                goto done;
    250279        }
     280
     281        b = pipe_cli->binding_handle;
    251282
    252283        werr = libnetapi_samr_open_domain(ctx, pipe_cli,
     
    263294        init_lsa_String(&lsa_group_name, r->in.group_name);
    264295
    265         status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),
     296        status = dcerpc_samr_LookupNames(b, talloc_tos(),
    266297                                         &domain_handle,
    267298                                         1,
    268299                                         &lsa_group_name,
    269300                                         &rids,
    270                                          &types);
    271         if (!NT_STATUS_IS_OK(status)) {
    272                 werr = ntstatus_to_werror(status);
     301                                         &types,
     302                                         &result);
     303        if (!NT_STATUS_IS_OK(status)) {
     304                werr = ntstatus_to_werror(status);
     305                goto done;
     306        }
     307        if (!NT_STATUS_IS_OK(result)) {
     308                werr = ntstatus_to_werror(result);
    273309                goto done;
    274310        }
     
    279315        }
    280316
    281         status = rpccli_samr_OpenGroup(pipe_cli, talloc_tos(),
     317        status = dcerpc_samr_OpenGroup(b, talloc_tos(),
    282318                                       &domain_handle,
    283319                                       SEC_STD_DELETE |
     
    287323                                       SAMR_GROUP_ACCESS_LOOKUP_INFO,
    288324                                       rids.ids[0],
    289                                        &group_handle);
    290         if (!NT_STATUS_IS_OK(status)) {
    291                 werr = ntstatus_to_werror(status);
    292                 goto done;
    293         }
    294 
    295         status = rpccli_samr_QueryGroupInfo(pipe_cli, talloc_tos(),
     325                                       &group_handle,
     326                                       &result);
     327        if (!NT_STATUS_IS_OK(status)) {
     328                werr = ntstatus_to_werror(status);
     329                goto done;
     330        }
     331        if (!NT_STATUS_IS_OK(result)) {
     332                werr = ntstatus_to_werror(result);
     333                goto done;
     334        }
     335
     336        status = dcerpc_samr_QueryGroupInfo(b, talloc_tos(),
    296337                                            &group_handle,
    297338                                            GROUPINFOATTRIBUTES,
    298                                             &info);
    299         if (!NT_STATUS_IS_OK(status)) {
    300                 werr = ntstatus_to_werror(status);
     339                                            &info,
     340                                            &result);
     341        if (!NT_STATUS_IS_OK(status)) {
     342                werr = ntstatus_to_werror(status);
     343                goto done;
     344        }
     345        if (!NT_STATUS_IS_OK(result)) {
     346                werr = ntstatus_to_werror(result);
    301347                goto done;
    302348        }
     
    309355        }
    310356#endif
    311         status = rpccli_samr_QueryGroupMember(pipe_cli, talloc_tos(),
     357        status = dcerpc_samr_QueryGroupMember(b, talloc_tos(),
    312358                                              &group_handle,
    313                                               &rid_array);
    314         if (!NT_STATUS_IS_OK(status)) {
    315                 werr = ntstatus_to_werror(status);
     359                                              &rid_array,
     360                                              &result);
     361        if (!NT_STATUS_IS_OK(status)) {
     362                werr = ntstatus_to_werror(status);
     363                goto done;
     364        }
     365        if (!NT_STATUS_IS_OK(result)) {
     366                werr = ntstatus_to_werror(result);
    316367                goto done;
    317368        }
     
    321372        struct samr_Ids member_types;
    322373
    323         status = rpccli_samr_LookupRids(pipe_cli, talloc_tos(),
     374        status = dcerpc_samr_LookupRids(b, talloc_tos(),
    324375                                        &domain_handle,
    325376                                        rid_array->count,
    326377                                        rid_array->rids,
    327378                                        &names,
    328                                         &member_types);
    329         if (!NT_STATUS_IS_OK(status)) {
    330                 werr = ntstatus_to_werror(status);
     379                                        &member_types,
     380                                        &result);
     381        if (!NT_STATUS_IS_OK(status)) {
     382                werr = ntstatus_to_werror(status);
     383                goto done;
     384        }
     385        if (!NT_STATUS_IS_OK(result)) {
     386                werr = ntstatus_to_werror(result);
    331387                goto done;
    332388        }
     
    335391        for (i=0; i < rid_array->count; i++) {
    336392
    337                 status = rpccli_samr_DeleteGroupMember(pipe_cli, talloc_tos(),
     393                status = dcerpc_samr_DeleteGroupMember(b, talloc_tos(),
    338394                                                       &group_handle,
    339                                                        rid_array->rids[i]);
     395                                                       rid_array->rids[i],
     396                                                       &result);
    340397                if (!NT_STATUS_IS_OK(status)) {
    341398                        werr = ntstatus_to_werror(status);
    342399                        goto done;
    343400                }
    344         }
    345 
    346         status = rpccli_samr_DeleteDomainGroup(pipe_cli, talloc_tos(),
    347                                                &group_handle);
    348         if (!NT_STATUS_IS_OK(status)) {
    349                 werr = ntstatus_to_werror(status);
     401                if (!NT_STATUS_IS_OK(result)) {
     402                        werr = ntstatus_to_werror(result);
     403                        goto done;
     404                }
     405        }
     406
     407        status = dcerpc_samr_DeleteDomainGroup(b, talloc_tos(),
     408                                               &group_handle,
     409                                               &result);
     410        if (!NT_STATUS_IS_OK(status)) {
     411                werr = ntstatus_to_werror(status);
     412                goto done;
     413        }
     414        if (!NT_STATUS_IS_OK(result)) {
     415                werr = ntstatus_to_werror(result);
    350416                goto done;
    351417        }
     
    357423 done:
    358424        if (is_valid_policy_hnd(&group_handle)) {
    359                 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);
     425                dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result);
    360426        }
    361427
     
    384450{
    385451        struct rpc_pipe_client *pipe_cli = NULL;
    386         NTSTATUS status;
     452        NTSTATUS status, result;
    387453        WERROR werr;
    388454        struct policy_handle connect_handle, domain_handle, group_handle;
    389455        struct lsa_String lsa_group_name;
    390456        struct dom_sid2 *domain_sid = NULL;
     457        struct dcerpc_binding_handle *b = NULL;
    391458
    392459        struct samr_Ids rids;
     
    415482        }
    416483
     484        b = pipe_cli->binding_handle;
     485
    417486        werr = libnetapi_samr_open_domain(ctx, pipe_cli,
    418487                                          SAMR_ACCESS_ENUM_DOMAINS |
     
    428497        init_lsa_String(&lsa_group_name, r->in.group_name);
    429498
    430         status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),
     499        status = dcerpc_samr_LookupNames(b, talloc_tos(),
    431500                                         &domain_handle,
    432501                                         1,
    433502                                         &lsa_group_name,
    434503                                         &rids,
    435                                          &types);
    436         if (!NT_STATUS_IS_OK(status)) {
    437                 werr = ntstatus_to_werror(status);
     504                                         &types,
     505                                         &result);
     506        if (!NT_STATUS_IS_OK(status)) {
     507                werr = ntstatus_to_werror(status);
     508                goto done;
     509        }
     510        if (!NT_STATUS_IS_OK(result)) {
     511                werr = ntstatus_to_werror(result);
    438512                goto done;
    439513        }
     
    444518        }
    445519
    446         status = rpccli_samr_OpenGroup(pipe_cli, talloc_tos(),
     520        status = dcerpc_samr_OpenGroup(b, talloc_tos(),
    447521                                       &domain_handle,
    448522                                       SAMR_GROUP_ACCESS_SET_INFO |
    449523                                       SAMR_GROUP_ACCESS_LOOKUP_INFO,
    450524                                       rids.ids[0],
    451                                        &group_handle);
    452         if (!NT_STATUS_IS_OK(status)) {
    453                 werr = ntstatus_to_werror(status);
     525                                       &group_handle,
     526                                       &result);
     527        if (!NT_STATUS_IS_OK(status)) {
     528                werr = ntstatus_to_werror(status);
     529                goto done;
     530        }
     531        if (!NT_STATUS_IS_OK(result)) {
     532                werr = ntstatus_to_werror(result);
    454533                goto done;
    455534        }
     
    459538                        g0 = (struct GROUP_INFO_0 *)r->in.buffer;
    460539                        init_lsa_String(&info.name, g0->grpi0_name);
    461                         status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),
     540                        status = dcerpc_samr_SetGroupInfo(b, talloc_tos(),
    462541                                                          &group_handle,
    463542                                                          GROUPINFONAME,
    464                                                           &info);
     543                                                          &info,
     544                                                          &result);
    465545                        break;
    466546                case 1:
    467547                        g1 = (struct GROUP_INFO_1 *)r->in.buffer;
    468548                        init_lsa_String(&info.description, g1->grpi1_comment);
    469                         status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),
     549                        status = dcerpc_samr_SetGroupInfo(b, talloc_tos(),
    470550                                                          &group_handle,
    471551                                                          GROUPINFODESCRIPTION,
    472                                                           &info);
     552                                                          &info,
     553                                                          &result);
    473554                        break;
    474555                case 2:
    475556                        g2 = (struct GROUP_INFO_2 *)r->in.buffer;
    476557                        init_lsa_String(&info.description, g2->grpi2_comment);
    477                         status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),
     558                        status = dcerpc_samr_SetGroupInfo(b, talloc_tos(),
    478559                                                          &group_handle,
    479560                                                          GROUPINFODESCRIPTION,
    480                                                           &info);
     561                                                          &info,
     562                                                          &result);
    481563                        if (!NT_STATUS_IS_OK(status)) {
    482564                                werr = ntstatus_to_werror(status);
    483565                                goto done;
    484566                        }
     567                        if (!NT_STATUS_IS_OK(result)) {
     568                                werr = ntstatus_to_werror(result);
     569                                goto done;
     570                        }
     571
    485572                        info.attributes.attributes = g2->grpi2_attributes;
    486                         status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),
     573                        status = dcerpc_samr_SetGroupInfo(b, talloc_tos(),
    487574                                                          &group_handle,
    488575                                                          GROUPINFOATTRIBUTES,
    489                                                           &info);
     576                                                          &info,
     577                                                          &result);
    490578                        break;
    491579                case 3:
    492580                        g3 = (struct GROUP_INFO_3 *)r->in.buffer;
    493581                        init_lsa_String(&info.description, g3->grpi3_comment);
    494                         status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),
     582                        status = dcerpc_samr_SetGroupInfo(b, talloc_tos(),
    495583                                                          &group_handle,
    496584                                                          GROUPINFODESCRIPTION,
    497                                                           &info);
     585                                                          &info,
     586                                                          &result);
    498587                        if (!NT_STATUS_IS_OK(status)) {
    499588                                werr = ntstatus_to_werror(status);
    500589                                goto done;
    501590                        }
     591                        if (!NT_STATUS_IS_OK(result)) {
     592                                werr = ntstatus_to_werror(result);
     593                                goto done;
     594                        }
     595
    502596                        info.attributes.attributes = g3->grpi3_attributes;
    503                         status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),
     597                        status = dcerpc_samr_SetGroupInfo(b, talloc_tos(),
    504598                                                          &group_handle,
    505599                                                          GROUPINFOATTRIBUTES,
    506                                                           &info);
     600                                                          &info,
     601                                                          &result);
    507602                        break;
    508603                case 1002:
    509604                        g1002 = (struct GROUP_INFO_1002 *)r->in.buffer;
    510605                        init_lsa_String(&info.description, g1002->grpi1002_comment);
    511                         status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),
     606                        status = dcerpc_samr_SetGroupInfo(b, talloc_tos(),
    512607                                                          &group_handle,
    513608                                                          GROUPINFODESCRIPTION,
    514                                                           &info);
     609                                                          &info,
     610                                                          &result);
    515611                        break;
    516612                case 1005:
    517613                        g1005 = (struct GROUP_INFO_1005 *)r->in.buffer;
    518614                        info.attributes.attributes = g1005->grpi1005_attributes;
    519                         status = rpccli_samr_SetGroupInfo(pipe_cli, talloc_tos(),
     615                        status = dcerpc_samr_SetGroupInfo(b, talloc_tos(),
    520616                                                          &group_handle,
    521617                                                          GROUPINFOATTRIBUTES,
    522                                                           &info);
     618                                                          &info,
     619                                                          &result);
    523620                        break;
    524621                default:
     
    531628                goto done;
    532629        }
     630        if (!NT_STATUS_IS_OK(result)) {
     631                werr = ntstatus_to_werror(result);
     632                goto done;
     633        }
    533634
    534635        werr = WERR_OK;
     
    536637 done:
    537638        if (is_valid_policy_hnd(&group_handle)) {
    538                 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);
     639                dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result);
    539640        }
    540641
     
    603704                        info3.grpi3_comment     = info->description.string;
    604705                        info3.grpi3_attributes  = info->attributes;
    605                         info3.grpi3_group_sid   = (struct domsid *)sid_dup_talloc(mem_ctx, &sid);
     706                        info3.grpi3_group_sid   = (struct domsid *)dom_sid_dup(mem_ctx, &sid);
    606707
    607708                        *buffer = (uint8_t *)talloc_memdup(mem_ctx, &info3, sizeof(info3));
     
    624725{
    625726        struct rpc_pipe_client *pipe_cli = NULL;
    626         NTSTATUS status;
     727        NTSTATUS status, result;
    627728        WERROR werr;
    628729        struct policy_handle connect_handle, domain_handle, group_handle;
    629730        struct lsa_String lsa_group_name;
    630731        struct dom_sid2 *domain_sid = NULL;
     732        struct dcerpc_binding_handle *b = NULL;
    631733
    632734        struct samr_Ids rids;
     
    649751                goto done;
    650752        }
     753
     754        b = pipe_cli->binding_handle;
    651755
    652756        werr = libnetapi_samr_open_domain(ctx, pipe_cli,
     
    663767        init_lsa_String(&lsa_group_name, r->in.group_name);
    664768
    665         status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),
     769        status = dcerpc_samr_LookupNames(b, talloc_tos(),
    666770                                         &domain_handle,
    667771                                         1,
    668772                                         &lsa_group_name,
    669773                                         &rids,
    670                                          &types);
    671         if (!NT_STATUS_IS_OK(status)) {
    672                 werr = ntstatus_to_werror(status);
     774                                         &types,
     775                                         &result);
     776        if (!NT_STATUS_IS_OK(status)) {
     777                werr = ntstatus_to_werror(status);
     778                goto done;
     779        }
     780        if (!NT_STATUS_IS_OK(result)) {
     781                werr = ntstatus_to_werror(result);
    673782                goto done;
    674783        }
     
    679788        }
    680789
    681         status = rpccli_samr_OpenGroup(pipe_cli, talloc_tos(),
     790        status = dcerpc_samr_OpenGroup(b, talloc_tos(),
    682791                                       &domain_handle,
    683792                                       SAMR_GROUP_ACCESS_LOOKUP_INFO,
    684793                                       rids.ids[0],
    685                                        &group_handle);
    686         if (!NT_STATUS_IS_OK(status)) {
    687                 werr = ntstatus_to_werror(status);
    688                 goto done;
    689         }
    690 
    691         status = rpccli_samr_QueryGroupInfo(pipe_cli, talloc_tos(),
     794                                       &group_handle,
     795                                       &result);
     796        if (!NT_STATUS_IS_OK(status)) {
     797                werr = ntstatus_to_werror(status);
     798                goto done;
     799        }
     800        if (!NT_STATUS_IS_OK(result)) {
     801                werr = ntstatus_to_werror(result);
     802                goto done;
     803        }
     804
     805        status = dcerpc_samr_QueryGroupInfo(b, talloc_tos(),
    692806                                            &group_handle,
    693807                                            GROUPINFOALL2,
    694                                             &info);
    695         if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS)) {
    696                 status = rpccli_samr_QueryGroupInfo(pipe_cli, talloc_tos(),
     808                                            &info,
     809                                            &result);
     810        if (!NT_STATUS_IS_OK(status)) {
     811                werr = ntstatus_to_werror(status);
     812                goto done;
     813        }
     814
     815        if (NT_STATUS_EQUAL(result, NT_STATUS_INVALID_INFO_CLASS)) {
     816                status = dcerpc_samr_QueryGroupInfo(b, talloc_tos(),
    697817                                                    &group_handle,
    698818                                                    GROUPINFOALL,
    699                                                     &info);
     819                                                    &info,
     820                                                    &result);
    700821                group_info_all = true;
    701         }
    702 
    703         if (!NT_STATUS_IS_OK(status)) {
    704                 werr = ntstatus_to_werror(status);
     822                if (!NT_STATUS_IS_OK(status)) {
     823                        werr = ntstatus_to_werror(status);
     824                        goto done;
     825                }
     826        }
     827
     828        if (!NT_STATUS_IS_OK(result)) {
     829                werr = ntstatus_to_werror(result);
    705830                goto done;
    706831        }
     
    715840 done:
    716841        if (is_valid_policy_hnd(&group_handle)) {
    717                 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);
     842                dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result);
    718843        }
    719844
     
    742867{
    743868        struct rpc_pipe_client *pipe_cli = NULL;
    744         NTSTATUS status;
     869        NTSTATUS status, result;
    745870        WERROR werr;
    746871        struct policy_handle connect_handle, domain_handle, group_handle;
    747872        struct lsa_String lsa_group_name, lsa_user_name;
    748873        struct dom_sid2 *domain_sid = NULL;
     874        struct dcerpc_binding_handle *b = NULL;
    749875
    750876        struct samr_Ids rids;
     
    765891                goto done;
    766892        }
     893
     894        b = pipe_cli->binding_handle;
    767895
    768896        werr = libnetapi_samr_open_domain(ctx, pipe_cli,
     
    779907        init_lsa_String(&lsa_group_name, r->in.group_name);
    780908
    781         status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),
     909        status = dcerpc_samr_LookupNames(b, talloc_tos(),
    782910                                         &domain_handle,
    783911                                         1,
    784912                                         &lsa_group_name,
    785913                                         &rids,
    786                                          &types);
    787         if (!NT_STATUS_IS_OK(status)) {
     914                                         &types,
     915                                         &result);
     916        if (!NT_STATUS_IS_OK(status)) {
     917                werr = ntstatus_to_werror(status);
     918                goto done;
     919        }
     920        if (!NT_STATUS_IS_OK(result)) {
    788921                werr = WERR_GROUPNOTFOUND;
    789922                goto done;
     
    795928        }
    796929
    797         status = rpccli_samr_OpenGroup(pipe_cli, talloc_tos(),
     930        status = dcerpc_samr_OpenGroup(b, talloc_tos(),
    798931                                       &domain_handle,
    799932                                       SAMR_GROUP_ACCESS_ADD_MEMBER,
    800933                                       rids.ids[0],
    801                                        &group_handle);
    802         if (!NT_STATUS_IS_OK(status)) {
    803                 werr = ntstatus_to_werror(status);
     934                                       &group_handle,
     935                                       &result);
     936        if (!NT_STATUS_IS_OK(status)) {
     937                werr = ntstatus_to_werror(status);
     938                goto done;
     939        }
     940        if (!NT_STATUS_IS_OK(result)) {
     941                werr = ntstatus_to_werror(result);
    804942                goto done;
    805943        }
     
    807945        init_lsa_String(&lsa_user_name, r->in.user_name);
    808946
    809         status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),
     947        status = dcerpc_samr_LookupNames(b, talloc_tos(),
    810948                                         &domain_handle,
    811949                                         1,
    812950                                         &lsa_user_name,
    813951                                         &rids,
    814                                          &types);
    815         if (!NT_STATUS_IS_OK(status)) {
     952                                         &types,
     953                                         &result);
     954        if (!NT_STATUS_IS_OK(status)) {
     955                werr = ntstatus_to_werror(status);
     956                goto done;
     957        }
     958        if (!NT_STATUS_IS_OK(result)) {
    816959                werr = WERR_USER_NOT_FOUND;
    817960                goto done;
     
    823966        }
    824967
    825         status = rpccli_samr_AddGroupMember(pipe_cli, talloc_tos(),
     968        status = dcerpc_samr_AddGroupMember(b, talloc_tos(),
    826969                                            &group_handle,
    827970                                            rids.ids[0],
    828                                             7); /* why ? */
    829         if (!NT_STATUS_IS_OK(status)) {
    830                 werr = ntstatus_to_werror(status);
     971                                            7, /* why ? */
     972                                            &result);
     973        if (!NT_STATUS_IS_OK(status)) {
     974                werr = ntstatus_to_werror(status);
     975                goto done;
     976        }
     977        if (!NT_STATUS_IS_OK(result)) {
     978                werr = ntstatus_to_werror(result);
    831979                goto done;
    832980        }
     
    836984 done:
    837985        if (is_valid_policy_hnd(&group_handle)) {
    838                 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);
     986                dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result);
    839987        }
    840988
     
    8631011{
    8641012        struct rpc_pipe_client *pipe_cli = NULL;
    865         NTSTATUS status;
     1013        NTSTATUS status, result;
    8661014        WERROR werr;
    8671015        struct policy_handle connect_handle, domain_handle, group_handle;
    8681016        struct lsa_String lsa_group_name, lsa_user_name;
    8691017        struct dom_sid2 *domain_sid = NULL;
     1018        struct dcerpc_binding_handle *b = NULL;
    8701019
    8711020        struct samr_Ids rids;
     
    8861035                goto done;
    8871036        }
     1037
     1038        b = pipe_cli->binding_handle;
    8881039
    8891040        werr = libnetapi_samr_open_domain(ctx, pipe_cli,
     
    9001051        init_lsa_String(&lsa_group_name, r->in.group_name);
    9011052
    902         status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),
     1053        status = dcerpc_samr_LookupNames(b, talloc_tos(),
    9031054                                         &domain_handle,
    9041055                                         1,
    9051056                                         &lsa_group_name,
    9061057                                         &rids,
    907                                          &types);
    908         if (!NT_STATUS_IS_OK(status)) {
     1058                                         &types,
     1059                                         &result);
     1060        if (!NT_STATUS_IS_OK(status)) {
     1061                werr = ntstatus_to_werror(status);
     1062                goto done;
     1063        }
     1064        if (!NT_STATUS_IS_OK(result)) {
    9091065                werr = WERR_GROUPNOTFOUND;
    9101066                goto done;
     
    9161072        }
    9171073
    918         status = rpccli_samr_OpenGroup(pipe_cli, talloc_tos(),
     1074        status = dcerpc_samr_OpenGroup(b, talloc_tos(),
    9191075                                       &domain_handle,
    9201076                                       SAMR_GROUP_ACCESS_REMOVE_MEMBER,
    9211077                                       rids.ids[0],
    922                                        &group_handle);
    923         if (!NT_STATUS_IS_OK(status)) {
    924                 werr = ntstatus_to_werror(status);
     1078                                       &group_handle,
     1079                                       &result);
     1080        if (!NT_STATUS_IS_OK(status)) {
     1081                werr = ntstatus_to_werror(status);
     1082                goto done;
     1083        }
     1084        if (!NT_STATUS_IS_OK(result)) {
     1085                werr = ntstatus_to_werror(result);
    9251086                goto done;
    9261087        }
     
    9281089        init_lsa_String(&lsa_user_name, r->in.user_name);
    9291090
    930         status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),
     1091        status = dcerpc_samr_LookupNames(b, talloc_tos(),
    9311092                                         &domain_handle,
    9321093                                         1,
    9331094                                         &lsa_user_name,
    9341095                                         &rids,
    935                                          &types);
    936         if (!NT_STATUS_IS_OK(status)) {
     1096                                         &types,
     1097                                         &result);
     1098        if (!NT_STATUS_IS_OK(status)) {
     1099                werr = ntstatus_to_werror(status);
     1100                goto done;
     1101        }
     1102
     1103        if (!NT_STATUS_IS_OK(result)) {
    9371104                werr = WERR_USER_NOT_FOUND;
    9381105                goto done;
     
    9441111        }
    9451112
    946         status = rpccli_samr_DeleteGroupMember(pipe_cli, talloc_tos(),
     1113        status = dcerpc_samr_DeleteGroupMember(b, talloc_tos(),
    9471114                                               &group_handle,
    948                                                rids.ids[0]);
    949         if (!NT_STATUS_IS_OK(status)) {
    950                 werr = ntstatus_to_werror(status);
     1115                                               rids.ids[0],
     1116                                               &result);
     1117        if (!NT_STATUS_IS_OK(status)) {
     1118                werr = ntstatus_to_werror(status);
     1119                goto done;
     1120        }
     1121        if (!NT_STATUS_IS_OK(result)) {
     1122                werr = ntstatus_to_werror(result);
    9511123                goto done;
    9521124        }
     
    9561128 done:
    9571129        if (is_valid_policy_hnd(&group_handle)) {
    958                 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);
     1130                dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result);
    9591131        }
    9601132
     
    10861258                g3[i].grpi3_comment = talloc_strdup(mem_ctx,
    10871259                        groups->entries[i].description.string);
    1088                 g3[i].grpi3_group_sid = (struct domsid *)sid_dup_talloc(mem_ctx, &sid);
     1260                g3[i].grpi3_group_sid = (struct domsid *)dom_sid_dup(mem_ctx, &sid);
    10891261                g3[i].grpi3_attributes = groups->entries[i].acct_flags;
    10901262                W_ERROR_HAVE_NO_MEMORY(g3[i].grpi3_name);
     
    11381310        union samr_DispInfo info;
    11391311        union samr_DomainInfo *domain_info = NULL;
     1312        struct dcerpc_binding_handle *b = NULL;
    11401313
    11411314        uint32_t total_size = 0;
    11421315        uint32_t returned_size = 0;
    11431316
     1317        NTSTATUS result = NT_STATUS_OK;
    11441318        NTSTATUS status = NT_STATUS_OK;
    11451319        WERROR werr, tmp_werr;
     
    11641338                goto done;
    11651339        }
     1340
     1341        b = pipe_cli->binding_handle;
    11661342
    11671343        werr = libnetapi_samr_open_domain(ctx, pipe_cli,
     
    11781354        }
    11791355
    1180         status = rpccli_samr_QueryDomainInfo(pipe_cli, talloc_tos(),
     1356        status = dcerpc_samr_QueryDomainInfo(b, talloc_tos(),
    11811357                                             &domain_handle,
    11821358                                             2,
    1183                                              &domain_info);
    1184         if (!NT_STATUS_IS_OK(status)) {
    1185                 werr = ntstatus_to_werror(status);
     1359                                             &domain_info,
     1360                                             &result);
     1361        if (!NT_STATUS_IS_OK(status)) {
     1362                werr = ntstatus_to_werror(status);
     1363                goto done;
     1364        }
     1365        if (!NT_STATUS_IS_OK(result)) {
     1366                werr = ntstatus_to_werror(result);
    11861367                goto done;
    11871368        }
     
    11911372        }
    11921373
    1193         status = rpccli_samr_QueryDisplayInfo2(pipe_cli,
     1374        status = dcerpc_samr_QueryDisplayInfo2(b,
    11941375                                               ctx,
    11951376                                               &domain_handle,
     
    12011382                                               &total_size,
    12021383                                               &returned_size,
    1203                                                &info);
    1204         werr = ntstatus_to_werror(status);
    1205         if (NT_STATUS_IS_ERR(status)) {
     1384                                               &info,
     1385                                               &result);
     1386        if (!NT_STATUS_IS_OK(status)) {
     1387                werr = ntstatus_to_werror(status);
     1388                goto done;
     1389        }
     1390
     1391        werr = ntstatus_to_werror(result);
     1392        if (NT_STATUS_IS_ERR(result)) {
    12061393                goto done;
    12071394        }
     
    12251412 done:
    12261413        /* if last query */
    1227         if (NT_STATUS_IS_OK(status) ||
    1228             NT_STATUS_IS_ERR(status)) {
     1414        if (NT_STATUS_IS_OK(result) ||
     1415            NT_STATUS_IS_ERR(result)) {
    12291416
    12301417                if (ctx->disable_policy_handle_cache) {
     
    12591446        struct dom_sid2 *domain_sid = NULL;
    12601447        struct samr_Ids group_rids, name_types;
    1261         struct samr_RidTypeArray *rid_array = NULL;
     1448        struct samr_RidAttrArray *rid_array = NULL;
    12621449        struct lsa_Strings names;
    12631450        struct samr_Ids member_types;
     1451        struct dcerpc_binding_handle *b = NULL;
    12641452
    12651453        int i;
     
    12671455
    12681456        NTSTATUS status = NT_STATUS_OK;
     1457        NTSTATUS result = NT_STATUS_OK;
    12691458        WERROR werr;
    12701459
     
    12951484                goto done;
    12961485        }
     1486
     1487        b = pipe_cli->binding_handle;
    12971488
    12981489        werr = libnetapi_samr_open_domain(ctx, pipe_cli,
     
    13091500        init_lsa_String(&lsa_account_name, r->in.group_name);
    13101501
    1311         status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),
     1502        status = dcerpc_samr_LookupNames(b, talloc_tos(),
    13121503                                         &domain_handle,
    13131504                                         1,
    13141505                                         &lsa_account_name,
    13151506                                         &group_rids,
    1316                                          &name_types);
    1317         if (!NT_STATUS_IS_OK(status)) {
    1318                 werr = ntstatus_to_werror(status);
    1319                 goto done;
    1320         }
    1321 
    1322         status = rpccli_samr_OpenGroup(pipe_cli, talloc_tos(),
     1507                                         &name_types,
     1508                                         &result);
     1509        if (!NT_STATUS_IS_OK(status)) {
     1510                werr = ntstatus_to_werror(status);
     1511                goto done;
     1512        }
     1513        if (!NT_STATUS_IS_OK(result)) {
     1514                werr = ntstatus_to_werror(result);
     1515                goto done;
     1516        }
     1517
     1518        status = dcerpc_samr_OpenGroup(b, talloc_tos(),
    13231519                                       &domain_handle,
    13241520                                       SAMR_GROUP_ACCESS_GET_MEMBERS,
    13251521                                       group_rids.ids[0],
    1326                                        &group_handle);
    1327         if (!NT_STATUS_IS_OK(status)) {
    1328                 werr = ntstatus_to_werror(status);
    1329                 goto done;
    1330         }
    1331 
    1332         status = rpccli_samr_QueryGroupMember(pipe_cli, talloc_tos(),
     1522                                       &group_handle,
     1523                                       &result);
     1524        if (!NT_STATUS_IS_OK(status)) {
     1525                werr = ntstatus_to_werror(status);
     1526                goto done;
     1527        }
     1528        if (!NT_STATUS_IS_OK(result)) {
     1529                werr = ntstatus_to_werror(result);
     1530                goto done;
     1531        }
     1532
     1533        status = dcerpc_samr_QueryGroupMember(b, talloc_tos(),
    13331534                                              &group_handle,
    1334                                               &rid_array);
    1335         if (!NT_STATUS_IS_OK(status)) {
    1336                 werr = ntstatus_to_werror(status);
    1337                 goto done;
    1338         }
    1339 
    1340         status = rpccli_samr_LookupRids(pipe_cli, talloc_tos(),
     1535                                              &rid_array,
     1536                                              &result);
     1537        if (!NT_STATUS_IS_OK(status)) {
     1538                werr = ntstatus_to_werror(status);
     1539                goto done;
     1540        }
     1541        if (!NT_STATUS_IS_OK(result)) {
     1542                werr = ntstatus_to_werror(result);
     1543                goto done;
     1544        }
     1545
     1546        status = dcerpc_samr_LookupRids(b, talloc_tos(),
    13411547                                        &domain_handle,
    13421548                                        rid_array->count,
    13431549                                        rid_array->rids,
    13441550                                        &names,
    1345                                         &member_types);
    1346         if (!NT_STATUS_IS_OK(status)) {
    1347                 werr = ntstatus_to_werror(status);
     1551                                        &member_types,
     1552                                        &result);
     1553        if (!NT_STATUS_IS_OK(status)) {
     1554                werr = ntstatus_to_werror(status);
     1555                goto done;
     1556        }
     1557        if (!NT_STATUS_IS_OK(result)) {
     1558                werr = ntstatus_to_werror(result);
    13481559                goto done;
    13491560        }
     
    13741585 done:
    13751586        if (is_valid_policy_hnd(&group_handle)) {
    1376                 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);
     1587                dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result);
    13771588        }
    13781589
     
    14071618        struct samr_Ids user_rids, name_types;
    14081619        struct samr_Ids group_rids, group_types;
    1409         struct samr_RidTypeArray *rid_array = NULL;
     1620        struct samr_RidAttrArray *rid_array = NULL;
    14101621        struct lsa_String *lsa_names = NULL;
     1622        struct dcerpc_binding_handle *b = NULL;
    14111623
    14121624        uint32_t *add_rids = NULL;
     
    14161628
    14171629        uint32_t *member_rids = NULL;
    1418         size_t num_member_rids = 0;
    14191630
    14201631        struct GROUP_USERS_INFO_0 *i0 = NULL;
     
    14241635
    14251636        NTSTATUS status = NT_STATUS_OK;
     1637        NTSTATUS result = NT_STATUS_OK;
    14261638        WERROR werr;
    14271639
     
    14471659                goto done;
    14481660        }
     1661
     1662        b = pipe_cli->binding_handle;
    14491663
    14501664        werr = libnetapi_samr_open_domain(ctx, pipe_cli,
     
    14611675        init_lsa_String(&lsa_account_name, r->in.group_name);
    14621676
    1463         status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),
     1677        status = dcerpc_samr_LookupNames(b, talloc_tos(),
    14641678                                         &domain_handle,
    14651679                                         1,
    14661680                                         &lsa_account_name,
    14671681                                         &group_rids,
    1468                                          &group_types);
    1469         if (!NT_STATUS_IS_OK(status)) {
    1470                 werr = ntstatus_to_werror(status);
    1471                 goto done;
    1472         }
    1473 
    1474         status = rpccli_samr_OpenGroup(pipe_cli, talloc_tos(),
     1682                                         &group_types,
     1683                                         &result);
     1684        if (!NT_STATUS_IS_OK(status)) {
     1685                werr = ntstatus_to_werror(status);
     1686                goto done;
     1687        }
     1688        if (!NT_STATUS_IS_OK(result)) {
     1689                werr = ntstatus_to_werror(result);
     1690                goto done;
     1691        }
     1692
     1693        status = dcerpc_samr_OpenGroup(b, talloc_tos(),
    14751694                                       &domain_handle,
    14761695                                       SAMR_GROUP_ACCESS_GET_MEMBERS |
     
    14791698                                       SAMR_GROUP_ACCESS_LOOKUP_INFO,
    14801699                                       group_rids.ids[0],
    1481                                        &group_handle);
    1482         if (!NT_STATUS_IS_OK(status)) {
    1483                 werr = ntstatus_to_werror(status);
    1484                 goto done;
    1485         }
    1486 
    1487         status = rpccli_samr_QueryGroupInfo(pipe_cli, talloc_tos(),
     1700                                       &group_handle,
     1701                                       &result);
     1702        if (!NT_STATUS_IS_OK(status)) {
     1703                werr = ntstatus_to_werror(status);
     1704                goto done;
     1705        }
     1706        if (!NT_STATUS_IS_OK(result)) {
     1707                werr = ntstatus_to_werror(result);
     1708                goto done;
     1709        }
     1710
     1711        status = dcerpc_samr_QueryGroupInfo(b, talloc_tos(),
    14881712                                            &group_handle,
    14891713                                            GROUPINFOATTRIBUTES,
    1490                                             &group_info);
    1491         if (!NT_STATUS_IS_OK(status)) {
    1492                 werr = ntstatus_to_werror(status);
     1714                                            &group_info,
     1715                                            &result);
     1716        if (!NT_STATUS_IS_OK(status)) {
     1717                werr = ntstatus_to_werror(status);
     1718                goto done;
     1719        }
     1720        if (!NT_STATUS_IS_OK(result)) {
     1721                werr = ntstatus_to_werror(result);
    14931722                goto done;
    14941723        }
     
    15231752        }
    15241753
    1525         status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),
     1754        status = dcerpc_samr_LookupNames(b, talloc_tos(),
    15261755                                         &domain_handle,
    15271756                                         r->in.num_entries,
    15281757                                         lsa_names,
    15291758                                         &user_rids,
    1530                                          &name_types);
    1531         if (!NT_STATUS_IS_OK(status)) {
    1532                 werr = ntstatus_to_werror(status);
     1759                                         &name_types,
     1760                                         &result);
     1761        if (!NT_STATUS_IS_OK(status)) {
     1762                werr = ntstatus_to_werror(status);
     1763                goto done;
     1764        }
     1765        if (!NT_STATUS_IS_OK(result)) {
     1766                werr = ntstatus_to_werror(result);
    15331767                goto done;
    15341768        }
    15351769
    15361770        member_rids = user_rids.ids;
    1537         num_member_rids = user_rids.count;
    1538 
    1539         status = rpccli_samr_QueryGroupMember(pipe_cli, talloc_tos(),
     1771
     1772        status = dcerpc_samr_QueryGroupMember(b, talloc_tos(),
    15401773                                              &group_handle,
    1541                                               &rid_array);
    1542         if (!NT_STATUS_IS_OK(status)) {
    1543                 werr = ntstatus_to_werror(status);
     1774                                              &rid_array,
     1775                                              &result);
     1776        if (!NT_STATUS_IS_OK(status)) {
     1777                werr = ntstatus_to_werror(status);
     1778                goto done;
     1779        }
     1780        if (!NT_STATUS_IS_OK(result)) {
     1781                werr = ntstatus_to_werror(result);
    15441782                goto done;
    15451783        }
     
    15881826
    15891827        for (i=0; i < num_add_rids; i++) {
    1590                 status = rpccli_samr_AddGroupMember(pipe_cli, talloc_tos(),
     1828                status = dcerpc_samr_AddGroupMember(b, talloc_tos(),
    15911829                                                    &group_handle,
    15921830                                                    add_rids[i],
    1593                                                     7 /* ? */);
     1831                                                    7 /* ? */,
     1832                                                    &result);
    15941833                if (!NT_STATUS_IS_OK(status)) {
    15951834                        werr = ntstatus_to_werror(status);
    15961835                        goto done;
    15971836                }
     1837                if (!NT_STATUS_IS_OK(result)) {
     1838                        werr = ntstatus_to_werror(result);
     1839                        goto done;
     1840                }
    15981841        }
    15991842
     
    16011844
    16021845        for (i=0; i < num_del_rids; i++) {
    1603                 status = rpccli_samr_DeleteGroupMember(pipe_cli, talloc_tos(),
     1846                status = dcerpc_samr_DeleteGroupMember(b, talloc_tos(),
    16041847                                                       &group_handle,
    1605                                                        del_rids[i]);
     1848                                                       del_rids[i],
     1849                                                       &result);
    16061850                if (!NT_STATUS_IS_OK(status)) {
    16071851                        werr = ntstatus_to_werror(status);
    16081852                        goto done;
    16091853                }
     1854                if (!NT_STATUS_IS_OK(result)) {
     1855                        werr = ntstatus_to_werror(result);
     1856                        goto done;
     1857                }
    16101858        }
    16111859
     
    16141862 done:
    16151863        if (is_valid_policy_hnd(&group_handle)) {
    1616                 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);
     1864                dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result);
    16171865        }
    16181866
  • vendor/current/source3/lib/netapi/joindomain.c

    r594 r740  
    1919
    2020#include "includes.h"
    21 
     21#include "ads.h"
    2222#include "librpc/gen_ndr/libnetapi.h"
     23#include "libcli/auth/libcli_auth.h"
    2324#include "lib/netapi/netapi.h"
    2425#include "lib/netapi/netapi_private.h"
    2526#include "lib/netapi/libnetapi.h"
    26 #include "libnet/libnet.h"
    27 #include "libcli/auth/libcli_auth.h"
    28 #include "../librpc/gen_ndr/cli_wkssvc.h"
     27#include "librpc/gen_ndr/libnet_join.h"
     28#include "libnet/libnet_join.h"
     29#include "../librpc/gen_ndr/ndr_wkssvc_c.h"
     30#include "rpc_client/cli_pipe.h"
     31#include "secrets.h"
    2932
    3033/****************************************************************
     
    3538{
    3639        struct libnet_JoinCtx *j = NULL;
    37         WERROR werr;
     40        struct libnetapi_private_ctx *priv;
     41        WERROR werr;
     42
     43        priv = talloc_get_type_abort(mem_ctx->private_data,
     44                struct libnetapi_private_ctx);
    3845
    3946        if (!r->in.domain) {
     
    5461                                 DS_WRITABLE_REQUIRED |
    5562                                 DS_RETURN_DNS_NAME;
    56                 status = dsgetdcname(mem_ctx, NULL, r->in.domain,
     63                status = dsgetdcname(mem_ctx, priv->msg_ctx, r->in.domain,
    5764                                     NULL, NULL, flags, &info);
    5865                if (!NT_STATUS_IS_OK(status)) {
     
    106113        WERROR werr;
    107114        unsigned int old_timeout = 0;
     115        struct dcerpc_binding_handle *b;
     116        DATA_BLOB session_key;
    108117
    109118        werr = libnetapi_open_pipe(ctx, r->in.server,
     
    114123        }
    115124
    116         if (r->in.password) {
     125        b = pipe_cli->binding_handle;
     126
     127        if (r->in.password) {
     128
     129                status = cli_get_session_key(talloc_tos(), pipe_cli, &session_key);
     130                if (!NT_STATUS_IS_OK(status)) {
     131                        werr = ntstatus_to_werror(status);
     132                        goto done;
     133                }
     134
    117135                encode_wkssvc_join_password_buffer(ctx,
    118136                                                   r->in.password,
    119                                                    &pipe_cli->auth->user_session_key,
     137                                                   &session_key,
    120138                                                   &encrypted_password);
    121139        }
     
    123141        old_timeout = rpccli_set_timeout(pipe_cli, 600000);
    124142
    125         status = rpccli_wkssvc_NetrJoinDomain2(pipe_cli, talloc_tos(),
     143        status = dcerpc_wkssvc_NetrJoinDomain2(b, talloc_tos(),
    126144                                               r->in.server,
    127145                                               r->in.domain,
     
    153171        const char *domain = NULL;
    154172        WERROR werr;
     173        struct libnetapi_private_ctx *priv;
     174
     175        priv = talloc_get_type_abort(mem_ctx->private_data,
     176                struct libnetapi_private_ctx);
    155177
    156178        if (!secrets_fetch_domain_sid(lp_workgroup(), &domain_sid)) {
     
    177199                                 DS_WRITABLE_REQUIRED |
    178200                                 DS_RETURN_DNS_NAME;
    179                 status = dsgetdcname(mem_ctx, NULL, domain,
     201                status = dsgetdcname(mem_ctx, priv->msg_ctx, domain,
    180202                                     NULL, NULL, flags, &info);
    181203                if (!NT_STATUS_IS_OK(status)) {
     
    232254        WERROR werr;
    233255        unsigned int old_timeout = 0;
     256        struct dcerpc_binding_handle *b;
     257        DATA_BLOB session_key;
    234258
    235259        werr = libnetapi_open_pipe(ctx, r->in.server_name,
     
    240264        }
    241265
    242         if (r->in.password) {
     266        b = pipe_cli->binding_handle;
     267
     268        if (r->in.password) {
     269
     270                status = cli_get_session_key(talloc_tos(), pipe_cli, &session_key);
     271                if (!NT_STATUS_IS_OK(status)) {
     272                        werr = ntstatus_to_werror(status);
     273                        goto done;
     274                }
     275
    243276                encode_wkssvc_join_password_buffer(ctx,
    244277                                                   r->in.password,
    245                                                    &pipe_cli->auth->user_session_key,
     278                                                   &session_key,
    246279                                                   &encrypted_password);
    247280        }
     
    249282        old_timeout = rpccli_set_timeout(pipe_cli, 60000);
    250283
    251         status = rpccli_wkssvc_NetrUnjoinDomain2(pipe_cli, talloc_tos(),
     284        status = dcerpc_wkssvc_NetrUnjoinDomain2(b, talloc_tos(),
    252285                                                 r->in.server_name,
    253286                                                 r->in.account,
     
    278311        WERROR werr;
    279312        const char *buffer = NULL;
     313        struct dcerpc_binding_handle *b;
    280314
    281315        werr = libnetapi_open_pipe(ctx, r->in.server_name,
     
    286320        }
    287321
    288         status = rpccli_wkssvc_NetrGetJoinInformation(pipe_cli, talloc_tos(),
     322        b = pipe_cli->binding_handle;
     323
     324        status = dcerpc_wkssvc_NetrGetJoinInformation(b, talloc_tos(),
    289325                                                      r->in.server_name,
    290326                                                      &buffer,
     
    293329        if (!NT_STATUS_IS_OK(status)) {
    294330                werr = ntstatus_to_werror(status);
     331                goto done;
     332        }
     333
     334        if (!W_ERROR_IS_OK(werr)) {
    295335                goto done;
    296336        }
     
    339379                           struct NetGetJoinableOUs *r)
    340380{
    341 #ifdef WITH_ADS
     381#ifdef HAVE_ADS
    342382        NTSTATUS status;
    343383        ADS_STATUS ads_status;
     
    347387        uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED |
    348388                         DS_RETURN_DNS_NAME;
    349 
    350         status = dsgetdcname(ctx, NULL, r->in.domain,
     389        struct libnetapi_private_ctx *priv;
     390
     391        priv = talloc_get_type_abort(ctx->private_data,
     392                struct libnetapi_private_ctx);
     393
     394        status = dsgetdcname(ctx, priv->msg_ctx, r->in.domain,
    351395                             NULL, NULL, flags, &info);
    352396        if (!NT_STATUS_IS_OK(status)) {
     
    408452        NTSTATUS status;
    409453        WERROR werr;
     454        struct dcerpc_binding_handle *b;
     455        DATA_BLOB session_key;
    410456
    411457        werr = libnetapi_open_pipe(ctx, r->in.server_name,
     
    416462        }
    417463
    418         if (r->in.password) {
     464        b = pipe_cli->binding_handle;
     465
     466        if (r->in.password) {
     467
     468                status = cli_get_session_key(talloc_tos(), pipe_cli, &session_key);
     469                if (!NT_STATUS_IS_OK(status)) {
     470                        werr = ntstatus_to_werror(status);
     471                        goto done;
     472                }
     473
    419474                encode_wkssvc_join_password_buffer(ctx,
    420475                                                   r->in.password,
    421                                                    &pipe_cli->auth->user_session_key,
     476                                                   &session_key,
    422477                                                   &encrypted_password);
    423478        }
    424479
    425         status = rpccli_wkssvc_NetrGetJoinableOus2(pipe_cli, talloc_tos(),
     480        status = dcerpc_wkssvc_NetrGetJoinableOus2(b, talloc_tos(),
    426481                                                   r->in.server_name,
    427482                                                   r->in.domain,
     
    450505        NTSTATUS status;
    451506        WERROR werr;
     507        struct dcerpc_binding_handle *b;
     508        DATA_BLOB session_key;
    452509
    453510        werr = libnetapi_open_pipe(ctx, r->in.server_name,
     
    458515        }
    459516
    460         if (r->in.password) {
     517        b = pipe_cli->binding_handle;
     518
     519        if (r->in.password) {
     520
     521                status = cli_get_session_key(talloc_tos(), pipe_cli, &session_key);
     522                if (!NT_STATUS_IS_OK(status)) {
     523                        werr = ntstatus_to_werror(status);
     524                        goto done;
     525                }
     526
    461527                encode_wkssvc_join_password_buffer(ctx,
    462528                                                   r->in.password,
    463                                                    &pipe_cli->auth->user_session_key,
     529                                                   &session_key,
    464530                                                   &encrypted_password);
    465531        }
    466532
    467         status = rpccli_wkssvc_NetrRenameMachineInDomain2(pipe_cli, talloc_tos(),
     533        status = dcerpc_wkssvc_NetrRenameMachineInDomain2(b, talloc_tos(),
    468534                                                          r->in.server_name,
    469535                                                          r->in.new_machine_name,
  • vendor/current/source3/lib/netapi/libnetapi.c

    r594 r740  
    7575
    7676        TALLOC_FREE(frame);
    77         return r.out.result;
     77        return (NET_API_STATUS)r.out.result;
    7878}
    7979
     
    124124
    125125        TALLOC_FREE(frame);
    126         return r.out.result;
     126        return (NET_API_STATUS)r.out.result;
    127127}
    128128
     
    171171
    172172        TALLOC_FREE(frame);
    173         return r.out.result;
     173        return (NET_API_STATUS)r.out.result;
    174174}
    175175
     
    224224
    225225        TALLOC_FREE(frame);
    226         return r.out.result;
     226        return (NET_API_STATUS)r.out.result;
    227227}
    228228
     
    275275
    276276        TALLOC_FREE(frame);
    277         return r.out.result;
     277        return (NET_API_STATUS)r.out.result;
    278278}
    279279
     
    322322
    323323        TALLOC_FREE(frame);
    324         return r.out.result;
     324        return (NET_API_STATUS)r.out.result;
    325325}
    326326
     
    371371
    372372        TALLOC_FREE(frame);
    373         return r.out.result;
     373        return (NET_API_STATUS)r.out.result;
    374374}
    375375
     
    418418
    419419        TALLOC_FREE(frame);
    420         return r.out.result;
     420        return (NET_API_STATUS)r.out.result;
    421421}
    422422
     
    465465
    466466        TALLOC_FREE(frame);
    467         return r.out.result;
     467        return (NET_API_STATUS)r.out.result;
    468468}
    469469
     
    518518
    519519        TALLOC_FREE(frame);
    520         return r.out.result;
     520        return (NET_API_STATUS)r.out.result;
    521521}
    522522
     
    567567
    568568        TALLOC_FREE(frame);
    569         return r.out.result;
     569        return (NET_API_STATUS)r.out.result;
    570570}
    571571
     
    612612
    613613        TALLOC_FREE(frame);
    614         return r.out.result;
     614        return (NET_API_STATUS)r.out.result;
    615615}
    616616
     
    670670
    671671        TALLOC_FREE(frame);
    672         return r.out.result;
     672        return (NET_API_STATUS)r.out.result;
    673673}
    674674
     
    719719
    720720        TALLOC_FREE(frame);
    721         return r.out.result;
     721        return (NET_API_STATUS)r.out.result;
    722722}
    723723
     
    768768
    769769        TALLOC_FREE(frame);
    770         return r.out.result;
     770        return (NET_API_STATUS)r.out.result;
    771771}
    772772
     
    819819
    820820        TALLOC_FREE(frame);
    821         return r.out.result;
     821        return (NET_API_STATUS)r.out.result;
    822822}
    823823
     
    874874
    875875        TALLOC_FREE(frame);
    876         return r.out.result;
     876        return (NET_API_STATUS)r.out.result;
    877877}
    878878
     
    925925
    926926        TALLOC_FREE(frame);
    927         return r.out.result;
     927        return (NET_API_STATUS)r.out.result;
    928928}
    929929
     
    982982
    983983        TALLOC_FREE(frame);
    984         return r.out.result;
     984        return (NET_API_STATUS)r.out.result;
    985985}
    986986
     
    10291029
    10301030        TALLOC_FREE(frame);
    1031         return r.out.result;
     1031        return (NET_API_STATUS)r.out.result;
    10321032}
    10331033
     
    10781078
    10791079        TALLOC_FREE(frame);
    1080         return r.out.result;
     1080        return (NET_API_STATUS)r.out.result;
    10811081}
    10821082
     
    11331133
    11341134        TALLOC_FREE(frame);
    1135         return r.out.result;
     1135        return (NET_API_STATUS)r.out.result;
    11361136}
    11371137
     
    11821182
    11831183        TALLOC_FREE(frame);
    1184         return r.out.result;
     1184        return (NET_API_STATUS)r.out.result;
    11851185}
    11861186
     
    12271227
    12281228        TALLOC_FREE(frame);
    1229         return r.out.result;
     1229        return (NET_API_STATUS)r.out.result;
    12301230}
    12311231
     
    12831283
    12841284        TALLOC_FREE(frame);
    1285         return r.out.result;
     1285        return (NET_API_STATUS)r.out.result;
    12861286}
    12871287
     
    13341334
    13351335        TALLOC_FREE(frame);
    1336         return r.out.result;
     1336        return (NET_API_STATUS)r.out.result;
    13371337}
    13381338
     
    13831383
    13841384        TALLOC_FREE(frame);
    1385         return r.out.result;
     1385        return (NET_API_STATUS)r.out.result;
    13861386}
    13871387
     
    14301430
    14311431        TALLOC_FREE(frame);
    1432         return r.out.result;
     1432        return (NET_API_STATUS)r.out.result;
    14331433}
    14341434
     
    14771477
    14781478        TALLOC_FREE(frame);
    1479         return r.out.result;
     1479        return (NET_API_STATUS)r.out.result;
    14801480}
    14811481
     
    15351535
    15361536        TALLOC_FREE(frame);
    1537         return r.out.result;
     1537        return (NET_API_STATUS)r.out.result;
    15381538}
    15391539
     
    15861586
    15871587        TALLOC_FREE(frame);
    1588         return r.out.result;
     1588        return (NET_API_STATUS)r.out.result;
    15891589}
    15901590
     
    16351635
    16361636        TALLOC_FREE(frame);
    1637         return r.out.result;
     1637        return (NET_API_STATUS)r.out.result;
    16381638}
    16391639
     
    16801680
    16811681        TALLOC_FREE(frame);
    1682         return r.out.result;
     1682        return (NET_API_STATUS)r.out.result;
    16831683}
    16841684
     
    17291729
    17301730        TALLOC_FREE(frame);
    1731         return r.out.result;
     1731        return (NET_API_STATUS)r.out.result;
    17321732}
    17331733
     
    17801780
    17811781        TALLOC_FREE(frame);
    1782         return r.out.result;
     1782        return (NET_API_STATUS)r.out.result;
    17831783}
    17841784
     
    18361836
    18371837        TALLOC_FREE(frame);
    1838         return r.out.result;
     1838        return (NET_API_STATUS)r.out.result;
    18391839}
    18401840
     
    18871887
    18881888        TALLOC_FREE(frame);
    1889         return r.out.result;
     1889        return (NET_API_STATUS)r.out.result;
    18901890}
    18911891
     
    19381938
    19391939        TALLOC_FREE(frame);
    1940         return r.out.result;
     1940        return (NET_API_STATUS)r.out.result;
    19411941}
    19421942
     
    19961996
    19971997        TALLOC_FREE(frame);
    1998         return r.out.result;
     1998        return (NET_API_STATUS)r.out.result;
    19991999}
    20002000
     
    20472047
    20482048        TALLOC_FREE(frame);
    2049         return r.out.result;
     2049        return (NET_API_STATUS)r.out.result;
    20502050}
    20512051
     
    20922092
    20932093        TALLOC_FREE(frame);
    2094         return r.out.result;
     2094        return (NET_API_STATUS)r.out.result;
    20952095}
    20962096
     
    21412141
    21422142        TALLOC_FREE(frame);
    2143         return r.out.result;
     2143        return (NET_API_STATUS)r.out.result;
    21442144}
    21452145
     
    21882188
    21892189        TALLOC_FREE(frame);
    2190         return r.out.result;
     2190        return (NET_API_STATUS)r.out.result;
    21912191}
    21922192
     
    22442244
    22452245        TALLOC_FREE(frame);
    2246         return r.out.result;
     2246        return (NET_API_STATUS)r.out.result;
    22472247}
    22482248
     
    22932293
    22942294        TALLOC_FREE(frame);
    2295         return r.out.result;
     2295        return (NET_API_STATUS)r.out.result;
    22962296}
    22972297
     
    23442344
    23452345        TALLOC_FREE(frame);
    2346         return r.out.result;
     2346        return (NET_API_STATUS)r.out.result;
    23472347}
    23482348
     
    23892389
    23902390        TALLOC_FREE(frame);
    2391         return r.out.result;
     2391        return (NET_API_STATUS)r.out.result;
    23922392}
    23932393
     
    24382438
    24392439        TALLOC_FREE(frame);
    2440         return r.out.result;
     2440        return (NET_API_STATUS)r.out.result;
    24412441}
    24422442
     
    24982498
    24992499        TALLOC_FREE(frame);
    2500         return r.out.result;
     2500        return (NET_API_STATUS)r.out.result;
    25012501}
    25022502
     
    25492549
    25502550        TALLOC_FREE(frame);
    2551         return r.out.result;
     2551        return (NET_API_STATUS)r.out.result;
    25522552}
    25532553
     
    25922592
    25932593        TALLOC_FREE(frame);
    2594         return r.out.result;
     2594        return (NET_API_STATUS)r.out.result;
    25952595}
    25962596
     
    26412641
    26422642        TALLOC_FREE(frame);
    2643         return r.out.result;
     2643        return (NET_API_STATUS)r.out.result;
    26442644}
    26452645
     
    26922692
    26932693        TALLOC_FREE(frame);
    2694         return r.out.result;
    2695 }
    2696 
     2694        return (NET_API_STATUS)r.out.result;
     2695}
     2696
  • vendor/current/source3/lib/netapi/libnetapi.h

    r414 r740  
     1/*
     2 *  Unix SMB/CIFS implementation.
     3 *  NetApi Support
     4 *  Copyright (C) Guenther Deschner 2007-2008
     5 *
     6 *  This program is free software; you can redistribute it and/or modify
     7 *  it under the terms of the GNU General Public License as published by
     8 *  the Free Software Foundation; either version 3 of the License, or
     9 *  (at your option) any later version.
     10 *
     11 *  This program is distributed in the hope that it will be useful,
     12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 *  GNU General Public License for more details.
     15 *
     16 *  You should have received a copy of the GNU General Public License
     17 *  along with this program; if not, see <http://www.gnu.org/licenses/>.
     18 */
     19
    120#ifndef __LIBNETAPI_LIBNETAPI__
    221#define __LIBNETAPI_LIBNETAPI__
  • vendor/current/source3/lib/netapi/localgroup.c

    r594 r740  
    2424#include "lib/netapi/netapi_private.h"
    2525#include "lib/netapi/libnetapi.h"
    26 #include "../librpc/gen_ndr/cli_samr.h"
    27 #include "../librpc/gen_ndr/cli_lsa.h"
     26#include "rpc_client/rpc_client.h"
     27#include "../librpc/gen_ndr/ndr_samr_c.h"
     28#include "../librpc/gen_ndr/ndr_lsa_c.h"
     29#include "rpc_client/cli_lsarpc.h"
     30#include "rpc_client/init_lsa.h"
     31#include "../libcli/security/security.h"
    2832
    2933static NTSTATUS libnetapi_samr_lookup_and_open_alias(TALLOC_CTX *mem_ctx,
     
    3438                                                     struct policy_handle *alias_handle)
    3539{
    36         NTSTATUS status;
     40        NTSTATUS status, result;
    3741
    3842        struct lsa_String lsa_account_name;
    3943        struct samr_Ids user_rids, name_types;
     44        struct dcerpc_binding_handle *b = pipe_cli->binding_handle;
    4045
    4146        init_lsa_String(&lsa_account_name, group_name);
    4247
    43         status = rpccli_samr_LookupNames(pipe_cli, mem_ctx,
     48        status = dcerpc_samr_LookupNames(b, mem_ctx,
    4449                                         domain_handle,
    4550                                         1,
    4651                                         &lsa_account_name,
    4752                                         &user_rids,
    48                                          &name_types);
     53                                         &name_types,
     54                                         &result);
    4955        if (!NT_STATUS_IS_OK(status)) {
    5056                return status;
     57        }
     58        if (!NT_STATUS_IS_OK(result)) {
     59                return result;
    5160        }
    5261
     
    5968        }
    6069
    61         return rpccli_samr_OpenAlias(pipe_cli, mem_ctx,
    62                                      domain_handle,
    63                                      access_rights,
    64                                      user_rids.ids[0],
    65                                      alias_handle);
     70        status = dcerpc_samr_OpenAlias(b, mem_ctx,
     71                                       domain_handle,
     72                                       access_rights,
     73                                       user_rids.ids[0],
     74                                       alias_handle,
     75                                       &result);
     76        if (!NT_STATUS_IS_OK(status)) {
     77                return status;
     78        }
     79
     80        return result;
    6681}
    6782
     
    7792                                                    union samr_AliasInfo **alias_info)
    7893{
    79         NTSTATUS status;
     94        NTSTATUS status, result;
    8095        struct policy_handle alias_handle;
    8196        union samr_AliasInfo *_alias_info = NULL;
     97        struct dcerpc_binding_handle *b = pipe_cli->binding_handle;
    8298
    8399        ZERO_STRUCT(alias_handle);
    84100
    85         status = rpccli_samr_OpenAlias(pipe_cli, mem_ctx,
     101        status = dcerpc_samr_OpenAlias(b, mem_ctx,
    86102                                       handle,
    87103                                       access_rights,
    88104                                       rid,
    89                                        &alias_handle);
    90         if (!NT_STATUS_IS_OK(status)) {
    91                 goto done;
    92         }
    93 
    94         status = rpccli_samr_QueryAliasInfo(pipe_cli, mem_ctx,
     105                                       &alias_handle,
     106                                       &result);
     107        if (!NT_STATUS_IS_OK(status)) {
     108                goto done;
     109        }
     110        if (!NT_STATUS_IS_OK(result)) {
     111                status = result;
     112                goto done;
     113        }
     114
     115        status = dcerpc_samr_QueryAliasInfo(b, mem_ctx,
    95116                                            &alias_handle,
    96117                                            level,
    97                                             &_alias_info);
    98         if (!NT_STATUS_IS_OK(status)) {
     118                                            &_alias_info,
     119                                            &result);
     120        if (!NT_STATUS_IS_OK(status)) {
     121                goto done;
     122        }
     123        if (!NT_STATUS_IS_OK(result)) {
     124                status = result;
    99125                goto done;
    100126        }
     
    104130 done:
    105131        if (is_valid_policy_hnd(&alias_handle)) {
    106                 rpccli_samr_Close(pipe_cli, mem_ctx, &alias_handle);
     132                dcerpc_samr_Close(b, mem_ctx, &alias_handle, &result);
    107133        }
    108134
     
    117143{
    118144        struct rpc_pipe_client *pipe_cli = NULL;
    119         NTSTATUS status;
     145        NTSTATUS status, result;
    120146        WERROR werr;
    121147        struct lsa_String lsa_account_name;
     
    123149        struct dom_sid2 *domain_sid = NULL;
    124150        uint32_t rid;
     151        struct dcerpc_binding_handle *b = NULL;
    125152
    126153        struct LOCALGROUP_INFO_0 *info0 = NULL;
     
    158185                goto done;
    159186        }
     187
     188        b = pipe_cli->binding_handle;
    160189
    161190        werr = libnetapi_samr_open_builtin_domain(ctx, pipe_cli,
     
    197226        init_lsa_String(&lsa_account_name, alias_name);
    198227
    199         status = rpccli_samr_CreateDomAlias(pipe_cli, talloc_tos(),
     228        status = dcerpc_samr_CreateDomAlias(b, talloc_tos(),
    200229                                            &domain_handle,
    201230                                            &lsa_account_name,
     
    203232                                            SAMR_ALIAS_ACCESS_SET_INFO,
    204233                                            &alias_handle,
    205                                             &rid);
     234                                            &rid,
     235                                            &result);
    206236        if (!NT_STATUS_IS_OK(status)) {
    207237                werr = ntstatus_to_werror(status);
    208238                goto done;
    209239        }
     240        if (!NT_STATUS_IS_OK(result)) {
     241                werr = ntstatus_to_werror(result);
     242                goto done;
     243        }
     244
    210245
    211246        if (r->in.level == 1 && info1->lgrpi1_comment) {
     
    215250                init_lsa_String(&alias_info.description, info1->lgrpi1_comment);
    216251
    217                 status = rpccli_samr_SetAliasInfo(pipe_cli, talloc_tos(),
     252                status = dcerpc_samr_SetAliasInfo(b, talloc_tos(),
    218253                                                  &alias_handle,
    219254                                                  ALIASINFODESCRIPTION,
    220                                                   &alias_info);
     255                                                  &alias_info,
     256                                                  &result);
    221257                if (!NT_STATUS_IS_OK(status)) {
    222258                        werr = ntstatus_to_werror(status);
    223259                        goto done;
    224260                }
     261                if (!NT_STATUS_IS_OK(result)) {
     262                        werr = ntstatus_to_werror(result);
     263                        goto done;
     264                }
    225265        }
    226266
     
    229269 done:
    230270        if (is_valid_policy_hnd(&alias_handle)) {
    231                 rpccli_samr_Close(pipe_cli, talloc_tos(), &alias_handle);
     271                dcerpc_samr_Close(b, talloc_tos(), &alias_handle, &result);
    232272        }
    233273
     
    258298{
    259299        struct rpc_pipe_client *pipe_cli = NULL;
    260         NTSTATUS status;
     300        NTSTATUS status, result;
    261301        WERROR werr;
    262302        struct policy_handle connect_handle, domain_handle, builtin_handle, alias_handle;
    263303        struct dom_sid2 *domain_sid = NULL;
     304        struct dcerpc_binding_handle *b = NULL;
    264305
    265306        if (!r->in.group_name) {
     
    278319                goto done;
    279320        }
     321
     322        b = pipe_cli->binding_handle;
    280323
    281324        werr = libnetapi_samr_open_builtin_domain(ctx, pipe_cli,
     
    332375
    333376 delete_alias:
    334         status = rpccli_samr_DeleteDomAlias(pipe_cli, talloc_tos(),
    335                                             &alias_handle);
     377        status = dcerpc_samr_DeleteDomAlias(b, talloc_tos(),
     378                                            &alias_handle,
     379                                            &result);
    336380        if (!NT_STATUS_IS_OK(status)) {
    337381                werr = ntstatus_to_werror(status);
     382                goto done;
     383        }
     384        if (!NT_STATUS_IS_OK(result)) {
     385                werr = ntstatus_to_werror(result);
    338386                goto done;
    339387        }
     
    345393 done:
    346394        if (is_valid_policy_hnd(&alias_handle)) {
    347                 rpccli_samr_Close(pipe_cli, talloc_tos(), &alias_handle);
     395                dcerpc_samr_Close(b, talloc_tos(), &alias_handle, &result);
    348396        }
    349397
     
    419467{
    420468        struct rpc_pipe_client *pipe_cli = NULL;
    421         NTSTATUS status;
     469        NTSTATUS status, result;
    422470        WERROR werr;
    423471        struct policy_handle connect_handle, domain_handle, builtin_handle, alias_handle;
     
    425473        union samr_AliasInfo *alias_info = NULL;
    426474        uint32_t entries_read = 0;
     475        struct dcerpc_binding_handle *b = NULL;
    427476
    428477        if (!r->in.group_name) {
     
    450499                goto done;
    451500        }
     501
     502        b = pipe_cli->binding_handle;
    452503
    453504        werr = libnetapi_samr_open_builtin_domain(ctx, pipe_cli,
     
    503554
    504555 query_alias:
    505         status = rpccli_samr_QueryAliasInfo(pipe_cli, talloc_tos(),
     556        status = dcerpc_samr_QueryAliasInfo(b, talloc_tos(),
    506557                                            &alias_handle,
    507558                                            ALIASINFOALL,
    508                                             &alias_info);
     559                                            &alias_info,
     560                                            &result);
    509561        if (!NT_STATUS_IS_OK(status)) {
    510562                werr = ntstatus_to_werror(status);
     563                goto done;
     564        }
     565        if (!NT_STATUS_IS_OK(result)) {
     566                werr = ntstatus_to_werror(result);
    511567                goto done;
    512568        }
     
    520576 done:
    521577        if (is_valid_policy_hnd(&alias_handle)) {
    522                 rpccli_samr_Close(pipe_cli, talloc_tos(), &alias_handle);
     578                dcerpc_samr_Close(b, talloc_tos(), &alias_handle, &result);
    523579        }
    524580
     
    589645{
    590646        struct rpc_pipe_client *pipe_cli = NULL;
    591         NTSTATUS status;
     647        NTSTATUS status, result;
    592648        WERROR werr;
    593649        struct lsa_String lsa_account_name;
     
    596652        enum samr_AliasInfoEnum alias_level = 0;
    597653        union samr_AliasInfo *alias_info = NULL;
     654        struct dcerpc_binding_handle *b = NULL;
    598655
    599656        if (!r->in.group_name) {
     
    621678                goto done;
    622679        }
     680
     681        b = pipe_cli->binding_handle;
    623682
    624683        werr = libnetapi_samr_open_builtin_domain(ctx, pipe_cli,
     
    681740        }
    682741
    683         status = rpccli_samr_SetAliasInfo(pipe_cli, talloc_tos(),
     742        status = dcerpc_samr_SetAliasInfo(b, talloc_tos(),
    684743                                          &alias_handle,
    685744                                          alias_level,
    686                                           alias_info);
     745                                          alias_info,
     746                                          &result);
    687747        if (!NT_STATUS_IS_OK(status)) {
    688748                werr = ntstatus_to_werror(status);
     749                goto done;
     750        }
     751        if (!NT_STATUS_IS_OK(result)) {
     752                werr = ntstatus_to_werror(result);
    689753                goto done;
    690754        }
     
    694758 done:
    695759        if (is_valid_policy_hnd(&alias_handle)) {
    696                 rpccli_samr_Close(pipe_cli, talloc_tos(), &alias_handle);
     760                dcerpc_samr_Close(b, talloc_tos(), &alias_handle, &result);
    697761        }
    698762
     
    722786{
    723787        struct rpc_pipe_client *pipe_cli = NULL;
    724         NTSTATUS status;
     788        NTSTATUS status, result;
    725789        WERROR werr;
    726790        struct policy_handle connect_handle, domain_handle, builtin_handle, alias_handle;
     
    732796        struct samr_SamArray *builtin_sam_array = NULL;
    733797        int i;
     798        struct dcerpc_binding_handle *b = NULL;
    734799
    735800        if (!r->out.buffer) {
     
    763828                goto done;
    764829        }
     830
     831        b = pipe_cli->binding_handle;
    765832
    766833        werr = libnetapi_samr_open_builtin_domain(ctx, pipe_cli,
     
    789856        }
    790857
    791         status = rpccli_samr_QueryDomainInfo(pipe_cli, talloc_tos(),
     858        status = dcerpc_samr_QueryDomainInfo(b, talloc_tos(),
    792859                                             &builtin_handle,
    793860                                             2,
    794                                              &builtin_info);
     861                                             &builtin_info,
     862                                             &result);
    795863        if (!NT_STATUS_IS_OK(status)) {
    796864                werr = ntstatus_to_werror(status);
     865                goto done;
     866        }
     867        if (!NT_STATUS_IS_OK(result)) {
     868                werr = ntstatus_to_werror(result);
    797869                goto done;
    798870        }
     
    802874        }
    803875
    804         status = rpccli_samr_QueryDomainInfo(pipe_cli, talloc_tos(),
     876        status = dcerpc_samr_QueryDomainInfo(b, talloc_tos(),
    805877                                             &domain_handle,
    806878                                             2,
    807                                              &domain_info);
     879                                             &domain_info,
     880                                             &result);
    808881        if (!NT_STATUS_IS_OK(status)) {
    809882                werr = ntstatus_to_werror(status);
     883                goto done;
     884        }
     885        if (!NT_STATUS_IS_OK(result)) {
     886                werr = ntstatus_to_werror(result);
    810887                goto done;
    811888        }
     
    815892        }
    816893
    817         status = rpccli_samr_EnumDomainAliases(pipe_cli, talloc_tos(),
     894        status = dcerpc_samr_EnumDomainAliases(b, talloc_tos(),
    818895                                               &builtin_handle,
    819896                                               r->in.resume_handle,
    820897                                               &builtin_sam_array,
    821898                                               r->in.prefmaxlen,
    822                                                &entries_read);
     899                                               &entries_read,
     900                                               &result);
    823901        if (!NT_STATUS_IS_OK(status)) {
    824902                werr = ntstatus_to_werror(status);
     903                goto done;
     904        }
     905        if (!NT_STATUS_IS_OK(result)) {
     906                werr = ntstatus_to_werror(result);
    825907                goto done;
    826908        }
     
    851933        }
    852934
    853         status = rpccli_samr_EnumDomainAliases(pipe_cli, talloc_tos(),
     935        status = dcerpc_samr_EnumDomainAliases(b, talloc_tos(),
    854936                                               &domain_handle,
    855937                                               r->in.resume_handle,
    856938                                               &domain_sam_array,
    857939                                               r->in.prefmaxlen,
    858                                                &entries_read);
     940                                               &entries_read,
     941                                               &result);
    859942        if (!NT_STATUS_IS_OK(status)) {
    860943                werr = ntstatus_to_werror(status);
     944                goto done;
     945        }
     946        if (!NT_STATUS_IS_OK(result)) {
     947                werr = ntstatus_to_werror(result);
    861948                goto done;
    862949        }
     
    9141001                                            struct dom_sid *sid)
    9151002{
    916         NTSTATUS status;
     1003        NTSTATUS status, result;
    9171004        struct policy_handle lsa_handle;
     1005        struct dcerpc_binding_handle *b = lsa_pipe->binding_handle;
    9181006
    9191007        struct lsa_RefDomainList *domains = NULL;
     
    9341022        status = rpccli_lsa_open_policy2(lsa_pipe, mem_ctx,
    9351023                                         false,
    936                                          STD_RIGHT_READ_CONTROL_ACCESS |
     1024                                         SEC_STD_READ_CONTROL |
    9371025                                         LSA_POLICY_VIEW_LOCAL_INFORMATION |
    9381026                                         LSA_POLICY_LOOKUP_NAMES,
     
    9401028        NT_STATUS_NOT_OK_RETURN(status);
    9411029
    942         status = rpccli_lsa_LookupNames3(lsa_pipe, mem_ctx,
     1030        status = dcerpc_lsa_LookupNames3(b, mem_ctx,
    9431031                                         &lsa_handle,
    9441032                                         num_names,
     
    9481036                                         LSA_LOOKUP_NAMES_ALL, /* sure ? */
    9491037                                         &count,
    950                                          0, 0);
     1038                                         0, 0,
     1039                                         &result);
    9511040        NT_STATUS_NOT_OK_RETURN(status);
     1041        NT_STATUS_NOT_OK_RETURN(result);
    9521042
    9531043        if (count != 1 || sids.count != 1) {
     
    9721062        struct rpc_pipe_client *pipe_cli = NULL;
    9731063        struct rpc_pipe_client *lsa_pipe = NULL;
    974         NTSTATUS status;
     1064        NTSTATUS status, result;
    9751065        WERROR werr;
    9761066        struct lsa_String lsa_account_name;
     
    9851075        struct dom_sid *add_sids = NULL;
    9861076        struct dom_sid *del_sids = NULL;
    987         size_t num_add_sids = 0;
    988         size_t num_del_sids = 0;
     1077        uint32_t num_add_sids = 0;
     1078        uint32_t num_del_sids = 0;
     1079        struct dcerpc_binding_handle *b = NULL;
    9891080
    9901081        if ((!add && !del && !set) || (add && del && set)) {
     
    10691160                goto done;
    10701161        }
     1162
     1163        b = pipe_cli->binding_handle;
    10711164
    10721165        werr = libnetapi_samr_open_builtin_domain(ctx, pipe_cli,
     
    11571250                struct lsa_SidArray current_sids;
    11581251
    1159                 status = rpccli_samr_GetMembersInAlias(pipe_cli, talloc_tos(),
     1252                status = dcerpc_samr_GetMembersInAlias(b, talloc_tos(),
    11601253                                                       &alias_handle,
    1161                                                        &current_sids);
     1254                                                       &current_sids,
     1255                                                       &result);
    11621256                if (!NT_STATUS_IS_OK(status)) {
    11631257                        werr = ntstatus_to_werror(status);
    11641258                        goto done;
    11651259                }
     1260                if (!NT_STATUS_IS_OK(result)) {
     1261                        werr = ntstatus_to_werror(result);
     1262                        goto done;
     1263                }
    11661264
    11671265                /* add list */
     
    11701268                        bool already_member = false;
    11711269                        for (k=0; k < current_sids.num_sids; k++) {
    1172                                 if (sid_equal(&member_sids[i],
     1270                                if (dom_sid_equal(&member_sids[i],
    11731271                                              current_sids.sids[k].sid)) {
    11741272                                        already_member = true;
     
    11921290                        bool keep_member = false;
    11931291                        for (i=0; i < r->in.total_entries; i++) {
    1194                                 if (sid_equal(&member_sids[i],
     1292                                if (dom_sid_equal(&member_sids[i],
    11951293                                              current_sids.sids[k].sid)) {
    11961294                                        keep_member = true;
     
    12131311
    12141312        for (i=0; i < num_add_sids; i++) {
    1215                 status = rpccli_samr_AddAliasMember(pipe_cli, talloc_tos(),
     1313                status = dcerpc_samr_AddAliasMember(b, talloc_tos(),
    12161314                                                    &alias_handle,
    1217                                                     &add_sids[i]);
     1315                                                    &add_sids[i],
     1316                                                    &result);
    12181317                if (!NT_STATUS_IS_OK(status)) {
    12191318                        werr = ntstatus_to_werror(status);
    12201319                        goto done;
    12211320                }
     1321                if (!NT_STATUS_IS_OK(result)) {
     1322                        werr = ntstatus_to_werror(result);
     1323                        goto done;
     1324                }
    12221325        }
    12231326
     
    12251328
    12261329        for (i=0; i < num_del_sids; i++) {
    1227                 status = rpccli_samr_DeleteAliasMember(pipe_cli, talloc_tos(),
     1330                status = dcerpc_samr_DeleteAliasMember(b, talloc_tos(),
    12281331                                                       &alias_handle,
    1229                                                        &del_sids[i]);
     1332                                                       &del_sids[i],
     1333                                                       &result);
    12301334                if (!NT_STATUS_IS_OK(status)) {
    12311335                        werr = ntstatus_to_werror(status);
    12321336                        goto done;
    12331337                }
     1338                if (!NT_STATUS_IS_OK(result)) {
     1339                        werr = ntstatus_to_werror(result);
     1340                        goto done;
     1341                }
    12341342        }
    12351343
     
    12371345
    12381346 done:
    1239         if (is_valid_policy_hnd(&alias_handle)) {
    1240                 rpccli_samr_Close(pipe_cli, talloc_tos(), &alias_handle);
     1347        if (b && is_valid_policy_hnd(&alias_handle)) {
     1348                dcerpc_samr_Close(b, talloc_tos(), &alias_handle, &result);
    12411349        }
    12421350
  • vendor/current/source3/lib/netapi/netapi.c

    r414 r740  
    2121#include "lib/netapi/netapi.h"
    2222#include "lib/netapi/netapi_private.h"
    23 
    24 extern bool AllowDebugChange;
     23#include "secrets.h"
     24#include "krb5_env.h"
    2525
    2626struct libnetapi_ctx *stat_ctx = NULL;
     
    5050
    5151/****************************************************************
     52Create a libnetapi context, for use in non-Samba applications.  This
     53loads the smb.conf file and sets the debug level to 0, so that
     54applications are not flooded with debug logs at level 10, when they
     55were not expecting it.
    5256****************************************************************/
    5357
    5458NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
    5559{
    56         NET_API_STATUS status;
    57         struct libnetapi_ctx *ctx = NULL;
    58         char *krb5_cc_env = NULL;
    59 
    6060        if (stat_ctx && libnetapi_initialized) {
    6161                *context = stat_ctx;
     
    6868        frame = talloc_stackframe();
    6969
    70         ctx = talloc_zero(frame, struct libnetapi_ctx);
    71         if (!ctx) {
    72                 TALLOC_FREE(frame);
    73                 return W_ERROR_V(WERR_NOMEM);
    74         }
    75 
    76         if (!DEBUGLEVEL) {
    77                 DEBUGLEVEL = 0;
    78         }
    79 
    80         /* prevent setup_logging() from closing x_stderr... */
    81         dbf = 0;
    82         setup_logging("libnetapi", true);
    83 
    84         dbf = x_stderr;
    85         x_setbuf(x_stderr, NULL);
    86         AllowDebugChange = false;
    87 
    88         load_case_tables();
     70        /* Case tables must be loaded before any string comparisons occour */
     71        load_case_tables_library();
     72
     73        /* When libnetapi is invoked from an application, it does not
     74         * want to be swamped with level 10 debug messages, even if
     75         * this has been set for the server in smb.conf */
     76        lp_set_cmdline("log level", "0");
     77        setup_logging("libnetapi", DEBUG_STDERR);
    8978
    9079        if (!lp_load(get_dyn_CONFIGFILE(), true, false, false, false)) {
     
    9483        }
    9584
    96         AllowDebugChange = true;
    97 
    9885        init_names();
    9986        load_interfaces();
    10087        reopen_logs();
     88
     89        BlockSignals(True, SIGPIPE);
     90
     91        return libnetapi_net_init(context);
     92}
     93
     94/****************************************************************
     95Create a libnetapi context, for use inside the 'net' binary.
     96
     97As we know net has already loaded the smb.conf file, and set the debug
     98level etc, this avoids doing so again (which causes trouble with -d on
     99the command line).
     100****************************************************************/
     101
     102NET_API_STATUS libnetapi_net_init(struct libnetapi_ctx **context)
     103{
     104        NET_API_STATUS status;
     105        struct libnetapi_ctx *ctx = NULL;
     106        char *krb5_cc_env = NULL;
     107
     108        frame = talloc_stackframe();
     109
     110        ctx = talloc_zero(frame, struct libnetapi_ctx);
     111        if (!ctx) {
     112                TALLOC_FREE(frame);
     113                return W_ERROR_V(WERR_NOMEM);
     114        }
    101115
    102116        BlockSignals(True, SIGPIPE);
     
    133147
    134148/****************************************************************
     149 Return the static libnetapi context
    135150****************************************************************/
    136151
     
    146161
    147162/****************************************************************
     163 Free the static libnetapi context
    148164****************************************************************/
    149165
     
    182198
    183199/****************************************************************
     200 Override the current log level for libnetapi
    184201****************************************************************/
    185202
     
    187204                                        const char *debuglevel)
    188205{
    189         AllowDebugChange = true;
    190206        ctx->debuglevel = talloc_strdup(ctx, debuglevel);
    191         if (!debug_parse_levels(debuglevel)) {
     207        if (!lp_set_cmdline("log level", debuglevel)) {
    192208                return W_ERROR_V(WERR_GENERAL_FAILURE);
    193209        }
  • vendor/current/source3/lib/netapi/netapi.h

    r414 r740  
    12851285};
    12861286
     1287#define DS_PDC_FLAG ( 0x00000001 )
     1288#define DS_GC_FLAG ( 0x00000004 )
     1289#define DS_LDAP_FLAG ( 0x00000008 )
     1290#define DS_DS_FLAG ( 0x00000010 )
     1291#define DS_KDC_FLAG ( 0x00000020 )
     1292#define DS_TIMESERV_FLAG ( 0x00000040 )
     1293#define DS_CLOSEST_FLAG ( 0x00000080 )
     1294#define DS_WRITABLE_FLAG ( 0x00000100 )
     1295#define DS_GOOD_TIMESERV_FLAG ( 0x00000200 )
     1296#define DS_NDNC_FLAG ( 0x00000400 )
     1297#define DS_SELECT_SECRET_DOMAIN_6_FLAG ( 0x00000800 )
     1298#define DS_FULL_SECRET_DOMAIN_6_FLAG ( 0x00001000 )
     1299#define DS_DNS_CONTROLLER_FLAG ( 0x20000000 )
     1300#define DS_DNS_DOMAIN_FLAG ( 0x40000000 )
     1301#define DS_DNS_FOREST_FLAG ( 0x80000000 )
     1302
    12871303#endif /* _HEADER_libnetapi */
    12881304
     
    13061322#define NETLOGON_CONTROL_BREAKPOINT ( 0x0000FFFF )
    13071323
     1324#define DS_FORCE_REDISCOVERY ( 0x00000001 )
     1325#define DS_DIRECTORY_SERVICE_REQUIRED ( 0x00000010 )
     1326#define DS_DIRECTORY_SERVICE_PREFERRED ( 0x00000020 )
     1327#define DS_GC_SERVER_REQUIRED ( 0x00000040 )
     1328#define DS_PDC_REQUIRED ( 0x00000080 )
     1329#define DS_BACKGROUND_ONLY ( 0x00000100 )
     1330#define DS_IP_REQUIRED ( 0x00000200 )
     1331#define DS_KDC_REQUIRED ( 0x00000400 )
     1332#define DS_TIMESERV_REQUIRED ( 0x00000800 )
     1333#define DS_WRITABLE_REQUIRED ( 0x00001000 )
     1334#define DS_GOOD_TIMESERV_PREFERRED ( 0x00002000 )
     1335#define DS_AVOID_SELF ( 0x00004000 )
     1336#define DS_ONLY_LDAP_NEEDED ( 0x00008000 )
     1337#define DS_IS_FLAT_NAME ( 0x00010000 )
     1338#define DS_IS_DNS_NAME ( 0x00020000 )
     1339#define DS_TRY_NEXTCLOSEST_SITE ( 0x00040000 )
     1340#define DS_DIRECTORY_SERVICE_6_REQUIRED ( 0x00080000 )
     1341#define DS_WEB_SERVICE_REQUIRED ( 0x00100000 )
     1342#define DS_RETURN_DNS_NAME ( 0x40000000 )
     1343#define DS_RETURN_FLAT_NAME ( 0x80000000 )
     1344
    13081345#endif /* _HEADER_netlogon */
    13091346
  • vendor/current/source3/lib/netapi/netapi_private.h

    r587 r740  
    2121#define __LIB_NETAPI_PRIVATE_H__
    2222
     23#include "lib/netapi/netapi_net.h"
     24
    2325#define LIBNETAPI_REDIRECT_TO_LOCALHOST(ctx, r, fn) \
    2426        DEBUG(10,("redirecting call %s to localhost\n", #fn)); \
     
    2729        } \
    2830        return fn ## _r(ctx, r);
     31
     32struct dcerpc_binding_handle;
    2933
    3034struct libnetapi_private_ctx {
     
    4549
    4650        struct client_ipc_connection *ipc_connections;
     51
     52        struct messaging_context *msg_ctx;
    4753};
    4854
     
    5763                           const struct ndr_syntax_id *interface,
    5864                           struct rpc_pipe_client **presult);
     65WERROR libnetapi_get_binding_handle(struct libnetapi_ctx *ctx,
     66                                    const char *server_name,
     67                                    const struct ndr_syntax_id *interface,
     68                                    struct dcerpc_binding_handle **binding_handle);
    5969WERROR libnetapi_samr_open_domain(struct libnetapi_ctx *mem_ctx,
    6070                                  struct rpc_pipe_client *pipe_cli,
  • vendor/current/source3/lib/netapi/netlogon.c

    r594 r740  
    2020#include "includes.h"
    2121
     22#include "../librpc/gen_ndr/ndr_netlogon_c.h"
    2223#include "librpc/gen_ndr/libnetapi.h"
    2324#include "lib/netapi/netapi.h"
    2425#include "lib/netapi/netapi_private.h"
    2526#include "lib/netapi/libnetapi.h"
    26 #include "../librpc/gen_ndr/cli_netlogon.h"
    2727
    2828static WERROR construct_data(enum netr_LogonControlCode function_code,
     
    4444                data_out->debug_level = atoi((const char *)data_in);
    4545                break;
     46        case NETLOGON_CONTROL_FORCE_DNS_REG:
     47                ZERO_STRUCTP(data_out);
     48                break;
    4649        default:
    4750                return WERR_INVALID_PARAM;
     
    127130        WERROR werr;
    128131        NTSTATUS status;
    129         struct rpc_pipe_client *pipe_cli = NULL;
    130132        union netr_CONTROL_QUERY_INFORMATION query;
    131 
    132         werr = libnetapi_open_pipe(ctx, r->in.server_name,
    133                                    &ndr_table_netlogon.syntax_id,
    134                                    &pipe_cli);
    135         if (!W_ERROR_IS_OK(werr)) {
    136                 goto done;
    137         }
    138 
    139         status = rpccli_netr_LogonControl(pipe_cli, talloc_tos(),
     133        struct dcerpc_binding_handle *b;
     134
     135        werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     136                                            &ndr_table_netlogon.syntax_id,
     137                                            &b);
     138        if (!W_ERROR_IS_OK(werr)) {
     139                goto done;
     140        }
     141
     142        status = dcerpc_netr_LogonControl(b, talloc_tos(),
    140143                                          r->in.server_name,
    141144                                          r->in.function_code,
     
    147150                goto done;
    148151        }
     152        if (!W_ERROR_IS_OK(werr)) {
     153                goto done;
     154        }
    149155
    150156        werr = construct_buffer(ctx, r->in.query_level, &query,
     
    175181        WERROR werr;
    176182        NTSTATUS status;
    177         struct rpc_pipe_client *pipe_cli = NULL;
    178183        union netr_CONTROL_DATA_INFORMATION data;
    179184        union netr_CONTROL_QUERY_INFORMATION query;
     185        struct dcerpc_binding_handle *b;
    180186
    181187        werr = construct_data(r->in.function_code, r->in.data, &data);
     
    184190        }
    185191
    186         werr = libnetapi_open_pipe(ctx, r->in.server_name,
    187                                    &ndr_table_netlogon.syntax_id,
    188                                    &pipe_cli);
     192        werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     193                                            &ndr_table_netlogon.syntax_id,
     194                                            &b);
    189195        if (!W_ERROR_IS_OK(werr)) {
    190196                goto done;
     
    194200        case NETLOGON_CONTROL_TC_VERIFY:
    195201        case NETLOGON_CONTROL_SET_DBFLAG:
    196                 status = rpccli_netr_LogonControl2Ex(pipe_cli, talloc_tos(),
     202        case NETLOGON_CONTROL_FORCE_DNS_REG:
     203                status = dcerpc_netr_LogonControl2Ex(b, talloc_tos(),
    197204                                                     r->in.server_name,
    198205                                                     r->in.function_code,
     
    203210                break;
    204211        default:
    205                 status = rpccli_netr_LogonControl2(pipe_cli, talloc_tos(),
     212                status = dcerpc_netr_LogonControl2(b, talloc_tos(),
    206213                                                   r->in.server_name,
    207214                                                   r->in.function_code,
     
    213220        }
    214221
    215         if (!W_ERROR_IS_OK(werr)) {
    216                 goto done;
    217         }
    218 
    219222        if (!NT_STATUS_IS_OK(status)) {
    220223                werr = ntstatus_to_werror(status);
     
    222225        }
    223226
     227        if (!W_ERROR_IS_OK(werr)) {
     228                goto done;
     229        }
     230
    224231        werr = construct_buffer(ctx, r->in.query_level, &query,
    225232                                r->out.buffer);
  • vendor/current/source3/lib/netapi/samr.c

    r414 r740  
    2121#include "lib/netapi/netapi.h"
    2222#include "lib/netapi/netapi_private.h"
    23 #include "../librpc/gen_ndr/cli_samr.h"
     23#include "rpc_client/rpc_client.h"
     24#include "../librpc/gen_ndr/ndr_samr_c.h"
     25#include "rpc_client/cli_samr.h"
     26#include "rpc_client/init_lsa.h"
     27#include "../libcli/security/security.h"
    2428
    2529/****************************************************************
     
    3438                                  struct dom_sid2 **domain_sid)
    3539{
    36         NTSTATUS status;
     40        NTSTATUS status, result;
    3741        WERROR werr;
    3842        struct libnetapi_private_ctx *priv;
     
    4448        bool domain_found = true;
    4549        int i;
     50        struct dcerpc_binding_handle *b = pipe_cli->binding_handle;
    4651
    4752        priv = talloc_get_type_abort(mem_ctx->private_data,
     
    7883
    7984        if (!is_valid_policy_hnd(connect_handle)) {
    80                 status = rpccli_try_samr_connects(pipe_cli, mem_ctx,
     85                status = dcerpc_try_samr_connects(pipe_cli->binding_handle, mem_ctx,
     86                                                  pipe_cli->srv_name_slash,
    8187                                                  connect_mask,
    82                                                   connect_handle);
     88                                                  connect_handle,
     89                                                  &result);
    8390                if (!NT_STATUS_IS_OK(status)) {
    8491                        werr = ntstatus_to_werror(status);
    8592                        goto done;
    8693                }
    87         }
    88 
    89         status = rpccli_samr_EnumDomains(pipe_cli, mem_ctx,
     94                if (!NT_STATUS_IS_OK(result)) {
     95                        werr = ntstatus_to_werror(result);
     96                        goto done;
     97                }
     98        }
     99
     100        status = dcerpc_samr_EnumDomains(b, mem_ctx,
    90101                                         connect_handle,
    91102                                         &resume_handle,
    92103                                         &sam,
    93104                                         0xffffffff,
    94                                          &num_entries);
     105                                         &num_entries,
     106                                         &result);
    95107        if (!NT_STATUS_IS_OK(status)) {
    96108                werr = ntstatus_to_werror(status);
    97109                goto done;
    98110        }
     111        if (!NT_STATUS_IS_OK(result)) {
     112                werr = ntstatus_to_werror(result);
     113                goto done;
     114        }
    99115
    100116        for (i=0; i<num_entries; i++) {
     
    117133        init_lsa_String(&lsa_domain_name, domain_name);
    118134
    119         status = rpccli_samr_LookupDomain(pipe_cli, mem_ctx,
     135        status = dcerpc_samr_LookupDomain(b, mem_ctx,
    120136                                          connect_handle,
    121137                                          &lsa_domain_name,
    122                                           domain_sid);
     138                                          domain_sid,
     139                                          &result);
    123140        if (!NT_STATUS_IS_OK(status)) {
    124141                werr = ntstatus_to_werror(status);
    125142                goto done;
    126143        }
    127 
    128         status = rpccli_samr_OpenDomain(pipe_cli, mem_ctx,
     144        if (!NT_STATUS_IS_OK(result)) {
     145                werr = ntstatus_to_werror(result);
     146                goto done;
     147        }
     148
     149        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    129150                                        connect_handle,
    130151                                        domain_mask,
    131152                                        *domain_sid,
    132                                         domain_handle);
     153                                        domain_handle,
     154                                        &result);
    133155        if (!NT_STATUS_IS_OK(status)) {
    134156                werr = ntstatus_to_werror(status);
     157                goto done;
     158        }
     159        if (!NT_STATUS_IS_OK(result)) {
     160                werr = ntstatus_to_werror(result);
    135161                goto done;
    136162        }
     
    163189                                          struct policy_handle *builtin_handle)
    164190{
    165         NTSTATUS status;
     191        NTSTATUS status, result;
    166192        WERROR werr;
    167193        struct libnetapi_private_ctx *priv;
     194        struct dcerpc_binding_handle *b = pipe_cli->binding_handle;
    168195
    169196        priv = talloc_get_type_abort(mem_ctx->private_data,
     
    196223
    197224        if (!is_valid_policy_hnd(connect_handle)) {
    198                 status = rpccli_try_samr_connects(pipe_cli, mem_ctx,
     225                status = dcerpc_try_samr_connects(pipe_cli->binding_handle, mem_ctx,
     226                                                  pipe_cli->srv_name_slash,
    199227                                                  connect_mask,
    200                                                   connect_handle);
     228                                                  connect_handle,
     229                                                  &result);
    201230                if (!NT_STATUS_IS_OK(status)) {
    202231                        werr = ntstatus_to_werror(status);
    203232                        goto done;
    204233                }
    205         }
    206 
    207         status = rpccli_samr_OpenDomain(pipe_cli, mem_ctx,
     234                if (!NT_STATUS_IS_OK(result)) {
     235                        werr = ntstatus_to_werror(result);
     236                        goto done;
     237                }
     238        }
     239
     240        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    208241                                        connect_handle,
    209242                                        builtin_mask,
    210                                         CONST_DISCARD(DOM_SID *, &global_sid_Builtin),
    211                                         builtin_handle);
     243                                        CONST_DISCARD(struct dom_sid *, &global_sid_Builtin),
     244                                        builtin_handle,
     245                                        &result);
    212246        if (!NT_STATUS_IS_OK(status)) {
    213247                werr = ntstatus_to_werror(status);
    214248                goto done;
    215249        }
     250        if (!NT_STATUS_IS_OK(result)) {
     251                werr = ntstatus_to_werror(result);
     252                goto done;
     253        }
    216254
    217255        priv->samr.cli                  = pipe_cli;
     
    236274{
    237275        struct libnetapi_private_ctx *priv;
     276        struct dcerpc_binding_handle *b;
     277        NTSTATUS result;
    238278
    239279        if (!is_valid_policy_hnd(handle)) {
     
    244284                struct libnetapi_private_ctx);
    245285
    246         if (!policy_hnd_equal(handle, &priv->samr.domain_handle)) {
    247                 return;
    248         }
    249 
    250         rpccli_samr_Close(priv->samr.cli, ctx, handle);
     286        if (!policy_handle_equal(handle, &priv->samr.domain_handle)) {
     287                return;
     288        }
     289
     290        b = priv->samr.cli->binding_handle;
     291
     292        dcerpc_samr_Close(b, ctx, handle, &result);
    251293
    252294        ZERO_STRUCT(priv->samr.domain_handle);
     
    260302{
    261303        struct libnetapi_private_ctx *priv;
     304        struct dcerpc_binding_handle *b;
     305        NTSTATUS result;
    262306
    263307        if (!is_valid_policy_hnd(handle)) {
     
    268312                struct libnetapi_private_ctx);
    269313
    270         if (!policy_hnd_equal(handle, &priv->samr.builtin_handle)) {
    271                 return;
    272         }
    273 
    274         rpccli_samr_Close(priv->samr.cli, ctx, handle);
     314        if (!policy_handle_equal(handle, &priv->samr.builtin_handle)) {
     315                return;
     316        }
     317
     318        b = priv->samr.cli->binding_handle;
     319
     320        dcerpc_samr_Close(b, ctx, handle, &result);
    275321
    276322        ZERO_STRUCT(priv->samr.builtin_handle);
     
    284330{
    285331        struct libnetapi_private_ctx *priv;
     332        struct dcerpc_binding_handle *b;
     333        NTSTATUS result;
    286334
    287335        if (!is_valid_policy_hnd(handle)) {
     
    292340                struct libnetapi_private_ctx);
    293341
    294         if (!policy_hnd_equal(handle, &priv->samr.connect_handle)) {
    295                 return;
    296         }
    297 
    298         rpccli_samr_Close(priv->samr.cli, ctx, handle);
     342        if (!policy_handle_equal(handle, &priv->samr.connect_handle)) {
     343                return;
     344        }
     345
     346        b = priv->samr.cli->binding_handle;
     347
     348        dcerpc_samr_Close(b, ctx, handle, &result);
    299349
    300350        ZERO_STRUCT(priv->samr.connect_handle);
  • vendor/current/source3/lib/netapi/serverinfo.c

    r594 r740  
    2424#include "lib/netapi/netapi_private.h"
    2525#include "lib/netapi/libnetapi.h"
    26 #include "libnet/libnet.h"
    27 #include "../librpc/gen_ndr/cli_srvsvc.h"
     26#include "../librpc/gen_ndr/ndr_srvsvc_c.h"
     27#include "lib/smbconf/smbconf.h"
     28#include "lib/smbconf/smbconf_reg.h"
    2829
    2930/****************************************************************
     
    480481                          struct NetServerGetInfo *r)
    481482{
    482         struct rpc_pipe_client *pipe_cli = NULL;
    483483        NTSTATUS status;
    484484        WERROR werr;
    485485        union srvsvc_NetSrvInfo info;
     486        struct dcerpc_binding_handle *b;
    486487
    487488        if (!r->out.buffer) {
     
    502503        }
    503504
    504         werr = libnetapi_open_pipe(ctx, r->in.server_name,
    505                                    &ndr_table_srvsvc.syntax_id,
    506                                    &pipe_cli);
     505        werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     506                                            &ndr_table_srvsvc.syntax_id,
     507                                            &b);
    507508        if (!W_ERROR_IS_OK(werr)) {
    508509                goto done;
    509510        }
    510511
    511         status = rpccli_srvsvc_NetSrvGetInfo(pipe_cli, talloc_tos(),
     512        status = dcerpc_srvsvc_NetSrvGetInfo(b, talloc_tos(),
    512513                                             r->in.server_name,
    513514                                             r->in.level,
     
    519520        }
    520521
     522        if (!W_ERROR_IS_OK(werr)) {
     523                goto done;
     524        }
     525
    521526        status = map_server_info_to_SERVER_INFO_buffer(ctx, r->in.level, &info,
    522527                                                       r->out.buffer);
     
    536541                                      struct NetServerSetInfo *r)
    537542{
    538         WERROR werr;
     543        WERROR werr = WERR_OK;
     544        sbcErr err;
    539545        struct smbconf_ctx *conf_ctx;
    540546        struct srvsvc_NetSrvInfo1005 *info1005;
     
    559565        }
    560566
    561         werr = smbconf_init_reg(ctx, &conf_ctx, NULL);
    562         if (!W_ERROR_IS_OK(werr)) {
    563                 goto done;
    564         }
    565 
    566         werr = smbconf_set_global_parameter(conf_ctx, "server string",
     567        err = smbconf_init_reg(ctx, &conf_ctx, NULL);
     568        if (!SBC_ERROR_IS_OK(err)) {
     569                libnetapi_set_error_string(ctx,
     570                        "Could not initialize backend: %s",
     571                        sbcErrorString(err));
     572                werr = WERR_NO_SUCH_SERVICE;
     573                goto done;
     574        }
     575
     576        err = smbconf_set_global_parameter(conf_ctx, "server string",
    567577                                            info1005->comment);
     578        if (!SBC_ERROR_IS_OK(err)) {
     579                libnetapi_set_error_string(ctx,
     580                        "Could not set global parameter: %s",
     581                        sbcErrorString(err));
     582                werr = WERR_NO_SUCH_SERVICE;
     583                goto done;
     584        }
    568585
    569586 done:
     
    594611                          struct NetServerSetInfo *r)
    595612{
    596         struct rpc_pipe_client *pipe_cli = NULL;
    597613        NTSTATUS status;
    598614        WERROR werr;
    599615        union srvsvc_NetSrvInfo info;
    600 
    601         werr = libnetapi_open_pipe(ctx, r->in.server_name,
    602                                    &ndr_table_srvsvc.syntax_id,
    603                                    &pipe_cli);
     616        struct dcerpc_binding_handle *b;
     617
     618        werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     619                                            &ndr_table_srvsvc.syntax_id,
     620                                            &b);
    604621        if (!W_ERROR_IS_OK(werr)) {
    605622                goto done;
     
    615632        }
    616633
    617         status = rpccli_srvsvc_NetSrvSetInfo(pipe_cli, talloc_tos(),
     634        status = dcerpc_srvsvc_NetSrvSetInfo(b, talloc_tos(),
    618635                                             r->in.server_name,
    619636                                             r->in.level,
     
    636653                      struct NetRemoteTOD *r)
    637654{
    638         struct rpc_pipe_client *pipe_cli = NULL;
    639655        NTSTATUS status;
    640656        WERROR werr;
    641657        struct srvsvc_NetRemoteTODInfo *info = NULL;
    642 
    643         werr = libnetapi_open_pipe(ctx, r->in.server_name,
    644                                    &ndr_table_srvsvc.syntax_id,
    645                                    &pipe_cli);
     658        struct dcerpc_binding_handle *b;
     659
     660        werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     661                                            &ndr_table_srvsvc.syntax_id,
     662                                            &b);
    646663        if (!W_ERROR_IS_OK(werr)) {
    647664                goto done;
    648665        }
    649666
    650         status = rpccli_srvsvc_NetRemoteTOD(pipe_cli, talloc_tos(),
     667        status = dcerpc_srvsvc_NetRemoteTOD(b, talloc_tos(),
    651668                                            r->in.server_name,
    652669                                            &info,
     
    657674        }
    658675
     676        if (!W_ERROR_IS_OK(werr)) {
     677                goto done;
     678        }
     679
    659680        *r->out.buffer = (uint8_t *)talloc_memdup(ctx, info,
    660681                          sizeof(struct srvsvc_NetRemoteTODInfo));
  • vendor/current/source3/lib/netapi/share.c

    r594 r740  
    2424#include "lib/netapi/netapi_private.h"
    2525#include "lib/netapi/libnetapi.h"
    26 #include "../librpc/gen_ndr/cli_srvsvc.h"
     26#include "../librpc/gen_ndr/ndr_srvsvc_c.h"
    2727
    2828/****************************************************************
     
    183183        WERROR werr;
    184184        NTSTATUS status;
    185         struct rpc_pipe_client *pipe_cli = NULL;
    186185        union srvsvc_NetShareInfo info;
     186        struct dcerpc_binding_handle *b;
    187187
    188188        if (!r->in.buffer) {
     
    200200        }
    201201
    202         werr = libnetapi_open_pipe(ctx, r->in.server_name,
    203                                    &ndr_table_srvsvc.syntax_id,
    204                                    &pipe_cli);
     202        werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     203                                            &ndr_table_srvsvc.syntax_id,
     204                                            &b);
    205205        if (!W_ERROR_IS_OK(werr)) {
    206206                goto done;
     
    216216        }
    217217
    218         status = rpccli_srvsvc_NetShareAdd(pipe_cli, talloc_tos(),
     218        status = dcerpc_srvsvc_NetShareAdd(b, talloc_tos(),
    219219                                           r->in.server_name,
    220220                                           r->in.level,
     
    222222                                           r->out.parm_err,
    223223                                           &werr);
     224        if (!NT_STATUS_IS_OK(status)) {
     225                werr = ntstatus_to_werror(status);
     226                goto done;
     227        }
     228
    224229        if (!W_ERROR_IS_OK(werr)) {
    225230                goto done;
     
    247252        WERROR werr;
    248253        NTSTATUS status;
    249         struct rpc_pipe_client *pipe_cli = NULL;
     254        struct dcerpc_binding_handle *b;
    250255
    251256        if (!r->in.net_name) {
     
    253258        }
    254259
    255         werr = libnetapi_open_pipe(ctx, r->in.server_name,
    256                                    &ndr_table_srvsvc.syntax_id,
    257                                    &pipe_cli);
    258         if (!W_ERROR_IS_OK(werr)) {
    259                 goto done;
    260         }
    261 
    262         status = rpccli_srvsvc_NetShareDel(pipe_cli, talloc_tos(),
     260        werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     261                                            &ndr_table_srvsvc.syntax_id,
     262                                            &b);
     263        if (!W_ERROR_IS_OK(werr)) {
     264                goto done;
     265        }
     266
     267        status = dcerpc_srvsvc_NetShareDel(b, talloc_tos(),
    263268                                           r->in.server_name,
    264269                                           r->in.net_name,
     
    291296        WERROR werr;
    292297        NTSTATUS status;
    293         struct rpc_pipe_client *pipe_cli = NULL;
    294298        struct srvsvc_NetShareInfoCtr info_ctr;
    295299        struct srvsvc_NetShareCtr0 ctr0;
     
    297301        struct srvsvc_NetShareCtr2 ctr2;
    298302        uint32_t i;
     303        struct dcerpc_binding_handle *b;
    299304
    300305        if (!r->out.buffer) {
     
    316321        ZERO_STRUCT(info_ctr);
    317322
    318         werr = libnetapi_open_pipe(ctx, r->in.server_name,
    319                                    &ndr_table_srvsvc.syntax_id,
    320                                    &pipe_cli);
     323        werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     324                                            &ndr_table_srvsvc.syntax_id,
     325                                            &b);
    321326        if (!W_ERROR_IS_OK(werr)) {
    322327                goto done;
     
    339344        }
    340345
    341         status = rpccli_srvsvc_NetShareEnumAll(pipe_cli, talloc_tos(),
     346        status = dcerpc_srvsvc_NetShareEnumAll(b, talloc_tos(),
    342347                                               r->in.server_name,
    343348                                               &info_ctr,
     
    346351                                               r->out.resume_handle,
    347352                                               &werr);
    348         if (NT_STATUS_IS_ERR(status)) {
     353        if (!NT_STATUS_IS_OK(status)) {
     354                werr = ntstatus_to_werror(status);
     355                goto done;
     356        }
     357
     358        if (!W_ERROR_IS_OK(werr) && !W_ERROR_EQUAL(werr, WERR_MORE_DATA)) {
    349359                goto done;
    350360        }
     
    371381                if (!NT_STATUS_IS_OK(status)) {
    372382                        werr = ntstatus_to_werror(status);
     383                        goto done;
    373384                }
    374385        }
     
    395406        WERROR werr;
    396407        NTSTATUS status;
    397         struct rpc_pipe_client *pipe_cli = NULL;
    398408        union srvsvc_NetShareInfo info;
    399409        uint32_t num_entries = 0;
     410        struct dcerpc_binding_handle *b;
    400411
    401412        if (!r->in.net_name || !r->out.buffer) {
     
    417428        }
    418429
    419         werr = libnetapi_open_pipe(ctx, r->in.server_name,
    420                                    &ndr_table_srvsvc.syntax_id,
    421                                    &pipe_cli);
    422         if (!W_ERROR_IS_OK(werr)) {
    423                 goto done;
    424         }
    425 
    426         status = rpccli_srvsvc_NetShareGetInfo(pipe_cli, talloc_tos(),
     430        werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     431                                            &ndr_table_srvsvc.syntax_id,
     432                                            &b);
     433        if (!W_ERROR_IS_OK(werr)) {
     434                goto done;
     435        }
     436
     437        status = dcerpc_srvsvc_NetShareGetInfo(b, talloc_tos(),
    427438                                               r->in.server_name,
    428439                                               r->in.net_name,
     
    430441                                               &info,
    431442                                               &werr);
     443        if (!NT_STATUS_IS_OK(status)) {
     444                werr = ntstatus_to_werror(status);
     445                goto done;
     446        }
    432447
    433448        if (!W_ERROR_IS_OK(werr)) {
     
    465480        WERROR werr;
    466481        NTSTATUS status;
    467         struct rpc_pipe_client *pipe_cli = NULL;
    468482        union srvsvc_NetShareInfo info;
     483        struct dcerpc_binding_handle *b;
    469484
    470485        if (!r->in.buffer) {
     
    487502        }
    488503
    489         werr = libnetapi_open_pipe(ctx, r->in.server_name,
    490                                    &ndr_table_srvsvc.syntax_id,
    491                                    &pipe_cli);
     504        werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     505                                            &ndr_table_srvsvc.syntax_id,
     506                                            &b);
    492507        if (!W_ERROR_IS_OK(werr)) {
    493508                goto done;
     
    503518        }
    504519
    505         status = rpccli_srvsvc_NetShareSetInfo(pipe_cli, talloc_tos(),
     520        status = dcerpc_srvsvc_NetShareSetInfo(b, talloc_tos(),
    506521                                               r->in.server_name,
    507522                                               r->in.net_name,
     
    510525                                               r->out.parm_err,
    511526                                               &werr);
     527        if (!NT_STATUS_IS_OK(status)) {
     528                werr = ntstatus_to_werror(status);
     529                goto done;
     530        }
     531
    512532        if (!W_ERROR_IS_OK(werr)) {
    513533                goto done;
  • vendor/current/source3/lib/netapi/shutdown.c

    r594 r740  
    2424#include "lib/netapi/netapi_private.h"
    2525#include "lib/netapi/libnetapi.h"
    26 #include "../librpc/gen_ndr/cli_initshutdown.h"
     26#include "../librpc/gen_ndr/ndr_initshutdown_c.h"
     27#include "rpc_client/init_lsa.h"
    2728
    2829/****************************************************************
     
    3435        WERROR werr;
    3536        NTSTATUS status;
    36         struct rpc_pipe_client *pipe_cli = NULL;
    3737        struct lsa_StringLarge message;
     38        struct dcerpc_binding_handle *b;
    3839
    39         werr = libnetapi_open_pipe(ctx, r->in.server_name,
    40                                    &ndr_table_initshutdown.syntax_id,
    41                                    &pipe_cli);
     40        werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     41                                            &ndr_table_initshutdown.syntax_id,
     42                                            &b);
    4243        if (!W_ERROR_IS_OK(werr)) {
    4344                goto done;
     
    4647        init_lsa_StringLarge(&message, r->in.message);
    4748
    48         status = rpccli_initshutdown_Init(pipe_cli, talloc_tos(),
     49        status = dcerpc_initshutdown_Init(b, talloc_tos(),
    4950                                          NULL,
    5051                                          &message,
     
    7980        WERROR werr;
    8081        NTSTATUS status;
    81         struct rpc_pipe_client *pipe_cli = NULL;
     82        struct dcerpc_binding_handle *b;
    8283
    83         werr = libnetapi_open_pipe(ctx, r->in.server_name,
    84                                    &ndr_table_initshutdown.syntax_id,
    85                                    &pipe_cli);
     84        werr = libnetapi_get_binding_handle(ctx, r->in.server_name,
     85                                            &ndr_table_initshutdown.syntax_id,
     86                                            &b);
    8687        if (!W_ERROR_IS_OK(werr)) {
    8788                goto done;
    8889        }
    8990
    90         status = rpccli_initshutdown_Abort(pipe_cli, talloc_tos(),
     91        status = dcerpc_initshutdown_Abort(b, talloc_tos(),
    9192                                           NULL,
    9293                                           &werr);
  • vendor/current/source3/lib/netapi/sid.c

    r414 r740  
    2121
    2222#include "lib/netapi/netapi.h"
     23#include "../libcli/security/security.h"
    2324
    2425/****************************************************************
  • vendor/current/source3/lib/netapi/user.c

    r594 r740  
    2424#include "lib/netapi/netapi_private.h"
    2525#include "lib/netapi/libnetapi.h"
    26 #include "../librpc/gen_ndr/cli_samr.h"
     26#include "../librpc/gen_ndr/ndr_samr_c.h"
     27#include "rpc_client/init_samr.h"
     28#include "../libds/common/flags.h"
     29#include "rpc_client/init_lsa.h"
     30#include "../libcli/security/security.h"
     31#include "../libds/common/flag_mapping.h"
     32#include "rpc_client/cli_pipe.h"
    2733
    2834/****************************************************************
     
    109115        info21->lm_owf_password         = zero_parameters;
    110116        info21->nt_owf_password         = zero_parameters;
    111         info21->unknown3.string         = NULL;
     117        info21->private_data.string     = NULL;
    112118        info21->buf_count               = 0;
    113119        info21->buffer                  = NULL;
     
    124130        info21->nt_password_set         = 0;
    125131        info21->password_expired        = infoX->usriX_password_expired;
    126         info21->unknown4                = 0;
     132        info21->private_data_sensitive  = 0;
    127133}
    128134
     
    293299        union samr_UserInfo user_info;
    294300        struct samr_UserInfo21 info21;
    295         NTSTATUS status;
     301        NTSTATUS status, result;
     302        struct dcerpc_binding_handle *b = pipe_cli->binding_handle;
    296303
    297304        if (!uX) {
     
    311318                                          &user_info.info25.password);
    312319
    313                 status = rpccli_samr_SetUserInfo2(pipe_cli, talloc_tos(),
     320                status = dcerpc_samr_SetUserInfo2(b, talloc_tos(),
    314321                                                  user_handle,
    315322                                                  25,
    316                                                   &user_info);
    317 
    318                 if (NT_STATUS_EQUAL(status, NT_STATUS(DCERPC_FAULT_INVALID_TAG))) {
     323                                                  &user_info,
     324                                                  &result);
     325                if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE)) {
    319326
    320327                        user_info.info23.info = info21;
     
    324331                                                &user_info.info23.password);
    325332
    326                         status = rpccli_samr_SetUserInfo2(pipe_cli, talloc_tos(),
     333                        status = dcerpc_samr_SetUserInfo2(b, talloc_tos(),
    327334                                                          user_handle,
    328335                                                          23,
    329                                                           &user_info);
     336                                                          &user_info,
     337                                                          &result);
     338                        if (!NT_STATUS_IS_OK(status)) {
     339                                return status;
     340                        }
     341                }
     342
     343                if (!NT_STATUS_IS_OK(status)) {
     344                        return status;
    330345                }
    331346        } else {
     
    333348                user_info.info21 = info21;
    334349
    335                 status = rpccli_samr_SetUserInfo(pipe_cli, talloc_tos(),
     350                status = dcerpc_samr_SetUserInfo(b, talloc_tos(),
    336351                                                 user_handle,
    337352                                                 21,
    338                                                  &user_info);
    339         }
    340 
    341         return status;
     353                                                 &user_info,
     354                                                 &result);
     355                if (!NT_STATUS_IS_OK(status)) {
     356                        return status;
     357                }
     358        }
     359
     360        return result;
    342361}
    343362
     
    349368{
    350369        struct rpc_pipe_client *pipe_cli = NULL;
    351         NTSTATUS status;
     370        NTSTATUS status, result;
    352371        WERROR werr;
    353372        struct policy_handle connect_handle, domain_handle, user_handle;
     
    359378        uint32_t rid = 0;
    360379        struct USER_INFO_X uX;
     380        struct dcerpc_binding_handle *b = NULL;
     381        DATA_BLOB session_key;
    361382
    362383        ZERO_STRUCT(connect_handle);
     
    385406                goto done;
    386407        }
     408
     409        b = pipe_cli->binding_handle;
    387410
    388411        status = construct_USER_INFO_X(r->in.level, r->in.buffer, &uX);
     
    407430        init_lsa_String(&lsa_account_name, uX.usriX_name);
    408431
    409         status = rpccli_samr_CreateUser2(pipe_cli, talloc_tos(),
     432        status = dcerpc_samr_CreateUser2(b, talloc_tos(),
    410433                                         &domain_handle,
    411434                                         &lsa_account_name,
     
    418441                                         &user_handle,
    419442                                         &access_granted,
    420                                          &rid);
     443                                         &rid,
     444                                         &result);
    421445        if (!NT_STATUS_IS_OK(status)) {
    422446                werr = ntstatus_to_werror(status);
    423447                goto done;
    424448        }
    425 
    426         status = rpccli_samr_QueryUserInfo(pipe_cli, talloc_tos(),
     449        if (!NT_STATUS_IS_OK(result)) {
     450                werr = ntstatus_to_werror(result);
     451                goto done;
     452        }
     453
     454        status = dcerpc_samr_QueryUserInfo(b, talloc_tos(),
    427455                                           &user_handle,
    428456                                           16,
    429                                            &user_info);
     457                                           &user_info,
     458                                           &result);
    430459        if (!NT_STATUS_IS_OK(status)) {
    431460                werr = ntstatus_to_werror(status);
     461                goto done;
     462        }
     463        if (!NT_STATUS_IS_OK(result)) {
     464                werr = ntstatus_to_werror(result);
    432465                goto done;
    433466        }
     
    438471        }
    439472
    440         status = rpccli_samr_GetUserPwInfo(pipe_cli, talloc_tos(),
     473        status = dcerpc_samr_GetUserPwInfo(b, talloc_tos(),
    441474                                           &user_handle,
    442                                            &pw_info);
     475                                           &pw_info,
     476                                           &result);
    443477        if (!NT_STATUS_IS_OK(status)) {
    444478                werr = ntstatus_to_werror(status);
    445479                goto done;
    446480        }
     481        if (!NT_STATUS_IS_OK(result)) {
     482                werr = ntstatus_to_werror(result);
     483                goto done;
     484        }
     485
     486        status = cli_get_session_key(talloc_tos(), pipe_cli, &session_key);
     487        if (!NT_STATUS_IS_OK(status)) {
     488                werr = ntstatus_to_werror(status);
     489                goto done;
     490        }
    447491
    448492        uX.usriX_flags |= ACB_NORMAL;
    449493
    450494        status = set_user_info_USER_INFO_X(ctx, pipe_cli,
    451                                            &pipe_cli->auth->user_session_key,
     495                                           &session_key,
    452496                                           &user_handle,
    453497                                           &uX);
     
    461505
    462506 failed:
    463         rpccli_samr_DeleteUser(pipe_cli, talloc_tos(),
    464                                &user_handle);
     507        dcerpc_samr_DeleteUser(b, talloc_tos(),
     508                               &user_handle,
     509                               &result);
    465510
    466511 done:
    467         if (is_valid_policy_hnd(&user_handle) && pipe_cli) {
    468                 rpccli_samr_Close(pipe_cli, talloc_tos(), &user_handle);
     512        if (is_valid_policy_hnd(&user_handle) && b) {
     513                dcerpc_samr_Close(b, talloc_tos(), &user_handle, &result);
    469514        }
    470515
     
    493538{
    494539        struct rpc_pipe_client *pipe_cli = NULL;
    495         NTSTATUS status;
     540        NTSTATUS status, result;
    496541        WERROR werr;
    497542        struct policy_handle connect_handle, builtin_handle, domain_handle, user_handle;
     
    500545        struct dom_sid2 *domain_sid = NULL;
    501546        struct dom_sid2 user_sid;
     547        struct dcerpc_binding_handle *b = NULL;
    502548
    503549        ZERO_STRUCT(connect_handle);
     
    513559                goto done;
    514560        }
     561
     562        b = pipe_cli->binding_handle;
    515563
    516564        werr = libnetapi_samr_open_domain(ctx, pipe_cli,
     
    525573        }
    526574
    527         status = rpccli_samr_OpenDomain(pipe_cli, talloc_tos(),
     575        status = dcerpc_samr_OpenDomain(b, talloc_tos(),
    528576                                        &connect_handle,
    529577                                        SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
    530                                         CONST_DISCARD(DOM_SID *, &global_sid_Builtin),
    531                                         &builtin_handle);
     578                                        CONST_DISCARD(struct dom_sid *, &global_sid_Builtin),
     579                                        &builtin_handle,
     580                                        &result);
    532581        if (!NT_STATUS_IS_OK(status)) {
    533582                werr = ntstatus_to_werror(status);
    534583                goto done;
    535584        }
     585        if (!NT_STATUS_IS_OK(result)) {
     586                werr = ntstatus_to_werror(result);
     587                goto done;
     588        }
    536589
    537590        init_lsa_String(&lsa_account_name, r->in.user_name);
    538591
    539         status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),
     592        status = dcerpc_samr_LookupNames(b, talloc_tos(),
    540593                                         &domain_handle,
    541594                                         1,
    542595                                         &lsa_account_name,
    543596                                         &user_rids,
    544                                          &name_types);
     597                                         &name_types,
     598                                         &result);
    545599        if (!NT_STATUS_IS_OK(status)) {
    546600                werr = ntstatus_to_werror(status);
    547601                goto done;
    548602        }
    549 
    550         status = rpccli_samr_OpenUser(pipe_cli, talloc_tos(),
     603        if (!NT_STATUS_IS_OK(result)) {
     604                werr = ntstatus_to_werror(result);
     605                goto done;
     606        }
     607
     608        status = dcerpc_samr_OpenUser(b, talloc_tos(),
    551609                                      &domain_handle,
    552610                                      SEC_STD_DELETE,
    553611                                      user_rids.ids[0],
    554                                       &user_handle);
     612                                      &user_handle,
     613                                      &result);
    555614        if (!NT_STATUS_IS_OK(status)) {
    556615                werr = ntstatus_to_werror(status);
    557616                goto done;
    558617        }
     618        if (!NT_STATUS_IS_OK(result)) {
     619                werr = ntstatus_to_werror(result);
     620                goto done;
     621        }
    559622
    560623        sid_compose(&user_sid, domain_sid, user_rids.ids[0]);
    561624
    562         status = rpccli_samr_RemoveMemberFromForeignDomain(pipe_cli, talloc_tos(),
     625        status = dcerpc_samr_RemoveMemberFromForeignDomain(b, talloc_tos(),
    563626                                                           &builtin_handle,
    564                                                            &user_sid);
     627                                                           &user_sid,
     628                                                           &result);
    565629        if (!NT_STATUS_IS_OK(status)) {
    566630                werr = ntstatus_to_werror(status);
    567631                goto done;
    568632        }
    569 
    570         status = rpccli_samr_DeleteUser(pipe_cli, talloc_tos(),
    571                                         &user_handle);
     633        if (!NT_STATUS_IS_OK(result)) {
     634                werr = ntstatus_to_werror(result);
     635                goto done;
     636        }
     637
     638        status = dcerpc_samr_DeleteUser(b, talloc_tos(),
     639                                        &user_handle,
     640                                        &result);
    572641        if (!NT_STATUS_IS_OK(status)) {
    573642                werr = ntstatus_to_werror(status);
     643                goto done;
     644        }
     645        if (!NT_STATUS_IS_OK(result)) {
     646                werr = ntstatus_to_werror(result);
    574647                goto done;
    575648        }
     
    579652 done:
    580653        if (is_valid_policy_hnd(&user_handle)) {
    581                 rpccli_samr_Close(pipe_cli, talloc_tos(), &user_handle);
     654                dcerpc_samr_Close(b, talloc_tos(), &user_handle, &result);
    582655        }
    583656
     
    615688                                           uint32_t *auth_flag_p)
    616689{
    617         NTSTATUS status;
     690        NTSTATUS status, result;
    618691
    619692        struct policy_handle user_handle;
     
    623696                               SAMR_USER_ACCESS_GET_ATTRIBUTES |
    624697                               SAMR_USER_ACCESS_GET_NAME_ETC;
     698        struct dcerpc_binding_handle *b = pipe_cli->binding_handle;
    625699
    626700        ZERO_STRUCT(user_handle);
     
    653727        }
    654728
    655         status = rpccli_samr_OpenUser(pipe_cli, mem_ctx,
     729        status = dcerpc_samr_OpenUser(b, mem_ctx,
    656730                                      domain_handle,
    657731                                      access_mask,
    658732                                      rid,
    659                                       &user_handle);
    660         if (!NT_STATUS_IS_OK(status)) {
    661                 goto done;
    662         }
    663 
    664         status = rpccli_samr_QueryUserInfo(pipe_cli, mem_ctx,
     733                                      &user_handle,
     734                                      &result);
     735        if (!NT_STATUS_IS_OK(status)) {
     736                goto done;
     737        }
     738        if (!NT_STATUS_IS_OK(result)) {
     739                status = result;
     740                goto done;
     741        }
     742
     743        status = dcerpc_samr_QueryUserInfo(b, mem_ctx,
    665744                                           &user_handle,
    666745                                           21,
    667                                            &user_info);
    668         if (!NT_STATUS_IS_OK(status)) {
    669                 goto done;
    670         }
    671 
    672         status = rpccli_samr_QuerySecurity(pipe_cli, mem_ctx,
     746                                           &user_info,
     747                                           &result);
     748        if (!NT_STATUS_IS_OK(status)) {
     749                goto done;
     750        }
     751        if (!NT_STATUS_IS_OK(result)) {
     752                status = result;
     753                goto done;
     754        }
     755
     756        status = dcerpc_samr_QuerySecurity(b, mem_ctx,
    673757                                           &user_handle,
    674758                                           SECINFO_DACL,
    675                                            sec_desc);
    676         if (!NT_STATUS_IS_OK(status)) {
     759                                           sec_desc,
     760                                           &result);
     761        if (!NT_STATUS_IS_OK(status)) {
     762                goto done;
     763        }
     764        if (!NT_STATUS_IS_OK(result)) {
     765                status = result;
    677766                goto done;
    678767        }
     
    686775                struct dom_sid sid;
    687776
    688                 status = rpccli_samr_GetGroupsForUser(pipe_cli, mem_ctx,
     777                status = dcerpc_samr_GetGroupsForUser(b, mem_ctx,
    689778                                                      &user_handle,
    690                                                       &rid_array);
     779                                                      &rid_array,
     780                                                      &result);
    691781                if (!NT_STATUS_IS_OK(status)) {
     782                        goto done;
     783                }
     784                if (!NT_STATUS_IS_OK(result)) {
     785                        status = result;
    692786                        goto done;
    693787                }
     
    700794                for (i=0; i<rid_array->count; i++) {
    701795                        sid_compose(&sid, domain_sid, rid_array->rids[i].rid);
    702                         sid_array.sids[i].sid = sid_dup_talloc(mem_ctx, &sid);
     796                        sid_array.sids[i].sid = dom_sid_dup(mem_ctx, &sid);
    703797                        NT_STATUS_HAVE_NO_MEMORY(sid_array.sids[i].sid);
    704798                }
    705799
    706800                sid_compose(&sid, domain_sid, rid);
    707                 sid_array.sids[i].sid = sid_dup_talloc(mem_ctx, &sid);
     801                sid_array.sids[i].sid = dom_sid_dup(mem_ctx, &sid);
    708802                NT_STATUS_HAVE_NO_MEMORY(sid_array.sids[i].sid);
    709803
    710                 status = rpccli_samr_GetAliasMembership(pipe_cli, mem_ctx,
     804                status = dcerpc_samr_GetAliasMembership(b, mem_ctx,
    711805                                                        builtin_handle,
    712806                                                        &sid_array,
    713                                                         &alias_rids);
     807                                                        &alias_rids,
     808                                                        &result);
    714809                if (!NT_STATUS_IS_OK(status)) {
     810                        goto done;
     811                }
     812                if (!NT_STATUS_IS_OK(result)) {
     813                        status = result;
    715814                        goto done;
    716815                }
     
    741840 done:
    742841        if (is_valid_policy_hnd(&user_handle)) {
    743                 rpccli_samr_Close(pipe_cli, mem_ctx, &user_handle);
     842                dcerpc_samr_Close(b, mem_ctx, &user_handle, &result);
    744843        }
    745844
     
    9181017                return NT_STATUS_NO_MEMORY;
    9191018        }
    920         i->usri4_user_sid       = (struct domsid *)sid_dup_talloc(mem_ctx, &sid);
     1019        i->usri4_user_sid       = (struct domsid *)dom_sid_dup(mem_ctx, &sid);
    9211020        i->usri4_primary_group_id = i21->primary_gid;
    9221021        i->usri4_profile        = talloc_strdup(mem_ctx, i21->profile_path.string);
     
    10191118                return NT_STATUS_NO_MEMORY;
    10201119        }
    1021         i->usri23_user_sid      = (struct domsid *)sid_dup_talloc(mem_ctx, &sid);
     1120        i->usri23_user_sid      = (struct domsid *)dom_sid_dup(mem_ctx, &sid);
    10221121
    10231122        return NT_STATUS_OK;
     
    11851284
    11861285        NTSTATUS status = NT_STATUS_OK;
     1286        NTSTATUS result = NT_STATUS_OK;
    11871287        WERROR werr;
     1288        struct dcerpc_binding_handle *b = NULL;
    11881289
    11891290        ZERO_STRUCT(connect_handle);
     
    12201321        }
    12211322
     1323        b = pipe_cli->binding_handle;
     1324
    12221325        werr = libnetapi_samr_open_builtin_domain(ctx, pipe_cli,
    12231326                                                  SAMR_ACCESS_ENUM_DOMAINS |
     
    12641367        }
    12651368
    1266         status = rpccli_samr_EnumDomainUsers(pipe_cli,
     1369        status = dcerpc_samr_EnumDomainUsers(b,
    12671370                                             ctx,
    12681371                                             &domain_handle,
     
    12711374                                             &sam,
    12721375                                             r->in.prefmaxlen,
    1273                                              &entries_read);
    1274         werr = ntstatus_to_werror(status);
    1275         if (NT_STATUS_IS_ERR(status)) {
     1376                                             &entries_read,
     1377                                             &result);
     1378        if (!NT_STATUS_IS_OK(status)) {
     1379                werr = ntstatus_to_werror(status);
     1380                goto done;
     1381        }
     1382        werr = ntstatus_to_werror(result);
     1383        if (NT_STATUS_IS_ERR(result)) {
    12761384                goto done;
    12771385        }
     
    12961404 done:
    12971405        /* if last query */
    1298         if (NT_STATUS_IS_OK(status) ||
    1299             NT_STATUS_IS_ERR(status)) {
     1406        if (NT_STATUS_IS_OK(result) ||
     1407            NT_STATUS_IS_ERR(result)) {
    13001408
    13011409                if (ctx->disable_policy_handle_cache) {
     
    14901598        struct policy_handle domain_handle;
    14911599        union samr_DispInfo info;
     1600        struct dcerpc_binding_handle *b = NULL;
    14921601
    14931602        uint32_t total_size = 0;
     
    14951604
    14961605        NTSTATUS status = NT_STATUS_OK;
     1606        NTSTATUS result = NT_STATUS_OK;
    14971607        WERROR werr;
    14981608        WERROR werr_tmp;
     
    15181628                goto done;
    15191629        }
     1630
     1631        b = pipe_cli->binding_handle;
    15201632
    15211633        werr = libnetapi_samr_open_domain(ctx, pipe_cli,
     
    15321644        }
    15331645
    1534         status = rpccli_samr_QueryDisplayInfo2(pipe_cli,
     1646        status = dcerpc_samr_QueryDisplayInfo2(b,
    15351647                                               ctx,
    15361648                                               &domain_handle,
     
    15411653                                               &total_size,
    15421654                                               &returned_size,
    1543                                                &info);
    1544         werr = ntstatus_to_werror(status);
    1545         if (NT_STATUS_IS_ERR(status)) {
     1655                                               &info,
     1656                                               &result);
     1657        if (!NT_STATUS_IS_OK(status)) {
     1658                werr = ntstatus_to_werror(status);
     1659                goto done;
     1660        }
     1661        werr = ntstatus_to_werror(result);
     1662        if (NT_STATUS_IS_ERR(result)) {
    15461663                goto done;
    15471664        }
     
    15561673 done:
    15571674        /* if last query */
    1558         if (NT_STATUS_IS_OK(status) ||
    1559             NT_STATUS_IS_ERR(status)) {
     1675        if (NT_STATUS_IS_OK(result) ||
     1676            NT_STATUS_IS_ERR(result)) {
    15601677
    15611678                if (ctx->disable_policy_handle_cache) {
     
    16041721{
    16051722        struct rpc_pipe_client *pipe_cli = NULL;
    1606         NTSTATUS status;
     1723        NTSTATUS status, result;
    16071724        WERROR werr;
    16081725
     
    16121729        struct samr_Ids user_rids, name_types;
    16131730        uint32_t num_entries = 0;
     1731        struct dcerpc_binding_handle *b = NULL;
    16141732
    16151733        ZERO_STRUCT(connect_handle);
     
    16451763        }
    16461764
     1765        b = pipe_cli->binding_handle;
     1766
    16471767        werr = libnetapi_samr_open_domain(ctx, pipe_cli,
    16481768                                          SAMR_ACCESS_ENUM_DOMAINS |
     
    16691789        init_lsa_String(&lsa_account_name, r->in.user_name);
    16701790
    1671         status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),
     1791        status = dcerpc_samr_LookupNames(b, talloc_tos(),
    16721792                                         &domain_handle,
    16731793                                         1,
    16741794                                         &lsa_account_name,
    16751795                                         &user_rids,
    1676                                          &name_types);
     1796                                         &name_types,
     1797                                         &result);
    16771798        if (!NT_STATUS_IS_OK(status)) {
    16781799                werr = ntstatus_to_werror(status);
     1800                goto done;
     1801        }
     1802        if (!NT_STATUS_IS_OK(result)) {
     1803                werr = ntstatus_to_werror(result);
    16791804                goto done;
    16801805        }
     
    16951820
    16961821 done:
    1697         if (is_valid_policy_hnd(&user_handle) && pipe_cli) {
    1698                 rpccli_samr_Close(pipe_cli, talloc_tos(), &user_handle);
     1822        if (is_valid_policy_hnd(&user_handle) && b) {
     1823                dcerpc_samr_Close(b, talloc_tos(), &user_handle, &result);
    16991824        }
    17001825
     
    17231848{
    17241849        struct rpc_pipe_client *pipe_cli = NULL;
    1725         NTSTATUS status;
     1850        NTSTATUS status, result;
    17261851        WERROR werr;
    17271852
     
    17331858
    17341859        struct USER_INFO_X uX;
     1860        struct dcerpc_binding_handle *b = NULL;
     1861        DATA_BLOB session_key;
    17351862
    17361863        ZERO_STRUCT(connect_handle);
     
    17671894                        break;
    17681895                case 3:
    1769                         user_mask = STD_RIGHT_READ_CONTROL_ACCESS |
    1770                                     STD_RIGHT_WRITE_DAC_ACCESS |
     1896                        user_mask = SEC_STD_READ_CONTROL |
     1897                                    SEC_STD_WRITE_DAC |
    17711898                                    SAMR_USER_ACCESS_GET_GROUPS |
    17721899                                    SAMR_USER_ACCESS_SET_PASSWORD |
     
    17991926        }
    18001927
     1928        b = pipe_cli->binding_handle;
     1929
    18011930        werr = libnetapi_samr_open_domain(ctx, pipe_cli,
    18021931                                          SAMR_ACCESS_ENUM_DOMAINS |
     
    18241953        init_lsa_String(&lsa_account_name, r->in.user_name);
    18251954
    1826         status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),
     1955        status = dcerpc_samr_LookupNames(b, talloc_tos(),
    18271956                                         &domain_handle,
    18281957                                         1,
    18291958                                         &lsa_account_name,
    18301959                                         &user_rids,
    1831                                          &name_types);
     1960                                         &name_types,
     1961                                         &result);
    18321962        if (!NT_STATUS_IS_OK(status)) {
    18331963                werr = ntstatus_to_werror(status);
    18341964                goto done;
    18351965        }
    1836 
    1837         status = rpccli_samr_OpenUser(pipe_cli, talloc_tos(),
     1966        if (!NT_STATUS_IS_OK(result)) {
     1967                werr = ntstatus_to_werror(result);
     1968                goto done;
     1969        }
     1970
     1971        status = dcerpc_samr_OpenUser(b, talloc_tos(),
    18381972                                      &domain_handle,
    18391973                                      user_mask,
    18401974                                      user_rids.ids[0],
    1841                                       &user_handle);
     1975                                      &user_handle,
     1976                                      &result);
    18421977        if (!NT_STATUS_IS_OK(status)) {
    18431978                werr = ntstatus_to_werror(status);
    18441979                goto done;
    18451980        }
     1981        if (!NT_STATUS_IS_OK(result)) {
     1982                werr = ntstatus_to_werror(result);
     1983                goto done;
     1984        }
    18461985
    18471986        status = construct_USER_INFO_X(r->in.level, r->in.buffer, &uX);
     
    18511990        }
    18521991
     1992        status = cli_get_session_key(talloc_tos(), pipe_cli, &session_key);
     1993        if (!NT_STATUS_IS_OK(status)) {
     1994                werr = ntstatus_to_werror(status);
     1995                goto done;
     1996        }
     1997
    18531998        status = set_user_info_USER_INFO_X(ctx, pipe_cli,
    1854                                            &pipe_cli->auth->user_session_key,
     1999                                           &session_key,
    18552000                                           &user_handle,
    18562001                                           &uX);
     
    18632008
    18642009 done:
    1865         if (is_valid_policy_hnd(&user_handle) && pipe_cli) {
    1866                 rpccli_samr_Close(pipe_cli, talloc_tos(), &user_handle);
     2010        if (is_valid_policy_hnd(&user_handle) && b) {
     2011                dcerpc_samr_Close(b, talloc_tos(), &user_handle, &result);
    18672012        }
    18682013
     
    18982043                                           struct samr_DomInfo12 *info12)
    18992044{
    1900         NTSTATUS status;
     2045        NTSTATUS status, result;
    19012046        union samr_DomainInfo *dom_info = NULL;
     2047        struct dcerpc_binding_handle *b = pipe_cli->binding_handle;
    19022048
    19032049        if (info1) {
    1904                 status = rpccli_samr_QueryDomainInfo(pipe_cli, mem_ctx,
     2050                status = dcerpc_samr_QueryDomainInfo(b, mem_ctx,
    19052051                                                     domain_handle,
    19062052                                                     1,
    1907                                                      &dom_info);
     2053                                                     &dom_info,
     2054                                                     &result);
    19082055                NT_STATUS_NOT_OK_RETURN(status);
     2056                NT_STATUS_NOT_OK_RETURN(result);
    19092057
    19102058                *info1 = dom_info->info1;
     
    19122060
    19132061        if (info3) {
    1914                 status = rpccli_samr_QueryDomainInfo(pipe_cli, mem_ctx,
     2062                status = dcerpc_samr_QueryDomainInfo(b, mem_ctx,
    19152063                                                     domain_handle,
    19162064                                                     3,
    1917                                                      &dom_info);
     2065                                                     &dom_info,
     2066                                                     &result);
    19182067                NT_STATUS_NOT_OK_RETURN(status);
     2068                NT_STATUS_NOT_OK_RETURN(result);
    19192069
    19202070                *info3 = dom_info->info3;
     
    19222072
    19232073        if (info5) {
    1924                 status = rpccli_samr_QueryDomainInfo(pipe_cli, mem_ctx,
     2074                status = dcerpc_samr_QueryDomainInfo(b, mem_ctx,
    19252075                                                     domain_handle,
    19262076                                                     5,
    1927                                                      &dom_info);
     2077                                                     &dom_info,
     2078                                                     &result);
    19282079                NT_STATUS_NOT_OK_RETURN(status);
     2080                NT_STATUS_NOT_OK_RETURN(result);
    19292081
    19302082                *info5 = dom_info->info5;
     
    19322084
    19332085        if (info6) {
    1934                 status = rpccli_samr_QueryDomainInfo(pipe_cli, mem_ctx,
     2086                status = dcerpc_samr_QueryDomainInfo(b, mem_ctx,
    19352087                                                     domain_handle,
    19362088                                                     6,
    1937                                                      &dom_info);
     2089                                                     &dom_info,
     2090                                                     &result);
    19382091                NT_STATUS_NOT_OK_RETURN(status);
     2092                NT_STATUS_NOT_OK_RETURN(result);
    19392093
    19402094                *info6 = dom_info->info6;
     
    19422096
    19432097        if (info7) {
    1944                 status = rpccli_samr_QueryDomainInfo(pipe_cli, mem_ctx,
     2098                status = dcerpc_samr_QueryDomainInfo(b, mem_ctx,
    19452099                                                     domain_handle,
    19462100                                                     7,
    1947                                                      &dom_info);
     2101                                                     &dom_info,
     2102                                                     &result);
    19482103                NT_STATUS_NOT_OK_RETURN(status);
     2104                NT_STATUS_NOT_OK_RETURN(result);
    19492105
    19502106                *info7 = dom_info->info7;
     
    19522108
    19532109        if (info12) {
    1954                 status = rpccli_samr_QueryDomainInfo2(pipe_cli, mem_ctx,
     2110                status = dcerpc_samr_QueryDomainInfo2(b, mem_ctx,
    19552111                                                      domain_handle,
    19562112                                                      12,
    1957                                                       &dom_info);
     2113                                                      &dom_info,
     2114                                                      &result);
    19582115                NT_STATUS_NOT_OK_RETURN(status);
     2116                NT_STATUS_NOT_OK_RETURN(result);
    19592117
    19602118                *info12 = dom_info->info12;
     
    20612219                talloc_strdup(mem_ctx, dom_info5.domain_name.string);
    20622220        info2->usrmod2_domain_id =
    2063                 (struct domsid *)sid_dup_talloc(mem_ctx, domain_sid);
     2221                (struct domsid *)dom_sid_dup(mem_ctx, domain_sid);
    20642222
    20652223        NT_STATUS_HAVE_NO_MEMORY(info2->usrmod2_domain_name);
     
    22742432                                         struct samr_DomInfo12 *info12)
    22752433{
    2276         NTSTATUS status;
     2434        NTSTATUS status, result;
    22772435        union samr_DomainInfo dom_info;
     2436        struct dcerpc_binding_handle *b = pipe_cli->binding_handle;
    22782437
    22792438        if (info1) {
     
    22832442                dom_info.info1 = *info1;
    22842443
    2285                 status = rpccli_samr_SetDomainInfo(pipe_cli, mem_ctx,
     2444                status = dcerpc_samr_SetDomainInfo(b, mem_ctx,
    22862445                                                   domain_handle,
    22872446                                                   1,
    2288                                                    &dom_info);
     2447                                                   &dom_info,
     2448                                                   &result);
    22892449                NT_STATUS_NOT_OK_RETURN(status);
     2450                NT_STATUS_NOT_OK_RETURN(result);
    22902451        }
    22912452
     
    22962457                dom_info.info3 = *info3;
    22972458
    2298                 status = rpccli_samr_SetDomainInfo(pipe_cli, mem_ctx,
     2459                status = dcerpc_samr_SetDomainInfo(b, mem_ctx,
    22992460                                                   domain_handle,
    23002461                                                   3,
    2301                                                    &dom_info);
     2462                                                   &dom_info,
     2463                                                   &result);
    23022464
    23032465                NT_STATUS_NOT_OK_RETURN(status);
     2466                NT_STATUS_NOT_OK_RETURN(result);
    23042467        }
    23052468
     
    23102473                dom_info.info12 = *info12;
    23112474
    2312                 status = rpccli_samr_SetDomainInfo(pipe_cli, mem_ctx,
     2475                status = dcerpc_samr_SetDomainInfo(b, mem_ctx,
    23132476                                                   domain_handle,
    23142477                                                   12,
    2315                                                    &dom_info);
     2478                                                   &dom_info,
     2479                                                   &result);
    23162480
    23172481                NT_STATUS_NOT_OK_RETURN(status);
     2482                NT_STATUS_NOT_OK_RETURN(result);
    23182483        }
    23192484
     
    28022967
    28032968        NTSTATUS status = NT_STATUS_OK;
     2969        NTSTATUS result = NT_STATUS_OK;
    28042970        WERROR werr;
     2971        struct dcerpc_binding_handle *b = NULL;
    28052972
    28062973        ZERO_STRUCT(connect_handle);
     
    28292996                goto done;
    28302997        }
     2998
     2999        b = pipe_cli->binding_handle;
    28313000
    28323001        werr = libnetapi_samr_open_domain(ctx, pipe_cli,
     
    28433012        init_lsa_String(&lsa_account_name, r->in.user_name);
    28443013
    2845         status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),
     3014        status = dcerpc_samr_LookupNames(b, talloc_tos(),
    28463015                                         &domain_handle,
    28473016                                         1,
    28483017                                         &lsa_account_name,
    28493018                                         &user_rids,
    2850                                          &name_types);
     3019                                         &name_types,
     3020                                         &result);
    28513021        if (!NT_STATUS_IS_OK(status)) {
    28523022                werr = ntstatus_to_werror(status);
    28533023                goto done;
    28543024        }
    2855 
    2856         status = rpccli_samr_OpenUser(pipe_cli, talloc_tos(),
     3025        if (!NT_STATUS_IS_OK(result)) {
     3026                werr = ntstatus_to_werror(result);
     3027                goto done;
     3028        }
     3029
     3030        status = dcerpc_samr_OpenUser(b, talloc_tos(),
    28573031                                      &domain_handle,
    28583032                                      SAMR_USER_ACCESS_GET_GROUPS,
    28593033                                      user_rids.ids[0],
    2860                                       &user_handle);
     3034                                      &user_handle,
     3035                                      &result);
    28613036        if (!NT_STATUS_IS_OK(status)) {
    28623037                werr = ntstatus_to_werror(status);
    28633038                goto done;
    28643039        }
    2865 
    2866         status = rpccli_samr_GetGroupsForUser(pipe_cli, talloc_tos(),
     3040        if (!NT_STATUS_IS_OK(result)) {
     3041                werr = ntstatus_to_werror(result);
     3042                goto done;
     3043        }
     3044
     3045        status = dcerpc_samr_GetGroupsForUser(b, talloc_tos(),
    28673046                                              &user_handle,
    2868                                               &rid_array);
     3047                                              &rid_array,
     3048                                              &result);
    28693049        if (!NT_STATUS_IS_OK(status)) {
    28703050                werr = ntstatus_to_werror(status);
     3051                goto done;
     3052        }
     3053        if (!NT_STATUS_IS_OK(result)) {
     3054                werr = ntstatus_to_werror(result);
    28713055                goto done;
    28723056        }
     
    28823066        }
    28833067
    2884         status = rpccli_samr_LookupRids(pipe_cli, talloc_tos(),
     3068        status = dcerpc_samr_LookupRids(b, talloc_tos(),
    28853069                                        &domain_handle,
    28863070                                        rid_array->count,
    28873071                                        rids,
    28883072                                        &names,
    2889                                         &types);
    2890         if (!NT_STATUS_IS_OK(status) &&
    2891             !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) {
     3073                                        &types,
     3074                                        &result);
     3075        if (!NT_STATUS_IS_OK(status)) {
    28923076                werr = ntstatus_to_werror(status);
     3077                goto done;
     3078        }
     3079        if (!NT_STATUS_IS_OK(result) &&
     3080            !NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED)) {
     3081                werr = ntstatus_to_werror(result);
    28933082                goto done;
    28943083        }
     
    29573146
    29583147        NTSTATUS status = NT_STATUS_OK;
     3148        NTSTATUS result = NT_STATUS_OK;
    29593149        WERROR werr;
     3150        struct dcerpc_binding_handle *b = NULL;
    29603151
    29613152        ZERO_STRUCT(connect_handle);
     
    29803171                goto done;
    29813172        }
     3173
     3174        b = pipe_cli->binding_handle;
    29823175
    29833176        werr = libnetapi_samr_open_domain(ctx, pipe_cli,
     
    29943187        init_lsa_String(&lsa_account_name, r->in.user_name);
    29953188
    2996         status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),
     3189        status = dcerpc_samr_LookupNames(b, talloc_tos(),
    29973190                                         &domain_handle,
    29983191                                         1,
    29993192                                         &lsa_account_name,
    30003193                                         &user_rids,
    3001                                          &name_types);
     3194                                         &name_types,
     3195                                         &result);
    30023196        if (!NT_STATUS_IS_OK(status)) {
    30033197                werr = ntstatus_to_werror(status);
    30043198                goto done;
    30053199        }
    3006 
    3007         status = rpccli_samr_OpenUser(pipe_cli, talloc_tos(),
     3200        if (!NT_STATUS_IS_OK(result)) {
     3201                werr = ntstatus_to_werror(result);
     3202                goto done;
     3203        }
     3204
     3205        status = dcerpc_samr_OpenUser(b, talloc_tos(),
    30083206                                      &domain_handle,
    30093207                                      SAMR_USER_ACCESS_GET_GROUPS,
    30103208                                      user_rids.ids[0],
    3011                                       &user_handle);
     3209                                      &user_handle,
     3210                                      &result);
    30123211        if (!NT_STATUS_IS_OK(status)) {
    30133212                werr = ntstatus_to_werror(status);
     3213                goto done;
     3214        }
     3215        if (!NT_STATUS_IS_OK(result)) {
     3216                werr = ntstatus_to_werror(result);
    30143217                goto done;
    30153218        }
     
    30443247        }
    30453248
    3046         status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),
     3249        status = dcerpc_samr_LookupNames(b, talloc_tos(),
    30473250                                         &domain_handle,
    30483251                                         r->in.num_entries,
    30493252                                         lsa_names,
    30503253                                         &group_rids,
    3051                                          &name_types);
     3254                                         &name_types,
     3255                                         &result);
    30523256        if (!NT_STATUS_IS_OK(status)) {
    30533257                werr = ntstatus_to_werror(status);
     3258                goto done;
     3259        }
     3260        if (!NT_STATUS_IS_OK(result)) {
     3261                werr = ntstatus_to_werror(result);
    30543262                goto done;
    30553263        }
     
    30583266        num_member_rids = group_rids.count;
    30593267
    3060         status = rpccli_samr_GetGroupsForUser(pipe_cli, talloc_tos(),
     3268        status = dcerpc_samr_GetGroupsForUser(b, talloc_tos(),
    30613269                                              &user_handle,
    3062                                               &rid_array);
     3270                                              &rid_array,
     3271                                              &result);
    30633272        if (!NT_STATUS_IS_OK(status)) {
    30643273                werr = ntstatus_to_werror(status);
     3274                goto done;
     3275        }
     3276        if (!NT_STATUS_IS_OK(result)) {
     3277                werr = ntstatus_to_werror(result);
    30653278                goto done;
    30663279        }
     
    31093322
    31103323        for (i=0; i < num_add_rids; i++) {
    3111                 status = rpccli_samr_OpenGroup(pipe_cli, talloc_tos(),
     3324                status = dcerpc_samr_OpenGroup(b, talloc_tos(),
    31123325                                               &domain_handle,
    31133326                                               SAMR_GROUP_ACCESS_ADD_MEMBER,
    31143327                                               add_rids[i],
    3115                                                &group_handle);
     3328                                               &group_handle,
     3329                                               &result);
    31163330                if (!NT_STATUS_IS_OK(status)) {
    31173331                        werr = ntstatus_to_werror(status);
    31183332                        goto done;
    31193333                }
    3120 
    3121                 status = rpccli_samr_AddGroupMember(pipe_cli, talloc_tos(),
     3334                if (!NT_STATUS_IS_OK(result)) {
     3335                        werr = ntstatus_to_werror(result);
     3336                        goto done;
     3337                }
     3338
     3339                status = dcerpc_samr_AddGroupMember(b, talloc_tos(),
    31223340                                                    &group_handle,
    31233341                                                    user_rids.ids[0],
    3124                                                     7 /* ? */);
     3342                                                    7 /* ? */,
     3343                                                    &result);
    31253344                if (!NT_STATUS_IS_OK(status)) {
    31263345                        werr = ntstatus_to_werror(status);
    31273346                        goto done;
    31283347                }
     3348                if (!NT_STATUS_IS_OK(result)) {
     3349                        werr = ntstatus_to_werror(result);
     3350                        goto done;
     3351                }
    31293352
    31303353                if (is_valid_policy_hnd(&group_handle)) {
    3131                         rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);
     3354                        dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result);
    31323355                }
    31333356        }
     
    31363359
    31373360        for (i=0; i < num_del_rids; i++) {
    3138                 status = rpccli_samr_OpenGroup(pipe_cli, talloc_tos(),
     3361                status = dcerpc_samr_OpenGroup(b, talloc_tos(),
    31393362                                               &domain_handle,
    31403363                                               SAMR_GROUP_ACCESS_REMOVE_MEMBER,
    31413364                                               del_rids[i],
    3142                                                &group_handle);
     3365                                               &group_handle,
     3366                                               &result);
    31433367                if (!NT_STATUS_IS_OK(status)) {
    31443368                        werr = ntstatus_to_werror(status);
    31453369                        goto done;
    31463370                }
    3147 
    3148                 status = rpccli_samr_DeleteGroupMember(pipe_cli, talloc_tos(),
     3371                if (!NT_STATUS_IS_OK(result)) {
     3372                        werr = ntstatus_to_werror(result);
     3373                        goto done;
     3374                }
     3375
     3376                status = dcerpc_samr_DeleteGroupMember(b, talloc_tos(),
    31493377                                                       &group_handle,
    3150                                                        user_rids.ids[0]);
     3378                                                       user_rids.ids[0],
     3379                                                       &result);
    31513380                if (!NT_STATUS_IS_OK(status)) {
    31523381                        werr = ntstatus_to_werror(status);
    31533382                        goto done;
    31543383                }
     3384                if (!NT_STATUS_IS_OK(result)) {
     3385                        werr = ntstatus_to_werror(result);
     3386                        goto done;
     3387                }
    31553388
    31563389                if (is_valid_policy_hnd(&group_handle)) {
    3157                         rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);
     3390                        dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result);
    31583391                }
    31593392        }
     
    31633396 done:
    31643397        if (is_valid_policy_hnd(&group_handle)) {
    3165                 rpccli_samr_Close(pipe_cli, talloc_tos(), &group_handle);
     3398                dcerpc_samr_Close(b, talloc_tos(), &group_handle, &result);
    31663399        }
    31673400
     
    32353468
    32363469        NTSTATUS status = NT_STATUS_OK;
     3470        NTSTATUS result = NT_STATUS_OK;
    32373471        WERROR werr;
     3472        struct dcerpc_binding_handle *b = NULL;
    32383473
    32393474        ZERO_STRUCT(connect_handle);
     
    32623497                goto done;
    32633498        }
     3499
     3500        b = pipe_cli->binding_handle;
    32643501
    32653502        werr = libnetapi_samr_open_domain(ctx, pipe_cli,
     
    32883525        init_lsa_String(&lsa_account_name, r->in.user_name);
    32893526
    3290         status = rpccli_samr_LookupNames(pipe_cli, talloc_tos(),
     3527        status = dcerpc_samr_LookupNames(b, talloc_tos(),
    32913528                                         &domain_handle,
    32923529                                         1,
    32933530                                         &lsa_account_name,
    32943531                                         &user_rids,
    3295                                          &name_types);
     3532                                         &name_types,
     3533                                         &result);
    32963534        if (!NT_STATUS_IS_OK(status)) {
    32973535                werr = ntstatus_to_werror(status);
    32983536                goto done;
    32993537        }
    3300 
    3301         status = rpccli_samr_OpenUser(pipe_cli, talloc_tos(),
     3538        if (!NT_STATUS_IS_OK(result)) {
     3539                werr = ntstatus_to_werror(result);
     3540                goto done;
     3541        }
     3542
     3543        status = dcerpc_samr_OpenUser(b, talloc_tos(),
    33023544                                      &domain_handle,
    33033545                                      SAMR_USER_ACCESS_GET_GROUPS,
    33043546                                      user_rids.ids[0],
    3305                                       &user_handle);
     3547                                      &user_handle,
     3548                                      &result);
    33063549        if (!NT_STATUS_IS_OK(status)) {
    33073550                werr = ntstatus_to_werror(status);
    33083551                goto done;
    33093552        }
    3310 
    3311         status = rpccli_samr_GetGroupsForUser(pipe_cli, talloc_tos(),
     3553        if (!NT_STATUS_IS_OK(result)) {
     3554                werr = ntstatus_to_werror(result);
     3555                goto done;
     3556        }
     3557
     3558        status = dcerpc_samr_GetGroupsForUser(b, talloc_tos(),
    33123559                                              &user_handle,
    3313                                               &rid_array);
     3560                                              &rid_array,
     3561                                              &result);
    33143562        if (!NT_STATUS_IS_OK(status)) {
    33153563                werr = ntstatus_to_werror(status);
     3564                goto done;
     3565        }
     3566        if (!NT_STATUS_IS_OK(result)) {
     3567                werr = ntstatus_to_werror(result);
    33163568                goto done;
    33173569        }
     
    33293581        }
    33303582
    3331         sid_array.sids[0].sid = sid_dup_talloc(ctx, &user_sid);
     3583        sid_array.sids[0].sid = dom_sid_dup(ctx, &user_sid);
    33323584        if (!sid_array.sids[0].sid) {
    33333585                werr = WERR_NOMEM;
     
    33433595                }
    33443596
    3345                 sid_array.sids[i+1].sid = sid_dup_talloc(ctx, &sid);
     3597                sid_array.sids[i+1].sid = dom_sid_dup(ctx, &sid);
    33463598                if (!sid_array.sids[i+1].sid) {
    33473599                        werr = WERR_NOMEM;
     
    33503602        }
    33513603
    3352         status = rpccli_samr_GetAliasMembership(pipe_cli, talloc_tos(),
     3604        status = dcerpc_samr_GetAliasMembership(b, talloc_tos(),
    33533605                                                &domain_handle,
    33543606                                                &sid_array,
    3355                                                 &domain_rids);
     3607                                                &domain_rids,
     3608                                                &result);
    33563609        if (!NT_STATUS_IS_OK(status)) {
    33573610                werr = ntstatus_to_werror(status);
     3611                goto done;
     3612        }
     3613        if (!NT_STATUS_IS_OK(result)) {
     3614                werr = ntstatus_to_werror(result);
    33583615                goto done;
    33593616        }
     
    33673624        }
    33683625
    3369         status = rpccli_samr_GetAliasMembership(pipe_cli, talloc_tos(),
     3626        status = dcerpc_samr_GetAliasMembership(b, talloc_tos(),
    33703627                                                &builtin_handle,
    33713628                                                &sid_array,
    3372                                                 &builtin_rids);
     3629                                                &builtin_rids,
     3630                                                &result);
    33733631        if (!NT_STATUS_IS_OK(status)) {
    33743632                werr = ntstatus_to_werror(status);
     3633                goto done;
     3634        }
     3635        if (!NT_STATUS_IS_OK(result)) {
     3636                werr = ntstatus_to_werror(result);
    33753637                goto done;
    33763638        }
     
    33843646        }
    33853647
    3386         status = rpccli_samr_LookupRids(pipe_cli, talloc_tos(),
     3648        status = dcerpc_samr_LookupRids(b, talloc_tos(),
    33873649                                        &builtin_handle,
    33883650                                        num_rids,
    33893651                                        rids,
    33903652                                        &names,
    3391                                         &types);
     3653                                        &types,
     3654                                        &result);
    33923655        if (!NT_STATUS_IS_OK(status)) {
    33933656                werr = ntstatus_to_werror(status);
     3657                goto done;
     3658        }
     3659        if (!NT_STATUS_IS_OK(result)) {
     3660                werr = ntstatus_to_werror(result);
    33943661                goto done;
    33953662        }
Note: See TracChangeset for help on using the changeset viewer.