winbind: Pass upn unmodified to lookup names
[samba.git] / source3 / winbindd / winbindd_proto.h
1 /*
2  * Unix SMB/CIFS implementation.
3  * collected prototypes header
4  *
5  * frozen from "make proto" in May 2008
6  *
7  * Copyright (C) Michael Adam 2008
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, see <http://www.gnu.org/licenses/>.
21  */
22
23 #ifndef _WINBINDD_PROTO_H_
24 #define _WINBINDD_PROTO_H_
25
26 /* The following definitions come from winbindd/winbindd.c  */
27 struct imessaging_context *winbind_imessaging_context(void);
28 void request_error(struct winbindd_cli_state *state);
29 void request_ok(struct winbindd_cli_state *state);
30 bool winbindd_setup_sig_term_handler(bool parent);
31 bool winbindd_setup_stdin_handler(bool parent, bool foreground);
32 bool winbindd_setup_sig_hup_handler(const char *lfile);
33 bool winbindd_use_idmap_cache(void);
34 bool winbindd_use_cache(void);
35 char *get_winbind_priv_pipe_dir(void);
36
37 /* The following definitions come from winbindd/winbindd_ads.c  */
38
39 /* The following definitions come from winbindd/winbindd_rpc.c  */
40
41 NTSTATUS winbindd_lookup_sids(TALLOC_CTX *mem_ctx,
42                               struct winbindd_domain *domain,
43                               uint32_t num_sids,
44                               const struct dom_sid *sids,
45                               char ***domains,
46                               char ***names,
47                               enum lsa_SidType **types);
48 NTSTATUS rpc_lookup_sids(TALLOC_CTX *mem_ctx,
49                          struct winbindd_domain *domain,
50                          struct lsa_SidArray *sids,
51                          struct lsa_RefDomainList **pdomains,
52                          struct lsa_TransNameArray **pnames);
53
54 /* The following definitions come from winbindd/winbindd_cache.c  */
55
56 NTSTATUS wb_cache_query_user_list(struct winbindd_domain *domain,
57                                   TALLOC_CTX *mem_ctx,
58                                   uint32_t **prids);
59 NTSTATUS wb_cache_enum_dom_groups(struct winbindd_domain *domain,
60                                   TALLOC_CTX *mem_ctx,
61                                   uint32_t *num_entries,
62                                   struct wb_acct_info **info);
63 NTSTATUS wb_cache_enum_local_groups(struct winbindd_domain *domain,
64                                     TALLOC_CTX *mem_ctx,
65                                     uint32_t *num_entries,
66                                     struct wb_acct_info **info);
67 NTSTATUS wb_cache_name_to_sid(struct winbindd_domain *domain,
68                               TALLOC_CTX *mem_ctx,
69                               const char *domain_name,
70                               const char *name,
71                               uint32_t flags,
72                               struct dom_sid *sid,
73                               enum lsa_SidType *type);
74 NTSTATUS wb_cache_sid_to_name(struct winbindd_domain *domain,
75                               TALLOC_CTX *mem_ctx,
76                               const struct dom_sid *sid,
77                               char **domain_name,
78                               char **name,
79                               enum lsa_SidType *type);
80 NTSTATUS wb_cache_rids_to_names(struct winbindd_domain *domain,
81                                 TALLOC_CTX *mem_ctx,
82                                 const struct dom_sid *domain_sid,
83                                 uint32_t *rids,
84                                 size_t num_rids,
85                                 char **domain_name,
86                                 char ***names,
87                                 enum lsa_SidType **types);
88 NTSTATUS wb_cache_lookup_usergroups(struct winbindd_domain *domain,
89                                     TALLOC_CTX *mem_ctx,
90                                     const struct dom_sid *user_sid,
91                                     uint32_t *pnum_sids,
92                                     struct dom_sid **psids);
93 NTSTATUS wb_cache_lookup_useraliases(struct winbindd_domain *domain,
94                                      TALLOC_CTX *mem_ctx,
95                                      uint32_t num_sids,
96                                      const struct dom_sid *sids,
97                                      uint32_t *num_aliases,
98                                      uint32_t **alias_rids);
99 NTSTATUS wb_cache_lookup_groupmem(struct winbindd_domain *domain,
100                                   TALLOC_CTX *mem_ctx,
101                                   const struct dom_sid *group_sid,
102                                   enum lsa_SidType type,
103                                   uint32_t *num_names,
104                                   struct dom_sid **sid_mem,
105                                   char ***names,
106                                   uint32_t **name_types);
107 NTSTATUS wb_cache_sequence_number(struct winbindd_domain *domain,
108                                   uint32_t *seq);
109 NTSTATUS wb_cache_lockout_policy(struct winbindd_domain *domain,
110                                  TALLOC_CTX *mem_ctx,
111                                  struct samr_DomInfo12 *policy);
112 NTSTATUS wb_cache_password_policy(struct winbindd_domain *domain,
113                                   TALLOC_CTX *mem_ctx,
114                                   struct samr_DomInfo1 *policy);
115 NTSTATUS wb_cache_trusted_domains(struct winbindd_domain *domain,
116                                   TALLOC_CTX *mem_ctx,
117                                   struct netr_DomainTrustList *trusts);
118
119 NTSTATUS wcache_cached_creds_exist(struct winbindd_domain *domain, const struct dom_sid *sid);
120 NTSTATUS wcache_get_creds(struct winbindd_domain *domain, 
121                           TALLOC_CTX *mem_ctx, 
122                           const struct dom_sid *sid,
123                           const uint8_t **cached_nt_pass,
124                           const uint8_t **cached_salt);
125 NTSTATUS wcache_save_creds(struct winbindd_domain *domain, 
126                            const struct dom_sid *sid,
127                            const uint8_t nt_pass[NT_HASH_LEN]);
128 void wcache_invalidate_samlogon(struct winbindd_domain *domain, 
129                                 const struct dom_sid *user_sid);
130 bool wcache_invalidate_cache(void);
131 bool wcache_invalidate_cache_noinit(void);
132 bool initialize_winbindd_cache(void);
133 void close_winbindd_cache(void);
134 bool lookup_cached_sid(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
135                        char **domain_name, char **name,
136                        enum lsa_SidType *type);
137 bool lookup_cached_name(const char *domain_name,
138                         const char *name,
139                         struct dom_sid *sid,
140                         enum lsa_SidType *type);
141 void cache_name2sid_trusted(struct winbindd_domain *domain,
142                         const char *domain_name,
143                         const char *name,
144                         enum lsa_SidType type,
145                         const struct dom_sid *sid);
146 void cache_name2sid(struct winbindd_domain *domain, 
147                     const char *domain_name, const char *name,
148                     enum lsa_SidType type, const struct dom_sid *sid);
149 NTSTATUS wcache_query_user_fullname(struct winbindd_domain *domain,
150                                     TALLOC_CTX *mem_ctx,
151                                     const struct dom_sid *user_sid,
152                                     const char **full_name);
153
154 NTSTATUS wcache_count_cached_creds(struct winbindd_domain *domain, int *count);
155 NTSTATUS wcache_remove_oldest_cached_creds(struct winbindd_domain *domain, const struct dom_sid *sid) ;
156 bool set_global_winbindd_state_offline(void);
157 void set_global_winbindd_state_online(void);
158 bool get_global_winbindd_state_offline(void);
159 int winbindd_validate_cache(void);
160 int winbindd_validate_cache_nobackup(void);
161 bool winbindd_cache_validate_and_initialize(void);
162 bool wcache_tdc_fetch_list( struct winbindd_tdc_domain **domains, size_t *num_domains );
163 bool wcache_tdc_add_domain( struct winbindd_domain *domain );
164 struct winbindd_tdc_domain * wcache_tdc_fetch_domain( TALLOC_CTX *ctx, const char *name );
165 void wcache_tdc_clear( void );
166 bool wcache_store_seqnum(const char *domain_name, uint32_t seqnum,
167                          time_t last_seq_check);
168 bool wcache_fetch_ndr(TALLOC_CTX *mem_ctx, struct winbindd_domain *domain,
169                       uint32_t opnum, const DATA_BLOB *req, DATA_BLOB *resp);
170 void wcache_store_ndr(struct winbindd_domain *domain, uint32_t opnum,
171                       const DATA_BLOB *req, const DATA_BLOB *resp);
172
173 /* The following definitions come from winbindd/winbindd_ccache_access.c  */
174
175 void winbindd_ccache_ntlm_auth(struct winbindd_cli_state *state);
176 enum winbindd_result winbindd_dual_ccache_ntlm_auth(struct winbindd_domain *domain,
177                                                 struct winbindd_cli_state *state);
178 void winbindd_ccache_save(struct winbindd_cli_state *state);
179
180 /* The following definitions come from winbindd/winbindd_cm.c  */
181 void winbind_msg_domain_offline(struct messaging_context *msg_ctx,
182                                 void *private_data,
183                                 uint32_t msg_type,
184                                 struct server_id server_id,
185                                 DATA_BLOB *data);
186 void winbind_msg_domain_online(struct messaging_context *msg_ctx,
187                                 void *private_data,
188                                 uint32_t msg_type,
189                                 struct server_id server_id,
190                                 DATA_BLOB *data);
191
192 void set_domain_offline(struct winbindd_domain *domain);
193 void set_domain_online_request(struct winbindd_domain *domain);
194
195 struct ndr_interface_table;
196 NTSTATUS wb_open_internal_pipe(TALLOC_CTX *mem_ctx,
197                                const struct ndr_interface_table *table,
198                                struct rpc_pipe_client **ret_pipe);
199 void invalidate_cm_connection(struct winbindd_domain *domain);
200 void close_conns_after_fork(void);
201 NTSTATUS init_dc_connection(struct winbindd_domain *domain, bool need_rw_dc);
202 NTSTATUS cm_connect_sam(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
203                         bool need_rw_dc,
204                         struct rpc_pipe_client **cli, struct policy_handle *sam_handle);
205 NTSTATUS cm_connect_lsa(struct winbindd_domain *domain, TALLOC_CTX *mem_ctx,
206                         struct rpc_pipe_client **cli, struct policy_handle *lsa_policy);
207 NTSTATUS cm_connect_lsat(struct winbindd_domain *domain,
208                          TALLOC_CTX *mem_ctx,
209                          struct rpc_pipe_client **cli,
210                          struct policy_handle *lsa_policy);
211 NTSTATUS cm_connect_netlogon(struct winbindd_domain *domain,
212                              struct rpc_pipe_client **cli);
213 NTSTATUS cm_connect_netlogon_secure(struct winbindd_domain *domain,
214                                     struct rpc_pipe_client **cli,
215                                     struct netlogon_creds_cli_context **ppdc);
216 bool fetch_current_dc_from_gencache(TALLOC_CTX *mem_ctx,
217                                     const char *domain_name,
218                                     char **p_dc_name, char **p_dc_ip);
219
220 /* The following definitions come from winbindd/winbindd_cred_cache.c  */
221
222 bool ccache_entry_exists(const char *username);
223 bool ccache_entry_identical(const char *username,
224                             uid_t uid,
225                             const char *ccname);
226 void ccache_remove_all_after_fork(void);
227 void ccache_regain_all_now(void);
228 NTSTATUS add_ccache_to_list(const char *princ_name,
229                             const char *ccname,
230                             const char *service,
231                             const char *username,
232                             const char *password,
233                             const char *realm,
234                             uid_t uid,
235                             time_t create_time,
236                             time_t ticket_end,
237                             time_t renew_until,
238                             bool postponed_request);
239 NTSTATUS remove_ccache(const char *username);
240 struct WINBINDD_MEMORY_CREDS *find_memory_creds_by_name(const char *username);
241 NTSTATUS winbindd_add_memory_creds(const char *username,
242                                    uid_t uid,
243                                    const char *pass);
244 NTSTATUS winbindd_delete_memory_creds(const char *username);
245 NTSTATUS winbindd_replace_memory_creds(const char *username,
246                                        const char *pass);
247
248 /* The following definitions come from winbindd/winbindd_creds.c  */
249
250 NTSTATUS winbindd_get_creds(struct winbindd_domain *domain,
251                             TALLOC_CTX *mem_ctx,
252                             const struct dom_sid *sid,
253                             struct netr_SamInfo3 **info3,
254                             const uint8_t *cached_nt_pass[NT_HASH_LEN],
255                             const uint8_t *cred_salt[NT_HASH_LEN]);
256 NTSTATUS winbindd_store_creds(struct winbindd_domain *domain,
257                               const char *user, 
258                               const char *pass, 
259                               struct netr_SamInfo3 *info3);
260 NTSTATUS winbindd_update_creds_by_info3(struct winbindd_domain *domain,
261                                         const char *user,
262                                         const char *pass,
263                                         struct netr_SamInfo3 *info3);
264 NTSTATUS winbindd_update_creds_by_name(struct winbindd_domain *domain,
265                                        const char *user,
266                                        const char *pass);
267
268 /* The following definitions come from winbindd/winbindd_domain.c  */
269
270 void setup_domain_child(struct winbindd_domain *domain);
271
272 /* The following definitions come from winbindd/winbindd_dual.c  */
273
274 struct dcerpc_binding_handle *dom_child_handle(struct winbindd_domain *domain);
275
276 struct tevent_req *wb_child_request_send(TALLOC_CTX *mem_ctx,
277                                          struct tevent_context *ev,
278                                          struct winbindd_child *child,
279                                          struct winbindd_request *request);
280 int wb_child_request_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
281                           struct winbindd_response **presponse, int *err);
282 struct tevent_req *wb_domain_request_send(TALLOC_CTX *mem_ctx,
283                                           struct tevent_context *ev,
284                                           struct winbindd_domain *domain,
285                                           struct winbindd_request *request);
286 int wb_domain_request_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
287                            struct winbindd_response **presponse, int *err);
288
289 void setup_child(struct winbindd_domain *domain, struct winbindd_child *child,
290                  const struct winbindd_child_dispatch_table *table,
291                  const char *logprefix,
292                  const char *logname);
293 void winbind_child_died(pid_t pid);
294 void winbindd_flush_negative_conn_cache(struct winbindd_domain *domain);
295 void winbind_msg_debug(struct messaging_context *msg_ctx,
296                          void *private_data,
297                          uint32_t msg_type,
298                          struct server_id server_id,
299                          DATA_BLOB *data);
300 void winbind_disconnect_dc_parent(struct messaging_context *msg_ctx,
301                                   void *private_data,
302                                   uint32_t msg_type,
303                                   struct server_id server_id,
304                                   DATA_BLOB *data);
305 void winbind_msg_offline(struct messaging_context *msg_ctx,
306                          void *private_data,
307                          uint32_t msg_type,
308                          struct server_id server_id,
309                          DATA_BLOB *data);
310 void winbind_msg_online(struct messaging_context *msg_ctx,
311                         void *private_data,
312                         uint32_t msg_type,
313                         struct server_id server_id,
314                         DATA_BLOB *data);
315 void winbind_msg_onlinestatus(struct messaging_context *msg_ctx,
316                               void *private_data,
317                               uint32_t msg_type,
318                               struct server_id server_id,
319                               DATA_BLOB *data);
320 void winbind_msg_dump_event_list(struct messaging_context *msg_ctx,
321                                  void *private_data,
322                                  uint32_t msg_type,
323                                  struct server_id server_id,
324                                  DATA_BLOB *data);
325 void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
326                                   void *private_data,
327                                   uint32_t msg_type,
328                                   struct server_id server_id,
329                                   DATA_BLOB *data);
330 void winbind_msg_ip_dropped(struct messaging_context *msg_ctx,
331                             void *private_data,
332                             uint32_t msg_type,
333                             struct server_id server_id,
334                             DATA_BLOB *data);
335 void winbind_msg_disconnect_dc(struct messaging_context *msg_ctx,
336                                void *private_data,
337                                uint32_t msg_type,
338                                struct server_id server_id,
339                                DATA_BLOB *data);
340 void winbind_msg_ip_dropped_parent(struct messaging_context *msg_ctx,
341                                    void *private_data,
342                                    uint32_t msg_type,
343                                    struct server_id server_id,
344                                    DATA_BLOB *data);
345 NTSTATUS winbindd_reinit_after_fork(const struct winbindd_child *myself,
346                                     const char *logfilename);
347 struct winbindd_domain *wb_child_domain(void);
348
349 /* The following definitions come from winbindd/winbindd_group.c  */
350 bool fill_grent(TALLOC_CTX *mem_ctx, struct winbindd_gr *gr,
351                 const char *dom_name, const char *gr_name, gid_t unix_gid);
352
353 struct db_context;
354 NTSTATUS winbindd_print_groupmembers(struct db_context *members,
355                                      TALLOC_CTX *mem_ctx,
356                                      int *num_members, char **result);
357
358
359 /* The following definitions come from winbindd/winbindd_idmap.c  */
360
361 void init_idmap_child(void);
362 struct winbindd_child *idmap_child(void);
363 struct dcerpc_binding_handle *idmap_child_handle(void);
364 struct idmap_domain *idmap_find_domain_with_sid(const char *domname,
365                                                 const struct dom_sid *sid);
366 const char *idmap_config_const_string(const char *domname, const char *option,
367                                       const char *def);
368 bool idmap_config_bool(const char *domname, const char *option, bool def);
369 int idmap_config_int(const char *domname, const char *option, int def);
370 bool domain_has_idmap_config(const char *domname);
371 bool lp_scan_idmap_domains(bool (*fn)(const char *domname,
372                                       void *private_data),
373                            void *private_data);
374
375 /* The following definitions come from winbindd/winbindd_locator.c  */
376
377 void init_locator_child(void);
378 struct winbindd_child *locator_child(void);
379 struct dcerpc_binding_handle *locator_child_handle(void);
380
381 /* The following definitions come from winbindd/winbindd_misc.c  */
382
383 void winbindd_list_trusted_domains(struct winbindd_cli_state *state);
384 enum winbindd_result winbindd_dual_list_trusted_domains(struct winbindd_domain *domain,
385                                                         struct winbindd_cli_state *state);
386 void winbindd_show_sequence(struct winbindd_cli_state *state);
387 void winbindd_domain_info(struct winbindd_cli_state *state);
388 void winbindd_dc_info(struct winbindd_cli_state *state);
389 void winbindd_ping(struct winbindd_cli_state *state);
390 void winbindd_info(struct winbindd_cli_state *state);
391 void winbindd_interface_version(struct winbindd_cli_state *state);
392 void winbindd_domain_name(struct winbindd_cli_state *state);
393 void winbindd_netbios_name(struct winbindd_cli_state *state);
394 void winbindd_priv_pipe_dir(struct winbindd_cli_state *state);
395
396 /* The following definitions come from winbindd/winbindd_ndr.c  */
397 struct ndr_print;
398 void ndr_print_winbindd_child(struct ndr_print *ndr,
399                               const char *name,
400                               const struct winbindd_child *r);
401 void ndr_print_winbindd_cm_conn(struct ndr_print *ndr,
402                                 const char *name,
403                                 const struct winbindd_cm_conn *r);
404 void ndr_print_winbindd_methods(struct ndr_print *ndr,
405                                 const char *name,
406                                 const struct winbindd_methods *r);
407 void ndr_print_winbindd_domain(struct ndr_print *ndr,
408                                const char *name,
409                                const struct winbindd_domain *r);
410
411 /* The following definitions come from winbindd/winbindd_pam.c  */
412
413 bool check_request_flags(uint32_t flags);
414 NTSTATUS append_auth_data(TALLOC_CTX *mem_ctx,
415                           struct winbindd_response *resp,
416                           uint32_t request_flags,
417                           uint16_t validation_level,
418                           union netr_Validation *validation,
419                           const char *name_domain,
420                           const char *name_user);
421 uid_t get_uid_from_request(struct winbindd_request *request);
422 struct winbindd_domain *find_auth_domain(uint8_t flags,
423                                          const char *domain_name);
424 enum winbindd_result winbindd_dual_pam_auth(struct winbindd_domain *domain,
425                                             struct winbindd_cli_state *state) ;
426 enum winbindd_result winbindd_dual_pam_auth_crap(struct winbindd_domain *domain,
427                                                  struct winbindd_cli_state *state) ;
428 enum winbindd_result winbindd_dual_pam_chauthtok(struct winbindd_domain *contact_domain,
429                                                  struct winbindd_cli_state *state);
430 enum winbindd_result winbindd_dual_pam_logoff(struct winbindd_domain *domain,
431                                               struct winbindd_cli_state *state) ;
432 enum winbindd_result winbindd_dual_pam_chng_pswd_auth_crap(struct winbindd_domain *domainSt, struct winbindd_cli_state *state);
433 NTSTATUS winbindd_pam_auth_pac_verify(struct winbindd_cli_state *state,
434                                       bool *p_is_trusted,
435                                       uint16_t *p_validation_level,
436                                       union netr_Validation **p_validation);
437
438 NTSTATUS winbind_dual_SamLogon(struct winbindd_domain *domain,
439                                TALLOC_CTX *mem_ctx,
440                                bool interactive,
441                                uint32_t logon_parameters,
442                                const char *name_user,
443                                const char *name_domain,
444                                const char *workstation,
445                                const uint8_t chal[8],
446                                DATA_BLOB lm_response,
447                                DATA_BLOB nt_response,
448                                uint8_t *authoritative,
449                                bool skip_sam,
450                                uint32_t *flags,
451                                uint16_t *_validation_level,
452                                union netr_Validation **_validation);
453
454 /* The following definitions come from winbindd/winbindd_util.c  */
455
456 struct winbindd_domain *domain_list(void);
457 struct winbindd_domain *wb_next_domain(struct winbindd_domain *domain);
458 bool set_routing_domain(struct winbindd_domain *domain,
459                         struct winbindd_domain *routing_domain);
460 bool add_trusted_domain_from_auth(uint16_t validation_level,
461                                   struct info3_text *info3,
462                                   struct info6_text *info6);
463 bool domain_is_forest_root(const struct winbindd_domain *domain);
464 void rescan_trusted_domains(struct tevent_context *ev, struct tevent_timer *te,
465                             struct timeval now, void *private_data);
466 enum winbindd_result winbindd_dual_init_connection(struct winbindd_domain *domain,
467                                                    struct winbindd_cli_state *state);
468 bool init_domain_list(void);
469 struct winbindd_domain *find_domain_from_name_noinit(const char *domain_name);
470 struct winbindd_domain *find_trust_from_name_noinit(const char *domain_name);
471 struct winbindd_domain *find_domain_from_name(const char *domain_name);
472 struct winbindd_domain *find_domain_from_sid_noinit(const struct dom_sid *sid);
473 struct winbindd_domain *find_trust_from_sid_noinit(const struct dom_sid *sid);
474 struct winbindd_domain *find_domain_from_sid(const struct dom_sid *sid);
475 struct winbindd_domain *find_our_domain(void);
476 struct winbindd_domain *find_default_route_domain(void);
477 struct winbindd_domain *find_lookup_domain_from_sid(const struct dom_sid *sid);
478 struct winbindd_domain *find_lookup_domain_from_name(const char *domain_name);
479 bool parse_domain_user(const char *domuser, fstring domain, fstring user);
480 bool parse_domain_user_talloc(TALLOC_CTX *mem_ctx, const char *domuser,
481                               char **domain, char **user);
482 bool canonicalize_username(fstring username_inout, fstring domain, fstring user);
483 void fill_domain_username(fstring name, const char *domain, const char *user, bool can_assume);
484 char *fill_domain_username_talloc(TALLOC_CTX *ctx,
485                                   const char *domain,
486                                   const char *user,
487                                   bool can_assume);
488 struct winbindd_cli_state *winbindd_client_list(void);
489 struct winbindd_cli_state *winbindd_client_list_tail(void);
490 struct winbindd_cli_state *
491 winbindd_client_list_prev(struct winbindd_cli_state *cli);
492 void winbindd_add_client(struct winbindd_cli_state *cli);
493 void winbindd_remove_client(struct winbindd_cli_state *cli);
494 void winbindd_promote_client(struct winbindd_cli_state *cli);
495 int winbindd_num_clients(void);
496 NTSTATUS lookup_usergroups_cached(TALLOC_CTX *mem_ctx,
497                                   const struct dom_sid *user_sid,
498                                   uint32_t *p_num_groups, struct dom_sid **user_sids);
499
500 NTSTATUS normalize_name_map(TALLOC_CTX *mem_ctx,
501                              const char *domain_name,
502                              const char *name,
503                              char **normalized);
504 NTSTATUS normalize_name_unmap(TALLOC_CTX *mem_ctx,
505                               char *name,
506                               char **normalized);
507
508 NTSTATUS resolve_username_to_alias(TALLOC_CTX *mem_ctx,
509                                    struct winbindd_domain *domain,
510                                    const char *name, char **alias);
511 NTSTATUS resolve_alias_to_username(TALLOC_CTX *mem_ctx,
512                                    struct winbindd_domain *domain,
513                                    const char *alias, char **name);
514
515 bool winbindd_can_contact_domain(struct winbindd_domain *domain);
516 void winbindd_set_locator_kdc_envs(const struct winbindd_domain *domain);
517 void winbindd_unset_locator_kdc_env(const struct winbindd_domain *domain);
518 void winbindd_set_locator_kdc_envs(const struct winbindd_domain *domain);
519 void winbindd_unset_locator_kdc_env(const struct winbindd_domain *domain);
520 void set_auth_errors(struct winbindd_response *resp, NTSTATUS result);
521 bool is_domain_offline(const struct winbindd_domain *domain);
522 bool is_domain_online(const struct winbindd_domain *domain);
523 bool parse_sidlist(TALLOC_CTX *mem_ctx, const char *sidstr,
524                    struct dom_sid **sids, uint32_t *num_sids);
525 bool parse_xidlist(TALLOC_CTX *mem_ctx, const char *xidstr,
526                    struct unixid **pxids, uint32_t *pnum_xids);
527
528 /* The following definitions come from winbindd/winbindd_wins.c  */
529
530 void winbindd_wins_byname(struct winbindd_cli_state *state);
531
532 enum winbindd_result winbindd_dual_ping(struct winbindd_domain *domain,
533                                         struct winbindd_cli_state *state);
534
535 struct dcerpc_binding_handle *wbint_binding_handle(TALLOC_CTX *mem_ctx,
536                                                 struct winbindd_domain *domain,
537                                                 struct winbindd_child *child);
538 enum winbindd_result winbindd_dual_ndrcmd(struct winbindd_domain *domain,
539                                           struct winbindd_cli_state *state);
540
541 struct tevent_req *wb_lookupsid_send(TALLOC_CTX *mem_ctx,
542                                      struct tevent_context *ev,
543                                      const struct dom_sid *sid);
544 NTSTATUS wb_lookupsid_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
545                            enum lsa_SidType *type, const char **domain,
546                            const char **name);
547
548 struct tevent_req *winbindd_lookupsid_send(TALLOC_CTX *mem_ctx,
549                                            struct tevent_context *ev,
550                                            struct winbindd_cli_state *cli,
551                                            struct winbindd_request *request);
552 NTSTATUS winbindd_lookupsid_recv(struct tevent_req *req,
553                                  struct winbindd_response *response);
554
555 struct tevent_req *winbindd_lookupsids_send(TALLOC_CTX *mem_ctx,
556                                             struct tevent_context *ev,
557                                             struct winbindd_cli_state *cli,
558                                             struct winbindd_request *request);
559 NTSTATUS winbindd_lookupsids_recv(struct tevent_req *req,
560                                   struct winbindd_response *response);
561
562 struct tevent_req *wb_lookupname_send(TALLOC_CTX *mem_ctx,
563                                       struct tevent_context *ev,
564                                       const char *namespace,
565                                       const char *dom_name,
566                                       const char *name,
567                                       uint32_t flags);
568 NTSTATUS wb_lookupname_recv(struct tevent_req *req, struct dom_sid *sid,
569                             enum lsa_SidType *type);
570
571 struct tevent_req *winbindd_lookupname_send(TALLOC_CTX *mem_ctx,
572                                             struct tevent_context *ev,
573                                             struct winbindd_cli_state *cli,
574                                             struct winbindd_request *request);
575 NTSTATUS winbindd_lookupname_recv(struct tevent_req *req,
576                                   struct winbindd_response *response);
577
578 struct tevent_req *winbindd_allocate_uid_send(TALLOC_CTX *mem_ctx,
579                                               struct tevent_context *ev,
580                                               struct winbindd_cli_state *cli,
581                                               struct winbindd_request *request);
582 NTSTATUS winbindd_allocate_uid_recv(struct tevent_req *req,
583                                     struct winbindd_response *response);
584
585 struct tevent_req *winbindd_allocate_gid_send(TALLOC_CTX *mem_ctx,
586                                               struct tevent_context *ev,
587                                               struct winbindd_cli_state *cli,
588                                               struct winbindd_request *request);
589 NTSTATUS winbindd_allocate_gid_recv(struct tevent_req *req,
590                                     struct winbindd_response *response);
591
592 struct tevent_req *wb_queryuser_send(TALLOC_CTX *mem_ctx,
593                                      struct tevent_context *ev,
594                                      const struct dom_sid *user_sid);
595 NTSTATUS wb_queryuser_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
596                            struct wbint_userinfo **pinfo);
597
598 struct tevent_req *wb_getpwsid_send(TALLOC_CTX *mem_ctx,
599                                     struct tevent_context *ev,
600                                     const struct dom_sid *user_sid,
601                                     struct winbindd_pw *pw);
602 NTSTATUS wb_getpwsid_recv(struct tevent_req *req);
603
604 struct tevent_req *winbindd_getpwsid_send(TALLOC_CTX *mem_ctx,
605                                           struct tevent_context *ev,
606                                           struct winbindd_cli_state *cli,
607                                           struct winbindd_request *request);
608 NTSTATUS winbindd_getpwsid_recv(struct tevent_req *req,
609                                 struct winbindd_response *response);
610
611 struct tevent_req *winbindd_getpwnam_send(TALLOC_CTX *mem_ctx,
612                                           struct tevent_context *ev,
613                                           struct winbindd_cli_state *cli,
614                                           struct winbindd_request *request);
615 NTSTATUS winbindd_getpwnam_recv(struct tevent_req *req,
616                                 struct winbindd_response *response);
617
618 struct tevent_req *winbindd_getpwuid_send(TALLOC_CTX *mem_ctx,
619                                           struct tevent_context *ev,
620                                           struct winbindd_cli_state *cli,
621                                           struct winbindd_request *request);
622 NTSTATUS winbindd_getpwuid_recv(struct tevent_req *req,
623                                 struct winbindd_response *response);
624 struct tevent_req *wb_lookupuseraliases_send(TALLOC_CTX *mem_ctx,
625                                              struct tevent_context *ev,
626                                              struct winbindd_domain *domain,
627                                              int num_sids,
628                                              const struct dom_sid *sids);
629 NTSTATUS wb_lookupuseraliases_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
630                                    uint32_t *num_aliases, uint32_t **aliases);
631 struct tevent_req *winbindd_getsidaliases_send(TALLOC_CTX *mem_ctx,
632                                                struct tevent_context *ev,
633                                                struct winbindd_cli_state *cli,
634                                                struct winbindd_request *request);
635 NTSTATUS winbindd_getsidaliases_recv(struct tevent_req *req,
636                                      struct winbindd_response *response);
637 struct tevent_req *wb_lookupusergroups_send(TALLOC_CTX *mem_ctx,
638                                             struct tevent_context *ev,
639                                             const struct dom_sid *sid);
640 NTSTATUS wb_lookupusergroups_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
641                                   int *num_sids, struct dom_sid **sids);
642
643 struct tevent_req *winbindd_getuserdomgroups_send(TALLOC_CTX *mem_ctx,
644                                                   struct tevent_context *ev,
645                                                   struct winbindd_cli_state *cli,
646                                                   struct winbindd_request *request);
647 NTSTATUS winbindd_getuserdomgroups_recv(struct tevent_req *req,
648                                         struct winbindd_response *response);
649 struct tevent_req *wb_gettoken_send(TALLOC_CTX *mem_ctx,
650                                     struct tevent_context *ev,
651                                     const struct dom_sid *sid,
652                                     bool expand_local_aliases);
653 NTSTATUS wb_gettoken_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
654                           int *num_sids, struct dom_sid **sids);
655 struct tevent_req *winbindd_getgroups_send(TALLOC_CTX *mem_ctx,
656                                            struct tevent_context *ev,
657                                            struct winbindd_cli_state *cli,
658                                            struct winbindd_request *request);
659 NTSTATUS winbindd_getgroups_recv(struct tevent_req *req,
660                                  struct winbindd_response *response);
661
662 struct tevent_req *wb_seqnum_send(TALLOC_CTX *mem_ctx,
663                                   struct tevent_context *ev,
664                                   struct winbindd_domain *domain);
665 NTSTATUS wb_seqnum_recv(struct tevent_req *req, uint32_t *seqnum);
666
667 struct tevent_req *wb_seqnums_send(TALLOC_CTX *mem_ctx,
668                                    struct tevent_context *ev);
669 NTSTATUS wb_seqnums_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
670                          int *num_domains, struct winbindd_domain ***domains,
671                          NTSTATUS **stati, uint32_t **seqnums);
672
673 struct tevent_req *winbindd_show_sequence_send(TALLOC_CTX *mem_ctx,
674                                                struct tevent_context *ev,
675                                                struct winbindd_cli_state *cli,
676                                                struct winbindd_request *request);
677 NTSTATUS winbindd_show_sequence_recv(struct tevent_req *req,
678                                      struct winbindd_response *response);
679
680 struct tevent_req *wb_group_members_send(TALLOC_CTX *mem_ctx,
681                                          struct tevent_context *ev,
682                                          const struct dom_sid *sid,
683                                          enum lsa_SidType type,
684                                          int max_depth);
685 NTSTATUS wb_group_members_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
686                                struct db_context **members);
687 NTSTATUS add_member_to_db(struct db_context *db, struct dom_sid *sid,
688                           const char *name);
689
690 struct tevent_req *wb_getgrsid_send(TALLOC_CTX *mem_ctx,
691                                     struct tevent_context *ev,
692                                     const struct dom_sid *group_sid,
693                                     int max_nesting);
694 NTSTATUS wb_getgrsid_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
695                           const char **domname, const char **name, gid_t *gid,
696                           struct db_context **members);
697
698 struct tevent_req *winbindd_getgrgid_send(TALLOC_CTX *mem_ctx,
699                                           struct tevent_context *ev,
700                                           struct winbindd_cli_state *cli,
701                                           struct winbindd_request *request);
702 NTSTATUS winbindd_getgrgid_recv(struct tevent_req *req,
703                                 struct winbindd_response *response);
704
705 struct tevent_req *winbindd_getgrnam_send(TALLOC_CTX *mem_ctx,
706                                           struct tevent_context *ev,
707                                           struct winbindd_cli_state *cli,
708                                           struct winbindd_request *request);
709 NTSTATUS winbindd_getgrnam_recv(struct tevent_req *req,
710                                 struct winbindd_response *response);
711
712 struct tevent_req *winbindd_getusersids_send(TALLOC_CTX *mem_ctx,
713                                              struct tevent_context *ev,
714                                              struct winbindd_cli_state *cli,
715                                              struct winbindd_request *request);
716 NTSTATUS winbindd_getusersids_recv(struct tevent_req *req,
717                                    struct winbindd_response *response);
718
719 struct tevent_req *winbindd_lookuprids_send(TALLOC_CTX *mem_ctx,
720                                             struct tevent_context *ev,
721                                             struct winbindd_cli_state *cli,
722                                             struct winbindd_request *request);
723 NTSTATUS winbindd_lookuprids_recv(struct tevent_req *req,
724                                   struct winbindd_response *response);
725
726 struct tevent_req *wb_query_user_list_send(TALLOC_CTX *mem_ctx,
727                                            struct tevent_context *ev,
728                                            struct winbindd_domain *domain);
729 NTSTATUS wb_query_user_list_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
730                                  char **users);
731
732 struct tevent_req *wb_query_group_list_send(TALLOC_CTX *mem_ctx,
733                                             struct tevent_context *ev,
734                                             struct winbindd_domain *domain);
735 NTSTATUS wb_query_group_list_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
736                                   int *num_users,
737                                   struct wbint_Principal **groups);
738
739 struct tevent_req *wb_next_pwent_send(TALLOC_CTX *mem_ctx,
740                                       struct tevent_context *ev,
741                                       struct getpwent_state *gstate,
742                                       struct winbindd_pw *pw);
743 NTSTATUS wb_next_pwent_recv(struct tevent_req *req);
744
745 struct tevent_req *winbindd_setpwent_send(TALLOC_CTX *mem_ctx,
746                                           struct tevent_context *ev,
747                                           struct winbindd_cli_state *cli,
748                                           struct winbindd_request *request);
749 NTSTATUS winbindd_setpwent_recv(struct tevent_req *req,
750                                 struct winbindd_response *presp);
751
752 struct tevent_req *winbindd_getpwent_send(TALLOC_CTX *mem_ctx,
753                                           struct tevent_context *ev,
754                                           struct winbindd_cli_state *cli,
755                                           struct winbindd_request *request);
756 NTSTATUS winbindd_getpwent_recv(struct tevent_req *req,
757                                 struct winbindd_response *response);
758
759 struct tevent_req *winbindd_endpwent_send(TALLOC_CTX *mem_ctx,
760                                           struct tevent_context *ev,
761                                           struct winbindd_cli_state *cli,
762                                           struct winbindd_request *request);
763 NTSTATUS winbindd_endpwent_recv(struct tevent_req *req,
764                                 struct winbindd_response *response);
765
766 struct tevent_req *winbindd_dsgetdcname_send(TALLOC_CTX *mem_ctx,
767                                              struct tevent_context *ev,
768                                              struct winbindd_cli_state *cli,
769                                              struct winbindd_request *request);
770 NTSTATUS winbindd_dsgetdcname_recv(struct tevent_req *req,
771                                    struct winbindd_response *response);
772
773 struct tevent_req *wb_dsgetdcname_send(TALLOC_CTX *mem_ctx,
774                                        struct tevent_context *ev,
775                                        const char *domain_name,
776                                        const struct GUID *domain_guid,
777                                        const char *site_name,
778                                        uint32_t flags);
779 NTSTATUS wb_dsgetdcname_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
780                              struct netr_DsRGetDCNameInfo **pdcinfo);
781 NTSTATUS wb_dsgetdcname_gencache_set(const char *domname,
782                                      struct netr_DsRGetDCNameInfo *dcinfo);
783 NTSTATUS wb_dsgetdcname_gencache_get(TALLOC_CTX *mem_ctx,
784                                      const char *domname,
785                                      struct netr_DsRGetDCNameInfo **dcinfo);
786
787 struct tevent_req *winbindd_getdcname_send(TALLOC_CTX *mem_ctx,
788                                            struct tevent_context *ev,
789                                            struct winbindd_cli_state *cli,
790                                            struct winbindd_request *request);
791 NTSTATUS winbindd_getdcname_recv(struct tevent_req *req,
792                                  struct winbindd_response *response);
793
794 struct tevent_req *wb_next_grent_send(TALLOC_CTX *mem_ctx,
795                                       struct tevent_context *ev,
796                                       int max_nesting,
797                                       struct getgrent_state *gstate,
798                                       struct winbindd_gr *gr);
799 NTSTATUS wb_next_grent_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
800                             struct db_context **members);
801
802 struct tevent_req *winbindd_setgrent_send(TALLOC_CTX *mem_ctx,
803                                           struct tevent_context *ev,
804                                           struct winbindd_cli_state *cli,
805                                           struct winbindd_request *request);
806 NTSTATUS winbindd_setgrent_recv(struct tevent_req *req,
807                                 struct winbindd_response *response);
808 struct tevent_req *winbindd_getgrent_send(TALLOC_CTX *mem_ctx,
809                                           struct tevent_context *ev,
810                                           struct winbindd_cli_state *cli,
811                                           struct winbindd_request *request);
812 NTSTATUS winbindd_getgrent_recv(struct tevent_req *req,
813                                 struct winbindd_response *response);
814 struct tevent_req *winbindd_endgrent_send(TALLOC_CTX *mem_ctx,
815                                           struct tevent_context *ev,
816                                           struct winbindd_cli_state *cli,
817                                           struct winbindd_request *request);
818 NTSTATUS winbindd_endgrent_recv(struct tevent_req *req,
819                                 struct winbindd_response *response);
820
821 struct tevent_req *winbindd_list_users_send(TALLOC_CTX *mem_ctx,
822                                             struct tevent_context *ev,
823                                             struct winbindd_cli_state *cli,
824                                             struct winbindd_request *request);
825 NTSTATUS winbindd_list_users_recv(struct tevent_req *req,
826                                   struct winbindd_response *response);
827
828 struct tevent_req *winbindd_list_groups_send(TALLOC_CTX *mem_ctx,
829                                              struct tevent_context *ev,
830                                              struct winbindd_cli_state *cli,
831                                              struct winbindd_request *request);
832 NTSTATUS winbindd_list_groups_recv(struct tevent_req *req,
833                                    struct winbindd_response *response);
834
835 struct tevent_req *winbindd_check_machine_acct_send(TALLOC_CTX *mem_ctx,
836                                                     struct tevent_context *ev,
837                                                     struct winbindd_cli_state *cli,
838                                                     struct winbindd_request *request);
839 NTSTATUS winbindd_check_machine_acct_recv(struct tevent_req *req,
840                                           struct winbindd_response *presp);
841
842 struct tevent_req *winbindd_ping_dc_send(TALLOC_CTX *mem_ctx,
843                                          struct tevent_context *ev,
844                                          struct winbindd_cli_state *cli,
845                                          struct winbindd_request *request);
846 NTSTATUS winbindd_ping_dc_recv(struct tevent_req *req,
847                                struct winbindd_response *presp);
848
849 struct tevent_req *winbindd_change_machine_acct_send(TALLOC_CTX *mem_ctx,
850                                                      struct tevent_context *ev,
851                                                      struct winbindd_cli_state *cli,
852                                                      struct winbindd_request *request);
853 NTSTATUS winbindd_change_machine_acct_recv(struct tevent_req *req,
854                                            struct winbindd_response *presp);
855
856 struct tevent_req *winbindd_pam_auth_send(TALLOC_CTX *mem_ctx,
857                                           struct tevent_context *ev,
858                                           struct winbindd_cli_state *cli,
859                                           struct winbindd_request *request);
860 NTSTATUS winbindd_pam_auth_recv(struct tevent_req *req,
861                                 struct winbindd_response *response);
862
863 struct tevent_req *winbindd_pam_auth_crap_send(
864         TALLOC_CTX *mem_ctx,
865         struct tevent_context *ev,
866         struct winbindd_cli_state *cli,
867         struct winbindd_request *request);
868 NTSTATUS winbindd_pam_auth_crap_recv(struct tevent_req *req,
869                                      struct winbindd_response *response);
870
871 struct tevent_req *winbindd_pam_chauthtok_send(
872         TALLOC_CTX *mem_ctx,
873         struct tevent_context *ev,
874         struct winbindd_cli_state *cli,
875         struct winbindd_request *request);
876 NTSTATUS winbindd_pam_chauthtok_recv(struct tevent_req *req,
877                                      struct winbindd_response *response);
878
879 struct tevent_req *winbindd_pam_logoff_send(TALLOC_CTX *mem_ctx,
880                                             struct tevent_context *ev,
881                                             struct winbindd_cli_state *cli,
882                                             struct winbindd_request *request);
883 NTSTATUS winbindd_pam_logoff_recv(struct tevent_req *req,
884                                   struct winbindd_response *response);
885
886 struct tevent_req *winbindd_pam_chng_pswd_auth_crap_send(
887         TALLOC_CTX *mem_ctx,
888         struct tevent_context *ev,
889         struct winbindd_cli_state *cli,
890         struct winbindd_request *request);
891 NTSTATUS winbindd_pam_chng_pswd_auth_crap_recv(
892         struct tevent_req *req,
893         struct winbindd_response *response);
894
895 struct tevent_req *wb_lookupsids_send(TALLOC_CTX *mem_ctx,
896                                       struct tevent_context *ev,
897                                       struct dom_sid *sids,
898                                       uint32_t num_sids);
899 NTSTATUS wb_lookupsids_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
900                             struct lsa_RefDomainList **domains,
901                             struct lsa_TransNameArray **names);
902
903 struct tevent_req *wb_sids2xids_send(TALLOC_CTX *mem_ctx,
904                                      struct tevent_context *ev,
905                                      const struct dom_sid *sids,
906                                      const uint32_t num_sids);
907 NTSTATUS wb_sids2xids_recv(struct tevent_req *req,
908                            struct unixid xids[], uint32_t num_xids);
909 struct tevent_req *winbindd_sids_to_xids_send(TALLOC_CTX *mem_ctx,
910                                               struct tevent_context *ev,
911                                               struct winbindd_cli_state *cli,
912                                               struct winbindd_request *request);
913 NTSTATUS winbindd_sids_to_xids_recv(struct tevent_req *req,
914                                     struct winbindd_response *response);
915 struct tevent_req *wb_xids2sids_send(TALLOC_CTX *mem_ctx,
916                                      struct tevent_context *ev,
917                                      struct unixid *xids,
918                                      uint32_t num_xids);
919 NTSTATUS wb_xids2sids_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
920                            struct dom_sid **sids);
921 struct tevent_req *winbindd_xids_to_sids_send(TALLOC_CTX *mem_ctx,
922                                               struct tevent_context *ev,
923                                               struct winbindd_cli_state *cli,
924                                               struct winbindd_request *request);
925 NTSTATUS winbindd_xids_to_sids_recv(struct tevent_req *req,
926                                     struct winbindd_response *response);
927 struct tevent_req *winbindd_wins_byip_send(TALLOC_CTX *mem_ctx,
928                                            struct tevent_context *ev,
929                                            struct winbindd_cli_state *cli,
930                                            struct winbindd_request *request);
931 NTSTATUS winbindd_wins_byip_recv(struct tevent_req *req,
932                                  struct winbindd_response *presp);
933 struct tevent_req *winbindd_wins_byname_send(TALLOC_CTX *mem_ctx,
934                                              struct tevent_context *ev,
935                                              struct winbindd_cli_state *cli,
936                                              struct winbindd_request *request);
937 NTSTATUS winbindd_wins_byname_recv(struct tevent_req *req,
938                                    struct winbindd_response *presp);
939
940
941 /* The following definitions come from winbindd/winbindd_samr.c  */
942
943 NTSTATUS open_internal_samr_conn(TALLOC_CTX *mem_ctx,
944                                  struct winbindd_domain *domain,
945                                  struct rpc_pipe_client **samr_pipe,
946                                  struct policy_handle *samr_domain_hnd);
947 NTSTATUS open_internal_lsa_conn(TALLOC_CTX *mem_ctx,
948                                 struct rpc_pipe_client **lsa_pipe,
949                                 struct policy_handle *lsa_hnd);
950
951 /* The following definitions come from winbindd/winbindd_irpc.c  */
952 NTSTATUS wb_irpc_register(void);
953
954 /* The following definitions come from winbindd/winbindd_reconnect.c  */
955 bool reconnect_need_retry(NTSTATUS status, struct winbindd_domain *domain);
956
957 /* The following definitions come from winbindd/winbindd_gpupdate.c  */
958 void gpupdate_init(void);
959
960 /* The following comes from winbindd/winbindd_dual_srv.c */
961 bool reset_cm_connection_on_error(struct winbindd_domain *domain,
962                                   struct dcerpc_binding_handle *b,
963                                   NTSTATUS status);
964
965 #endif /*  _WINBINDD_PROTO_H_  */