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/libnet/libnet_join.c

    r599 r745  
    2020
    2121#include "includes.h"
    22 #include "libnet/libnet.h"
     22#include "ads.h"
     23#include "librpc/gen_ndr/ndr_libnet_join.h"
     24#include "libnet/libnet_join.h"
    2325#include "libcli/auth/libcli_auth.h"
    24 #include "../librpc/gen_ndr/cli_samr.h"
    25 #include "../librpc/gen_ndr/cli_lsa.h"
     26#include "../librpc/gen_ndr/ndr_samr_c.h"
     27#include "rpc_client/init_samr.h"
     28#include "../librpc/gen_ndr/ndr_lsa_c.h"
     29#include "rpc_client/cli_lsarpc.h"
     30#include "../librpc/gen_ndr/ndr_netlogon.h"
     31#include "rpc_client/cli_netlogon.h"
     32#include "lib/smbconf/smbconf.h"
     33#include "lib/smbconf/smbconf_reg.h"
     34#include "../libds/common/flags.h"
     35#include "secrets.h"
     36#include "rpc_client/init_lsa.h"
     37#include "rpc_client/cli_pipe.h"
     38#include "krb5_env.h"
     39#include "../libcli/security/security.h"
     40#include "passdb.h"
     41#include "libsmb/libsmb.h"
    2642
    2743/****************************************************************
     
    90106}
    91107
    92 #ifdef WITH_ADS
     108#ifdef HAVE_ADS
    93109
    94110/****************************************************************
     
    630646        return ADS_SUCCESS;
    631647}
    632 #endif /* WITH_ADS */
     648#endif /* HAVE_ADS */
    633649
    634650/****************************************************************
     
    685701                                   pass,
    686702                                   flags,
    687                                    Undefined, NULL);
     703                                   Undefined);
    688704}
    689705
     
    698714        struct rpc_pipe_client *pipe_hnd = NULL;
    699715        struct policy_handle lsa_pol;
    700         NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
     716        NTSTATUS status, result;
    701717        union lsa_PolicyInformation *info = NULL;
     718        struct dcerpc_binding_handle *b;
    702719
    703720        status = libnet_join_connect_dc_ipc(r->in.dc_name,
     
    718735        }
    719736
     737        b = pipe_hnd->binding_handle;
     738
    720739        status = rpccli_lsa_open_policy(pipe_hnd, mem_ctx, true,
    721740                                        SEC_FLAG_MAXIMUM_ALLOWED, &lsa_pol);
     
    724743        }
    725744
    726         status = rpccli_lsa_QueryInfoPolicy2(pipe_hnd, mem_ctx,
     745        status = dcerpc_lsa_QueryInfoPolicy2(b, mem_ctx,
    727746                                             &lsa_pol,
    728747                                             LSA_POLICY_INFO_DNS,
    729                                              &info);
    730         if (NT_STATUS_IS_OK(status)) {
     748                                             &info,
     749                                             &result);
     750        if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(result)) {
    731751                r->out.domain_is_ad = true;
    732752                r->out.netbios_domain_name = info->dns.name.string;
    733753                r->out.dns_domain_name = info->dns.dns_domain.string;
    734754                r->out.forest_name = info->dns.dns_forest.string;
    735                 r->out.domain_sid = sid_dup_talloc(mem_ctx, info->dns.sid);
     755                r->out.domain_sid = dom_sid_dup(mem_ctx, info->dns.sid);
    736756                NT_STATUS_HAVE_NO_MEMORY(r->out.domain_sid);
    737757        }
    738758
    739759        if (!NT_STATUS_IS_OK(status)) {
    740                 status = rpccli_lsa_QueryInfoPolicy(pipe_hnd, mem_ctx,
     760                status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx,
    741761                                                    &lsa_pol,
    742762                                                    LSA_POLICY_INFO_ACCOUNT_DOMAIN,
    743                                                     &info);
     763                                                    &info,
     764                                                    &result);
    744765                if (!NT_STATUS_IS_OK(status)) {
    745766                        goto done;
    746767                }
     768                if (!NT_STATUS_IS_OK(result)) {
     769                        status = result;
     770                        goto done;
     771                }
    747772
    748773                r->out.netbios_domain_name = info->account_domain.name.string;
    749                 r->out.domain_sid = sid_dup_talloc(mem_ctx, info->account_domain.sid);
     774                r->out.domain_sid = dom_sid_dup(mem_ctx, info->account_domain.sid);
    750775                NT_STATUS_HAVE_NO_MEMORY(r->out.domain_sid);
    751776        }
    752777
    753         rpccli_lsa_Close(pipe_hnd, mem_ctx, &lsa_pol);
     778        dcerpc_lsa_Close(b, mem_ctx, &lsa_pol, &result);
    754779        TALLOC_FREE(pipe_hnd);
    755780
     
    818843        struct rpc_pipe_client *pipe_hnd = NULL;
    819844        struct policy_handle sam_pol, domain_pol, user_pol;
    820         NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
     845        NTSTATUS status = NT_STATUS_UNSUCCESSFUL, result;
    821846        char *acct_name;
    822847        struct lsa_String lsa_acct_name;
     
    826851        struct samr_Ids name_types;
    827852        union samr_UserInfo user_info;
     853        struct dcerpc_binding_handle *b = NULL;
    828854
    829855        struct samr_CryptPassword crypt_pwd;
     
    860886        }
    861887
    862         status = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
     888        b = pipe_hnd->binding_handle;
     889
     890        status = dcerpc_samr_Connect2(b, mem_ctx,
    863891                                      pipe_hnd->desthost,
    864892                                      SAMR_ACCESS_ENUM_DOMAINS
    865893                                      | SAMR_ACCESS_LOOKUP_DOMAIN,
    866                                       &sam_pol);
    867         if (!NT_STATUS_IS_OK(status)) {
    868                 goto done;
    869         }
    870 
    871         status = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
     894                                      &sam_pol,
     895                                      &result);
     896        if (!NT_STATUS_IS_OK(status)) {
     897                goto done;
     898        }
     899        if (!NT_STATUS_IS_OK(result)) {
     900                status = result;
     901                goto done;
     902        }
     903
     904        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    872905                                        &sam_pol,
    873906                                        SAMR_DOMAIN_ACCESS_LOOKUP_INFO_1
     
    875908                                        | SAMR_DOMAIN_ACCESS_OPEN_ACCOUNT,
    876909                                        r->out.domain_sid,
    877                                         &domain_pol);
    878         if (!NT_STATUS_IS_OK(status)) {
     910                                        &domain_pol,
     911                                        &result);
     912        if (!NT_STATUS_IS_OK(status)) {
     913                goto done;
     914        }
     915        if (!NT_STATUS_IS_OK(result)) {
     916                status = result;
    879917                goto done;
    880918        }
     
    899937                        access_desired));
    900938
    901                 status = rpccli_samr_CreateUser2(pipe_hnd, mem_ctx,
     939                status = dcerpc_samr_CreateUser2(b, mem_ctx,
    902940                                                 &domain_pol,
    903941                                                 &lsa_acct_name,
     
    906944                                                 &user_pol,
    907945                                                 &access_granted,
    908                                                  &user_rid);
     946                                                 &user_rid,
     947                                                 &result);
     948                if (!NT_STATUS_IS_OK(status)) {
     949                        goto done;
     950                }
     951
     952                status = result;
    909953                if (!NT_STATUS_IS_OK(status) &&
    910954                    !NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
     
    936980
    937981                if (NT_STATUS_IS_OK(status)) {
    938                         rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol);
    939                 }
    940         }
    941 
    942         status = rpccli_samr_LookupNames(pipe_hnd, mem_ctx,
     982                        dcerpc_samr_Close(b, mem_ctx, &user_pol, &result);
     983                }
     984        }
     985
     986        status = dcerpc_samr_LookupNames(b, mem_ctx,
    943987                                         &domain_pol,
    944988                                         1,
    945989                                         &lsa_acct_name,
    946990                                         &user_rids,
    947                                          &name_types);
    948         if (!NT_STATUS_IS_OK(status)) {
     991                                         &name_types,
     992                                         &result);
     993        if (!NT_STATUS_IS_OK(status)) {
     994                goto done;
     995        }
     996        if (!NT_STATUS_IS_OK(result)) {
     997                status = result;
    949998                goto done;
    950999        }
     
    9611010        /* Open handle on user */
    9621011
    963         status = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,
     1012        status = dcerpc_samr_OpenUser(b, mem_ctx,
    9641013                                      &domain_pol,
    9651014                                      SEC_FLAG_MAXIMUM_ALLOWED,
    9661015                                      user_rid,
    967                                       &user_pol);
    968         if (!NT_STATUS_IS_OK(status)) {
     1016                                      &user_pol,
     1017                                      &result);
     1018        if (!NT_STATUS_IS_OK(status)) {
     1019                goto done;
     1020        }
     1021        if (!NT_STATUS_IS_OK(result)) {
     1022                status = result;
    9691023                goto done;
    9701024        }
     
    9731027
    9741028        acct_flags |= ACB_PWNOEXP;
    975         if (r->out.domain_is_ad) {
    976 #if !defined(ENCTYPE_ARCFOUR_HMAC)
    977                 acct_flags |= ACB_USE_DES_KEY_ONLY;
    978 #endif
    979                 ;;
    980         }
    9811029
    9821030        /* Set account flags on machine account */
     
    9841032        user_info.info16.acct_flags = acct_flags;
    9851033
    986         status = rpccli_samr_SetUserInfo(pipe_hnd, mem_ctx,
     1034        status = dcerpc_samr_SetUserInfo(b, mem_ctx,
    9871035                                         &user_pol,
    9881036                                         16,
    989                                          &user_info);
    990 
    991         if (!NT_STATUS_IS_OK(status)) {
    992 
    993                 rpccli_samr_DeleteUser(pipe_hnd, mem_ctx,
    994                                        &user_pol);
     1037                                         &user_info,
     1038                                         &result);
     1039        if (!NT_STATUS_IS_OK(status)) {
     1040                dcerpc_samr_DeleteUser(b, mem_ctx,
     1041                                       &user_pol,
     1042                                       &result);
    9951043
    9961044                libnet_join_set_error_string(mem_ctx, r,
     
    10001048        }
    10011049
     1050        if (!NT_STATUS_IS_OK(result)) {
     1051                status = result;
     1052
     1053                dcerpc_samr_DeleteUser(b, mem_ctx,
     1054                                       &user_pol,
     1055                                       &result);
     1056
     1057                libnet_join_set_error_string(mem_ctx, r,
     1058                        "Failed to set account flags for machine account (%s)\n",
     1059                        nt_errstr(status));
     1060                goto done;
     1061        }
     1062
    10021063        /* Set password on machine account - first try level 26 */
    10031064
     
    10091070        user_info.info26.password_expired = PASS_DONT_CHANGE_AT_NEXT_LOGON;
    10101071
    1011         status = rpccli_samr_SetUserInfo2(pipe_hnd, mem_ctx,
     1072        status = dcerpc_samr_SetUserInfo2(b, mem_ctx,
    10121073                                          &user_pol,
    10131074                                          26,
    1014                                           &user_info);
    1015 
    1016         if (NT_STATUS_EQUAL(status, NT_STATUS(DCERPC_FAULT_INVALID_TAG))) {
     1075                                          &user_info,
     1076                                          &result);
     1077
     1078        if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_ENUM_VALUE_OUT_OF_RANGE)) {
    10171079
    10181080                /* retry with level 24 */
     
    10251087                user_info.info24.password_expired = PASS_DONT_CHANGE_AT_NEXT_LOGON;
    10261088
    1027                 status = rpccli_samr_SetUserInfo2(pipe_hnd, mem_ctx,
     1089                status = dcerpc_samr_SetUserInfo2(b, mem_ctx,
    10281090                                                  &user_pol,
    10291091                                                  24,
    1030                                                   &user_info);
    1031         }
    1032 
    1033         if (!NT_STATUS_IS_OK(status)) {
    1034 
    1035                 rpccli_samr_DeleteUser(pipe_hnd, mem_ctx,
    1036                                        &user_pol);
     1092                                                  &user_info,
     1093                                                  &result);
     1094        }
     1095
     1096        if (!NT_STATUS_IS_OK(status)) {
     1097
     1098                dcerpc_samr_DeleteUser(b, mem_ctx,
     1099                                       &user_pol,
     1100                                       &result);
    10371101
    10381102                libnet_join_set_error_string(mem_ctx, r,
     
    10411105                goto done;
    10421106        }
     1107        if (!NT_STATUS_IS_OK(result)) {
     1108                status = result;
     1109
     1110                dcerpc_samr_DeleteUser(b, mem_ctx,
     1111                                       &user_pol,
     1112                                       &result);
     1113
     1114                libnet_join_set_error_string(mem_ctx, r,
     1115                        "Failed to set password for machine account (%s)\n",
     1116                        nt_errstr(status));
     1117                goto done;
     1118        }
    10431119
    10441120        status = NT_STATUS_OK;
     
    10501126
    10511127        if (is_valid_policy_hnd(&sam_pol)) {
    1052                 rpccli_samr_Close(pipe_hnd, mem_ctx, &sam_pol);
     1128                dcerpc_samr_Close(b, mem_ctx, &sam_pol, &result);
    10531129        }
    10541130        if (is_valid_policy_hnd(&domain_pol)) {
    1055                 rpccli_samr_Close(pipe_hnd, mem_ctx, &domain_pol);
     1131                dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
    10561132        }
    10571133        if (is_valid_policy_hnd(&user_pol)) {
    1058                 rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol);
     1134                dcerpc_samr_Close(b, mem_ctx, &user_pol, &result);
    10591135        }
    10601136        TALLOC_FREE(pipe_hnd);
     
    11051181                                     machine_password,
    11061182                                     0,
    1107                                      Undefined, NULL);
     1183                                     Undefined);
    11081184        free(machine_account);
    11091185        free(machine_password);
     
    11181194                                             "",
    11191195                                             0,
    1120                                              Undefined, NULL);
     1196                                             Undefined);
    11211197        }
    11221198
     
    12101286        struct rpc_pipe_client *pipe_hnd = NULL;
    12111287        struct policy_handle sam_pol, domain_pol, user_pol;
    1212         NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
     1288        NTSTATUS status = NT_STATUS_UNSUCCESSFUL, result;
    12131289        char *acct_name;
    12141290        uint32_t user_rid;
     
    12171293        struct samr_Ids name_types;
    12181294        union samr_UserInfo *info = NULL;
     1295        struct dcerpc_binding_handle *b = NULL;
    12191296
    12201297        ZERO_STRUCT(sam_pol);
     
    12411318        }
    12421319
    1243         status = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
     1320        b = pipe_hnd->binding_handle;
     1321
     1322        status = dcerpc_samr_Connect2(b, mem_ctx,
    12441323                                      pipe_hnd->desthost,
    12451324                                      SEC_FLAG_MAXIMUM_ALLOWED,
    1246                                       &sam_pol);
    1247         if (!NT_STATUS_IS_OK(status)) {
    1248                 goto done;
    1249         }
    1250 
    1251         status = rpccli_samr_OpenDomain(pipe_hnd, mem_ctx,
     1325                                      &sam_pol,
     1326                                      &result);
     1327        if (!NT_STATUS_IS_OK(status)) {
     1328                goto done;
     1329        }
     1330        if (!NT_STATUS_IS_OK(result)) {
     1331                status = result;
     1332                goto done;
     1333        }
     1334
     1335        status = dcerpc_samr_OpenDomain(b, mem_ctx,
    12521336                                        &sam_pol,
    12531337                                        SEC_FLAG_MAXIMUM_ALLOWED,
    12541338                                        r->in.domain_sid,
    1255                                         &domain_pol);
    1256         if (!NT_STATUS_IS_OK(status)) {
     1339                                        &domain_pol,
     1340                                        &result);
     1341        if (!NT_STATUS_IS_OK(status)) {
     1342                goto done;
     1343        }
     1344        if (!NT_STATUS_IS_OK(result)) {
     1345                status = result;
    12571346                goto done;
    12581347        }
     
    12651354        init_lsa_String(&lsa_acct_name, acct_name);
    12661355
    1267         status = rpccli_samr_LookupNames(pipe_hnd, mem_ctx,
     1356        status = dcerpc_samr_LookupNames(b, mem_ctx,
    12681357                                         &domain_pol,
    12691358                                         1,
    12701359                                         &lsa_acct_name,
    12711360                                         &user_rids,
    1272                                          &name_types);
    1273 
    1274         if (!NT_STATUS_IS_OK(status)) {
     1361                                         &name_types,
     1362                                         &result);
     1363
     1364        if (!NT_STATUS_IS_OK(status)) {
     1365                goto done;
     1366        }
     1367        if (!NT_STATUS_IS_OK(result)) {
     1368                status = result;
    12751369                goto done;
    12761370        }
     
    12871381        /* Open handle on user */
    12881382
    1289         status = rpccli_samr_OpenUser(pipe_hnd, mem_ctx,
     1383        status = dcerpc_samr_OpenUser(b, mem_ctx,
    12901384                                      &domain_pol,
    12911385                                      SEC_FLAG_MAXIMUM_ALLOWED,
    12921386                                      user_rid,
    1293                                       &user_pol);
    1294         if (!NT_STATUS_IS_OK(status)) {
     1387                                      &user_pol,
     1388                                      &result);
     1389        if (!NT_STATUS_IS_OK(status)) {
     1390                goto done;
     1391        }
     1392        if (!NT_STATUS_IS_OK(result)) {
     1393                status = result;
    12951394                goto done;
    12961395        }
     
    12981397        /* Get user info */
    12991398
    1300         status = rpccli_samr_QueryUserInfo(pipe_hnd, mem_ctx,
     1399        status = dcerpc_samr_QueryUserInfo(b, mem_ctx,
    13011400                                           &user_pol,
    13021401                                           16,
    1303                                            &info);
    1304         if (!NT_STATUS_IS_OK(status)) {
    1305                 rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol);
     1402                                           &info,
     1403                                           &result);
     1404        if (!NT_STATUS_IS_OK(status)) {
     1405                dcerpc_samr_Close(b, mem_ctx, &user_pol, &result);
     1406                goto done;
     1407        }
     1408        if (!NT_STATUS_IS_OK(result)) {
     1409                status = result;
     1410                dcerpc_samr_Close(b, mem_ctx, &user_pol, &result);
    13061411                goto done;
    13071412        }
     
    13111416        info->info16.acct_flags |= ACB_DISABLED;
    13121417
    1313         status = rpccli_samr_SetUserInfo(pipe_hnd, mem_ctx,
     1418        status = dcerpc_samr_SetUserInfo(b, mem_ctx,
    13141419                                         &user_pol,
    13151420                                         16,
    1316                                          info);
    1317 
    1318         rpccli_samr_Close(pipe_hnd, mem_ctx, &user_pol);
     1421                                         info,
     1422                                         &result);
     1423        if (!NT_STATUS_IS_OK(status)) {
     1424                dcerpc_samr_Close(b, mem_ctx, &user_pol, &result);
     1425                goto done;
     1426        }
     1427        if (!NT_STATUS_IS_OK(result)) {
     1428                status = result;
     1429                dcerpc_samr_Close(b, mem_ctx, &user_pol, &result);
     1430                goto done;
     1431        }
     1432        status = result;
     1433        dcerpc_samr_Close(b, mem_ctx, &user_pol, &result);
    13191434
    13201435done:
    1321         if (pipe_hnd) {
     1436        if (pipe_hnd && b) {
    13221437                if (is_valid_policy_hnd(&domain_pol)) {
    1323                         rpccli_samr_Close(pipe_hnd, mem_ctx, &domain_pol);
     1438                        dcerpc_samr_Close(b, mem_ctx, &domain_pol, &result);
    13241439                }
    13251440                if (is_valid_policy_hnd(&sam_pol)) {
    1326                         rpccli_samr_Close(pipe_hnd, mem_ctx, &sam_pol);
     1441                        dcerpc_samr_Close(b, mem_ctx, &sam_pol, &result);
    13271442                }
    13281443                TALLOC_FREE(pipe_hnd);
     
    13411456static WERROR do_join_modify_vals_config(struct libnet_JoinCtx *r)
    13421457{
    1343         WERROR werr;
     1458        WERROR werr = WERR_OK;
     1459        sbcErr err;
    13441460        struct smbconf_ctx *ctx;
    13451461
    1346         werr = smbconf_init_reg(r, &ctx, NULL);
    1347         if (!W_ERROR_IS_OK(werr)) {
     1462        err = smbconf_init_reg(r, &ctx, NULL);
     1463        if (!SBC_ERROR_IS_OK(err)) {
     1464                werr = WERR_NO_SUCH_SERVICE;
    13481465                goto done;
    13491466        }
     
    13511468        if (!(r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE)) {
    13521469
    1353                 werr = smbconf_set_global_parameter(ctx, "security", "user");
    1354                 W_ERROR_NOT_OK_GOTO_DONE(werr);
    1355 
    1356                 werr = smbconf_set_global_parameter(ctx, "workgroup",
    1357                                                     r->in.domain_name);
     1470                err = smbconf_set_global_parameter(ctx, "security", "user");
     1471                if (!SBC_ERROR_IS_OK(err)) {
     1472                        werr = WERR_NO_SUCH_SERVICE;
     1473                        goto done;
     1474                }
     1475
     1476                err = smbconf_set_global_parameter(ctx, "workgroup",
     1477                                                   r->in.domain_name);
     1478                if (!SBC_ERROR_IS_OK(err)) {
     1479                        werr = WERR_NO_SUCH_SERVICE;
     1480                        goto done;
     1481                }
    13581482
    13591483                smbconf_delete_global_parameter(ctx, "realm");
     
    13611485        }
    13621486
    1363         werr = smbconf_set_global_parameter(ctx, "security", "domain");
    1364         W_ERROR_NOT_OK_GOTO_DONE(werr);
    1365 
    1366         werr = smbconf_set_global_parameter(ctx, "workgroup",
    1367                                             r->out.netbios_domain_name);
    1368         W_ERROR_NOT_OK_GOTO_DONE(werr);
     1487        err = smbconf_set_global_parameter(ctx, "security", "domain");
     1488        if (!SBC_ERROR_IS_OK(err)) {
     1489                werr = WERR_NO_SUCH_SERVICE;
     1490                goto done;
     1491        }
     1492
     1493        err = smbconf_set_global_parameter(ctx, "workgroup",
     1494                                           r->out.netbios_domain_name);
     1495        if (!SBC_ERROR_IS_OK(err)) {
     1496                werr = WERR_NO_SUCH_SERVICE;
     1497                goto done;
     1498        }
    13691499
    13701500        if (r->out.domain_is_ad) {
    1371                 werr = smbconf_set_global_parameter(ctx, "security", "ads");
    1372                 W_ERROR_NOT_OK_GOTO_DONE(werr);
    1373 
    1374                 werr = smbconf_set_global_parameter(ctx, "realm",
    1375                                                     r->out.dns_domain_name);
    1376                 W_ERROR_NOT_OK_GOTO_DONE(werr);
     1501                err = smbconf_set_global_parameter(ctx, "security", "ads");
     1502                if (!SBC_ERROR_IS_OK(err)) {
     1503                        werr = WERR_NO_SUCH_SERVICE;
     1504                        goto done;
     1505                }
     1506
     1507                err = smbconf_set_global_parameter(ctx, "realm",
     1508                                                   r->out.dns_domain_name);
     1509                if (!SBC_ERROR_IS_OK(err)) {
     1510                        werr = WERR_NO_SUCH_SERVICE;
     1511                        goto done;
     1512                }
    13771513        }
    13781514
     
    13881524{
    13891525        WERROR werr = WERR_OK;
     1526        sbcErr err;
    13901527        struct smbconf_ctx *ctx;
    13911528
    1392         werr = smbconf_init_reg(r, &ctx, NULL);
    1393         if (!W_ERROR_IS_OK(werr)) {
     1529        err = smbconf_init_reg(r, &ctx, NULL);
     1530        if (!SBC_ERROR_IS_OK(err)) {
     1531                werr = WERR_NO_SUCH_SERVICE;
    13941532                goto done;
    13951533        }
     
    13971535        if (r->in.unjoin_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE) {
    13981536
    1399                 werr = smbconf_set_global_parameter(ctx, "security", "user");
    1400                 W_ERROR_NOT_OK_GOTO_DONE(werr);
    1401 
    1402                 werr = smbconf_delete_global_parameter(ctx, "workgroup");
    1403                 W_ERROR_NOT_OK_GOTO_DONE(werr);
     1537                err = smbconf_set_global_parameter(ctx, "security", "user");
     1538                if (!SBC_ERROR_IS_OK(err)) {
     1539                        werr = WERR_NO_SUCH_SERVICE;
     1540                        goto done;
     1541                }
     1542
     1543                err = smbconf_delete_global_parameter(ctx, "workgroup");
     1544                if (!SBC_ERROR_IS_OK(err)) {
     1545                        werr = WERR_NO_SUCH_SERVICE;
     1546                        goto done;
     1547                }
    14041548
    14051549                smbconf_delete_global_parameter(ctx, "realm");
     
    15991743        }
    16001744
    1601 #ifdef WITH_ADS
     1745#ifdef HAVE_ADS
    16021746        if (r->out.domain_is_ad &&
    16031747            !(r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_UNSECURE)) {
     
    16091753                }
    16101754        }
    1611 #endif /* WITH_ADS */
     1755#endif /* HAVE_ADS */
    16121756
    16131757        libnet_join_add_dom_rids_to_builtins(r->out.domain_sid);
     
    18171961        WERROR werr;
    18181962        struct cli_state *cli = NULL;
    1819 #ifdef WITH_ADS
     1963#ifdef HAVE_ADS
    18201964        ADS_STATUS ads_status;
    1821 #endif /* WITH_ADS */
     1965#endif /* HAVE_ADS */
    18221966
    18231967        if (!r->in.dc_name) {
     
    18602004        }
    18612005
    1862 #ifdef WITH_ADS
     2006#ifdef HAVE_ADS
     2007
     2008        create_local_private_krb5_conf_for_domain(
     2009                r->out.dns_domain_name, r->out.netbios_domain_name,
     2010                NULL, &cli->dest_ss, cli->desthost);
     2011
    18632012        if (r->out.domain_is_ad && r->in.account_ou &&
    18642013            !(r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_UNSECURE)) {
     
    18802029                r->in.join_flags &= ~WKSSVC_JOIN_FLAGS_ACCOUNT_CREATE;
    18812030        }
    1882 #endif /* WITH_ADS */
     2031#endif /* HAVE_ADS */
    18832032
    18842033        if ((r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_UNSECURE) &&
     
    19552104        }
    19562105
     2106        ZERO_STRUCT(r->out);
     2107
    19572108        werr = libnet_join_pre_processing(mem_ctx, r);
    19582109        if (!W_ERROR_IS_OK(werr)) {
     
    20032154                        return WERR_SETUP_NOT_JOINED;
    20042155                }
    2005                 r->in.domain_sid = sid_dup_talloc(mem_ctx, &sid);
     2156                r->in.domain_sid = dom_sid_dup(mem_ctx, &sid);
    20062157                W_ERROR_HAVE_NO_MEMORY(r->in.domain_sid);
    20072158        }
     
    20382189        }
    20392190
    2040 #ifdef WITH_ADS
     2191#ifdef HAVE_ADS
    20412192        /* for net ads leave, try to delete the account.  If it works,
    20422193           no sense in disabling.  If it fails, we can still try to
    20432194           disable it. jmcd */
    2044            
     2195
    20452196        if (r->in.delete_machine_account) {
    20462197                ADS_STATUS ads_status;
     
    20652216                }
    20662217        }
    2067 #endif /* WITH_ADS */
     2218#endif /* HAVE_ADS */
    20682219
    20692220        /* The WKSSVC_JOIN_FLAGS_ACCOUNT_DELETE flag really means
     
    20802231                        return ntstatus_to_werror(status);
    20812232                }
    2082                
     2233
    20832234                r->out.disabled_machine_account = true;
    20842235        }
Note: See TracChangeset for help on using the changeset viewer.