1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
/*
* Unix SMB/CIFS implementation.
*
* LSARPC client routines
*
* Copyright (c) 2000-2001 Tim Potter
* Copyright (c) 1992-2000 Andrew Tridgell
* Copyright (c) 2002 Rafal Szczesniak
* Copyright (c) 2005 Jeremy Allison
* Copyright (c) 2007 Michael Adam
* Copyright (c) 2008 Guenther Deschner
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CLI_LSARPC_H
#define _CLI_LSARPC_H
/* The following definitions come from rpc_client/cli_lsarpc.c */
/**
* @brief Open a LSA policy.
*
* @param[in] h The dcerpc binding handle to use.
*
* @param[in] mem_ctx The memory context to use.
*
* @param[in] sec_qos Enable security quality of services.
*
* @param[in] des_access The desired access rights to be granted.
*
* @param[out] pol A pointer to a rpc policy handle.
*
* @param[out] result A pointer for the NDR NTSTATUS error code.
*
* @return A corresponding NTSTATUS error code for the connection.
*/
NTSTATUS dcerpc_lsa_open_policy(struct dcerpc_binding_handle *h,
TALLOC_CTX *mem_ctx,
bool sec_qos,
uint32_t des_access,
struct policy_handle *pol,
NTSTATUS *result);
NTSTATUS rpccli_lsa_open_policy(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
bool sec_qos, uint32_t des_access,
struct policy_handle *pol);
/**
* @brief Open a LSA policy.
*
* @param[in] h The dcerpc binding handle to use.
*
* @param[in] mem_ctx The memory context to use.
*
* @param[in] sec_qos Enable security quality of services.
*
* @param[in] des_access The desired access rights to be granted.
*
* @param[out] pol A pointer to a rpc policy handle.
*
* @param[out] result A pointer for the NDR NTSTATUS error code.
*
* @return A corresponding NTSTATUS error code for the connection.
*/
NTSTATUS dcerpc_lsa_open_policy2(struct dcerpc_binding_handle *h,
TALLOC_CTX *mem_ctx,
const char *srv_name_slash,
bool sec_qos,
uint32_t des_access,
struct policy_handle *pol,
NTSTATUS *result);
/**
* @brief Open a LSA policy.
*
* @param[in] h The dcerpc binding handle to use.
*
* @param[in] mem_ctx The memory context to use.
*
* @param[in] sec_qos Enable security quality of services.
*
* @param[in] des_access The desired access rights to be granted.
*
* @param[out] out_version A pointer to an uin32_t to store the version of the
* following data structure.
*
* @param[out] out_revision info A pointer to store the out_revision_info.
*
* @param[out] pol A pointer to a rpc policy handle.
*
* @param[out] result A pointer for the NDR NTSTATUS error code.
*
* @return A corresponding NTSTATUS error code for the connection.
*/
NTSTATUS dcerpc_lsa_open_policy3(struct dcerpc_binding_handle *h,
TALLOC_CTX *mem_ctx,
const char *srv_name_slash,
bool sec_qos,
uint32_t des_access,
uint32_t *out_version,
union lsa_revision_info *out_revision_info,
struct policy_handle *pol,
NTSTATUS *result);
/**
* @brief Open a LSA policy with fallback to previous version
*
* This first calls lsa_open_policy3 and falls back to lsa_open_policy2 in case
* it isn't implemented.
*
* @param[in] h The dcerpc binding handle to use.
*
* @param[in] mem_ctx The memory context to use.
*
* @param[in] sec_qos Enable security quality of services.
*
* @param[in] des_access The desired access rights to be granted.
*
* @param[out] out_version A pointer to an uin32_t to store the version of the
* following data structure.
*
* @param[out] out_revision info A pointer to store the out_revision_info.
*
* @param[out] pol A pointer to a rpc policy handle.
*
* @param[out] result A pointer for the NDR NTSTATUS error code.
*
* @return A corresponding NTSTATUS error code for the connection.
*/
NTSTATUS dcerpc_lsa_open_policy_fallback(struct dcerpc_binding_handle *h,
TALLOC_CTX *mem_ctx,
const char *srv_name_slash,
bool sec_qos,
uint32_t desired_access,
uint32_t *out_version,
union lsa_revision_info *out_revision_info,
struct policy_handle *pol,
NTSTATUS *result);
/**
* @brief Look up the names that correspond to an array of sids.
*
* @param[in] h The initialized binding handle for a dcerpc connection.
*
* @param[in] mem_ctx The memory context to use.
*
* @param[in] pol The opened domain policy handle.
*
* @param[in] num_sids The number of sids in the sids array to look up.
*
* @param[in] sids The array of sids to look up.
*
* @param[out] pdomains A pointer to store the refercenced domains.
*
* @param[out] pnames A pointer to an array for the translated names.
*
* @param[out] ptypes A pointer to an array for the types of the names.
*
* @param[out] result A pointer for the conversion result.
*
* @return A corresponding NTSTATUS error code.
*/
NTSTATUS dcerpc_lsa_lookup_sids(struct dcerpc_binding_handle *h,
TALLOC_CTX *mem_ctx,
struct policy_handle *pol,
int num_sids,
const struct dom_sid *sids,
char ***pdomains,
char ***pnames,
enum lsa_SidType **ptypes,
NTSTATUS *result);
NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *pol,
int num_sids,
const struct dom_sid *sids,
char ***pdomains,
char ***pnames,
enum lsa_SidType **ptypes);
NTSTATUS dcerpc_lsa_lookup_sids_generic(struct dcerpc_binding_handle *h,
TALLOC_CTX *mem_ctx,
struct policy_handle *pol,
int num_sids,
const struct dom_sid *sids,
enum lsa_LookupNamesLevel level,
char ***pdomains,
char ***pnames,
enum lsa_SidType **ptypes,
bool use_lookupsids3,
NTSTATUS *presult);
/**
* @brief Look up the names that correspond to an array of sids.
*
* @param[in] h The initialized binding handle for a dcerpc connection.
*
* @param[in] mem_ctx The memory context to use.
*
* @param[in] pol The opened domain policy handle.
*
* @param[in] num_sids The number of sids in the sids array to look up.
*
* @param[in] sids The array of sids to look up.
*
* @param[out] pdomains A pointer to store the refercenced domains.
*
* @param[out] pnames A pointer to an array for the translated names.
*
* @param[out] ptypes A pointer to an array for the types of the names.
*
* @param[out] result A pointer for the conversion result.
*
* @return A corresponding NTSTATUS error code.
*/
NTSTATUS dcerpc_lsa_lookup_sids3(struct dcerpc_binding_handle *h,
TALLOC_CTX *mem_ctx,
struct policy_handle *pol,
int num_sids,
const struct dom_sid *sids,
char ***pdomains,
char ***pnames,
enum lsa_SidType **ptypes,
NTSTATUS *result);
NTSTATUS dcerpc_lsa_lookup_names(struct dcerpc_binding_handle *h,
TALLOC_CTX *mem_ctx,
struct policy_handle *pol,
uint32_t num_names,
const char **names,
const char ***dom_names,
enum lsa_LookupNamesLevel level,
struct dom_sid **sids,
enum lsa_SidType **types,
NTSTATUS *result);
NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
struct policy_handle *pol, int num_names,
const char **names,
const char ***dom_names,
int level,
struct dom_sid **sids,
enum lsa_SidType **types);
NTSTATUS dcerpc_lsa_lookup_names4(struct dcerpc_binding_handle *h,
TALLOC_CTX *mem_ctx,
struct policy_handle *pol,
uint32_t num_names,
const char **names,
const char ***dom_names,
enum lsa_LookupNamesLevel level,
struct dom_sid **sids,
enum lsa_SidType **types,
NTSTATUS *result);
NTSTATUS dcerpc_lsa_lookup_names_generic(struct dcerpc_binding_handle *h,
TALLOC_CTX *mem_ctx,
struct policy_handle *pol,
uint32_t num_names,
const char **names,
const char ***dom_names,
enum lsa_LookupNamesLevel level,
struct dom_sid **sids,
enum lsa_SidType **types,
bool use_lookupnames4,
NTSTATUS *presult);
bool fetch_domain_sid( char *domain, char *remote_machine, struct dom_sid *psid);
#endif /* _CLI_LSARPC_H */
|