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_netlogon.c

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