Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/rpcclient/cmd_lsarpc.c

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