Ignore:
Timestamp:
Oct 30, 2009, 9:39:05 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update 3.3 to 3.3.9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.3.x/source/winbindd/winbindd_rpc.c

    r223 r342  
    278278        enum lsa_SidType *types = NULL;
    279279        char *full_name = NULL;
    280         struct rpc_pipe_client *cli;
    281         POLICY_HND lsa_policy;
    282280        NTSTATUS name_map_status = NT_STATUS_UNSUCCESSFUL;
    283281        char *mapped_name = NULL;
     
    311309                 full_name?full_name:"", domain_name ));
    312310
    313         result = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
    314         if (!NT_STATUS_IS_OK(result))
    315                 return result;
    316 
    317         result = rpccli_lsa_lookup_names(cli, mem_ctx, &lsa_policy, 1,
    318                                          (const char**) &full_name, NULL, 1, &sids, &types);
    319        
     311        result = winbindd_lookup_names(mem_ctx, domain, 1,
     312                                       (const char **)&full_name, NULL,
     313                                       &sids, &types);
    320314        if (!NT_STATUS_IS_OK(result))
    321315                return result;
     
    343337        enum lsa_SidType *types = NULL;
    344338        NTSTATUS result;
    345         struct rpc_pipe_client *cli;
    346         POLICY_HND lsa_policy;
    347339        NTSTATUS name_map_status = NT_STATUS_UNSUCCESSFUL;
    348340        char *mapped_name = NULL;
     
    351343                 domain->name ));
    352344
    353         result = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
     345        result = winbindd_lookup_sids(mem_ctx,
     346                                      domain,
     347                                      1,
     348                                      sid,
     349                                      &domains,
     350                                      &names,
     351                                      &types);
    354352        if (!NT_STATUS_IS_OK(result)) {
    355                 DEBUG(2,("msrpc_sid_to_name: cm_connect_lsa() failed (%s)\n",
    356                          nt_errstr(result)));           
     353                DEBUG(2,("msrpc_sid_to_name: failed to lookup sids: %s\n",
     354                        nt_errstr(result)));
    357355                return result;
    358356        }
    359357       
    360 
    361         result = rpccli_lsa_lookup_sids(cli, mem_ctx, &lsa_policy,
    362                                         1, sid, &domains, &names, &types);
    363         if (!NT_STATUS_IS_OK(result)) {         
    364                 DEBUG(2,("msrpc_sid_to_name: rpccli_lsa_lookup_sids()  failed (%s)\n",
    365                          nt_errstr(result)));           
    366                 return result;
    367         }
    368358
    369359        *type = (enum lsa_SidType)types[0];
     
    396386        char **domains;
    397387        NTSTATUS result;
    398         struct rpc_pipe_client *cli;
    399         POLICY_HND lsa_policy;
    400388        DOM_SID *sids;
    401389        size_t i;
     
    419407        }
    420408
    421         result = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
    422         if (!NT_STATUS_IS_OK(result)) {
    423                 return result;
    424         }
    425 
    426         result = rpccli_lsa_lookup_sids(cli, mem_ctx, &lsa_policy,
    427                                         num_rids, sids, &domains,
    428                                         names, types);
     409        result = winbindd_lookup_sids(mem_ctx,
     410                                      domain,
     411                                      num_rids,
     412                                      sids,
     413                                      &domains,
     414                                      names,
     415                                      types);
     416
    429417        if (!NT_STATUS_IS_OK(result) &&
    430418            !NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED)) {
     
    11861174}
    11871175
     1176typedef NTSTATUS (*lookup_sids_fn_t)(struct rpc_pipe_client *cli,
     1177                                     TALLOC_CTX *mem_ctx,
     1178                                     struct policy_handle *pol,
     1179                                     int num_sids,
     1180                                     const DOM_SID *sids,
     1181                                     char ***pdomains,
     1182                                     char ***pnames,
     1183                                     enum lsa_SidType **ptypes);
     1184
     1185NTSTATUS winbindd_lookup_sids(TALLOC_CTX *mem_ctx,
     1186                              struct winbindd_domain *domain,
     1187                              uint32_t num_sids,
     1188                              const struct dom_sid *sids,
     1189                              char ***domains,
     1190                              char ***names,
     1191                              enum lsa_SidType **types)
     1192{
     1193        NTSTATUS status;
     1194        struct rpc_pipe_client *cli = NULL;
     1195        struct policy_handle lsa_policy;
     1196        unsigned int orig_timeout;
     1197        lookup_sids_fn_t lookup_sids_fn = rpccli_lsa_lookup_sids;
     1198
     1199        if (domain->can_do_ncacn_ip_tcp) {
     1200                status = cm_connect_lsa_tcp(domain, mem_ctx, &cli);
     1201                if (NT_STATUS_IS_OK(status)) {
     1202                        lookup_sids_fn = rpccli_lsa_lookup_sids3;
     1203                        goto lookup;
     1204                }
     1205                domain->can_do_ncacn_ip_tcp = false;
     1206        }
     1207        status = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
     1208
     1209        if (!NT_STATUS_IS_OK(status)) {
     1210                return status;
     1211        }
     1212
     1213 lookup:
     1214        /*
     1215         * This call can take a long time
     1216         * allow the server to time out.
     1217         * 35 seconds should do it.
     1218         */
     1219        orig_timeout = rpccli_set_timeout(cli, 35000);
     1220
     1221        status = lookup_sids_fn(cli,
     1222                                mem_ctx,
     1223                                &lsa_policy,
     1224                                num_sids,
     1225                                sids,
     1226                                domains,
     1227                                names,
     1228                                types);
     1229
     1230        /* And restore our original timeout. */
     1231        rpccli_set_timeout(cli, orig_timeout);
     1232
     1233        if (!NT_STATUS_IS_OK(status)) {
     1234                return status;
     1235        }
     1236
     1237        return status;
     1238}
     1239
     1240typedef NTSTATUS (*lookup_names_fn_t)(struct rpc_pipe_client *cli,
     1241                                      TALLOC_CTX *mem_ctx,
     1242                                      struct policy_handle *pol,
     1243                                      int num_names,
     1244                                      const char **names,
     1245                                      const char ***dom_names,
     1246                                      int level,
     1247                                      struct dom_sid **sids,
     1248                                      enum lsa_SidType **types);
     1249
     1250NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
     1251                               struct winbindd_domain *domain,
     1252                               uint32_t num_names,
     1253                               const char **names,
     1254                               const char ***domains,
     1255                               struct dom_sid **sids,
     1256                               enum lsa_SidType **types)
     1257{
     1258        NTSTATUS status;
     1259        struct rpc_pipe_client *cli = NULL;
     1260        struct policy_handle lsa_policy;
     1261        unsigned int orig_timeout;
     1262        lookup_names_fn_t lookup_names_fn = rpccli_lsa_lookup_names;
     1263
     1264        if (domain->can_do_ncacn_ip_tcp) {
     1265                status = cm_connect_lsa_tcp(domain, mem_ctx, &cli);
     1266                if (NT_STATUS_IS_OK(status)) {
     1267                        lookup_names_fn = rpccli_lsa_lookup_names4;
     1268                        goto lookup;
     1269                }
     1270                domain->can_do_ncacn_ip_tcp = false;
     1271        }
     1272        status = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
     1273
     1274        if (!NT_STATUS_IS_OK(status)) {
     1275                return status;
     1276        }
     1277
     1278 lookup:
     1279
     1280        /*
     1281         * This call can take a long time
     1282         * allow the server to time out.
     1283         * 35 seconds should do it.
     1284         */
     1285        orig_timeout = rpccli_set_timeout(cli, 35000);
     1286
     1287        status = lookup_names_fn(cli,
     1288                                 mem_ctx,
     1289                                 &lsa_policy,
     1290                                 num_names,
     1291                                 (const char **) names,
     1292                                 domains,
     1293                                 1,
     1294                                 sids,
     1295                                 types);
     1296
     1297        /* And restore our original timeout. */
     1298        rpccli_set_timeout(cli, orig_timeout);
     1299
     1300        if (!NT_STATUS_IS_OK(status)) {
     1301                return status;
     1302        }
     1303
     1304        return status;
     1305}
    11881306
    11891307/* the rpc backend methods are exposed via this structure */
Note: See TracChangeset for help on using the changeset viewer.