source: trunk/server/source3/winbindd/wb_lookupsids.c@ 751

Last change on this file since 751 was 751, checked in by Silvan Scherrer, 13 years ago

Samba Server: updated trunk to 3.6.9

File size: 17.2 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 async lookupsids
4 Copyright (C) Volker Lendecke 2011
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#include "includes.h"
21#include "winbindd.h"
22#include "librpc/gen_ndr/ndr_wbint_c.h"
23#include "../libcli/security/security.h"
24#include "passdb/machine_sid.h"
25
26struct wb_lookupsids_domain {
27 struct dom_sid sid;
28 struct winbindd_domain *domain;
29
30 /*
31 * Array of sids to be passed into wbint_LookupSids. Preallocated with
32 * num_sids.
33 */
34 struct lsa_SidArray sids;
35
36 /*
37 * Indexes into wb_lookupsids_state->sids and thus
38 * wb_lookupsids_state->res_names. Preallocated with num_sids.
39 */
40 uint32_t *sid_indexes;
41};
42
43struct wb_translated_name {
44 const char *domain_name;
45 const char *name;
46 enum lsa_SidType type;
47};
48
49static struct wb_lookupsids_domain *wb_lookupsids_get_domain(
50 const struct dom_sid *sid, TALLOC_CTX *mem_ctx,
51 struct wb_lookupsids_domain **domains, uint32_t num_sids);
52
53struct wb_lookupsids_state {
54 struct tevent_context *ev;
55
56 /*
57 * SIDs passed in
58 */
59 struct dom_sid *sids;
60 uint32_t num_sids;
61
62 /*
63 * The domains we're using for bulk lookup via wbint_LookupRids or
64 * wbint_LookupSids. We expect very few domains, so we do a
65 * talloc_realloc and rely on talloc_array_length.
66 */
67 struct wb_lookupsids_domain *domains;
68 uint32_t domains_done;
69
70 /*
71 * These SIDs are looked up individually via
72 * wbint_LookupSid. Preallocated with num_sids.
73 */
74 uint32_t *single_sids;
75 uint32_t num_single_sids;
76 uint32_t single_sids_done;
77
78 /*
79 * Intermediate store for wbint_LookupRids to passdb. These are
80 * spliced into res_domains/res_names in wb_lookupsids_move_name.
81 */
82 struct wbint_RidArray rids;
83 const char *domain_name;
84 struct wbint_Principals rid_names;
85
86 /*
87 * Intermediate results for wbint_LookupSids. These results are
88 * spliced into res_domains/res_names in wb_lookupsids_move_name.
89 */
90 struct lsa_RefDomainList tmp_domains;
91 struct lsa_TransNameArray tmp_names;
92
93 /*
94 * Results
95 */
96 struct lsa_RefDomainList *res_domains;
97 /*
98 * Indexed as "sids" in this structure
99 */
100 struct lsa_TransNameArray *res_names;
101};
102
103static bool wb_lookupsids_next(struct tevent_req *req,
104 struct wb_lookupsids_state *state);