39cdef54531005d5c859b9ec55e6eedd704d6aed
[nivanova/samba-autobuild/.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 bool fetch_current_dc_from_gencache(TALLOC_CTX *mem_ctx,
214                                     const char *domain_name,
215                                     char **p_dc_name, char **p_dc_ip);
216
217 /* The following definitions come from winbindd/winbindd_cred_cache.c  */
218
219 bool ccache_entry_exists(const char *username);
220 bool ccache_entry_identical(const char *username,
221                             uid_t uid,
222                             const char *ccname);
223 void ccache_remove_all_after_fork(void);
224 void ccache_regain_all_now(void);
225 NTSTATUS add_ccache_to_list(const char *princ_name,
226                             const char *ccname,
227                             const char *service,
228                             const char *username,
229                             const char *password,
230                             const char *realm,
231                             uid_t uid,
232                             time_t create_time,
233                             time_t ticket_end,
234                             time_t renew_until,
235                             bool postponed_request);
236 NTSTATUS remove_ccache(const char *username);
237 struct WINBINDD_MEMORY_CREDS *find_memory_creds_by_name(const char *username);
238 NTSTATUS winbindd_add_memory_creds(const char *username,
239                                    uid_t uid,
240                                    const char *pass);
241 NTSTATUS winbindd_delete_memory_creds(const char *username);
242 NTSTATUS winbindd_replace_memory_creds(const char *username,
243                                        const char *pass);
244
245 /* The following definitions come from winbindd/winbindd_creds.c  */
246
247 NTSTATUS winbindd_get_creds(struct winbindd_domain *domain,
248                             TALLOC_CTX *mem_ctx,
249                             const struct dom_sid *sid,
250                             struct netr_SamInfo3 **info3,
251                             const uint8_t *cached_nt_pass[NT_HASH_LEN],
252                             const uint8_t *cred_salt[NT_HASH_LEN]);
253 NTSTATUS winbindd_store_creds(struct winbindd_domain *domain,
254                               const char *user, 
255                               const char *pass, 
256                               struct netr_SamInfo3 *info3);
257 NTSTATUS winbindd_update_creds_by_info3(struct winbindd_domain *domain,
258                                         const char *user,
259                                         const char *pass,
260                                         struct netr_SamInfo3 *info3);
261 NTSTATUS winbindd_update_creds_by_name(struct winbindd_domain *domain,
262                                        const char *user,
263                                        const char *pass);
264
265 /* The following definitions come from winbindd/winbindd_domain.c  */
266
267 void setup_domain_child(struct winbindd_domain *domain);
268
269 /* The following definitions come from winbindd/winbindd_dual.c  */
270
271 struct dcerpc_binding_handle *dom_child_handle(struct winbindd_domain *domain);
272 struct winbindd_child *choose_domain_child(struct winbindd_domain *domain);
273
274 struct tevent_req *wb_child_request_send(TALLOC_CTX *mem_ctx,
275                                          struct tevent_context *ev,
276                                          struct winbindd_child *child,
277                                          struct winbindd_request *request);
278 int wb_child_request_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
279                           struct winbindd_response **presponse, int *err);
280 struct tevent_req *wb_domain_request_send(TALLOC_CTX *mem_ctx,
281                                           struct tevent_context *ev,
282                                           struct winbindd_domain *domain,
283                                           struct winbindd_request *request);
284 int wb_domain_request_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
285                            struct winbindd_response **presponse, int *err);
286
287 void setup_child(struct winbindd_domain *domain, struct winbindd_child *child,
288                  const struct winbindd_child_dispatch_table *table,
289                  const char *logprefix,
290                  const char *logname);
291 void winbind_child_died(pid_t pid);
292 void winbindd_flush_negative_conn_cache(struct winbindd_domain *domain);
293 void winbind_msg_debug(struct messaging_context *msg_ctx,
294                          void *private_data,
295                          uint32_t msg_type,
296                          struct server_id server_id,
297                          DATA_BLOB *data);
298 void winbind_msg_offline(struct messaging_context *msg_ctx,
299                          void *private_data,
300                          uint32_t msg_type,
301                          struct server_id server_id,
302                          DATA_BLOB *data);
303 void winbind_msg_online(struct messaging_context *msg_ctx,
304                         void *private_data,
305                         uint32_t msg_type,
306                         struct server_id server_id,
307                         DATA_BLOB *data);
308 void winbind_msg_onlinestatus(struct messaging_context *msg_ctx,
309                               void *private_data,
310                               uint32_t msg_type,
311                               struct server_id server_id,
312                               DATA_BLOB *data);
313 void winbind_msg_dump_event_list(struct messaging_context *msg_ctx,
314                                  void *private_data,
315                                  uint32_t msg_type,
316                                  struct server_id server_id,
317                                  DATA_BLOB *data);
318 void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx,
319                                   void *private_data,
320                                   uint32_t msg_type,
321                                   struct server_id server_id,
322                                   DATA_BLOB *data);
323 void winbind_msg_ip_dropped(struct messaging_context *msg_ctx,
324                             void *private_data,
325                             uint32_t msg_type,
326                             struct server_id server_id,
327                             DATA_BLOB *data);
328 void winbind_msg_ip_dropped_parent(struct messaging_context *msg_ctx,
329                                    void *private_data,
330                                    uint32_t msg_type,
331                                    struct server_id server_id,
332                                    DATA_BLOB *data);
333 NTSTATUS winbindd_reinit_after_fork(const struct winbindd_child *myself,
334                                     const char *logfilename);
335 struct winbindd_domain *wb_child_domain(void);
336
337 /* The following definitions come from winbindd/winbindd_group.c  */
338 bool fill_grent(TALLOC_CTX *mem_ctx, struct winbindd_gr *gr,
339                 const char *dom_name, const char *gr_name, gid_t unix_gid);
340
341 struct db_context;
342 NTSTATUS winbindd_print_groupmembers(struct db_context *members,
343                                      TALLOC_CTX *mem_ctx,
344                                      int *num_members, char **result);
345
346
347 /* The following definitions come from winbindd/winbindd_idmap.c  */
348
349 void init_idmap_child(void);
350 struct winbindd_child *idmap_child(void);
351 struct idmap_domain *idmap_find_domain_with_sid(const char *domname,
352                                                 const struct dom_sid *sid);
353 const char *idmap_config_const_string(const char *domname, const char *option,
354                                       const char *def);
355 bool idmap_config_bool(const char *domname, const char *option, bool def);
356 int idmap_config_int(const char *domname, const char *option, int def);
357 bool domain_has_idmap_config(const char *domname);
358 bool lp_scan_idmap_domains(bool (*fn)(const char *domname,
359                                       void *private_data),
360                            void *private_data);
361
362 /* The following definitions come from winbindd/winbindd_locator.c  */
363
364 void init_locator_child(void);
365 struct winbindd_child *locator_child(void);
366
367 /* The following definitions come from winbindd/winbindd_misc.c  */
368
369 void winbindd_list_trusted_domains(struct winbindd_cli_state *state);
370 enum winbindd_result winbindd_dual_list_trusted_domains(struct winbindd_domain *domain,
371                                                         struct winbindd_cli_state *state);
372 void winbindd_show_sequence(struct winbindd_cli_state *state);
373 void winbindd_domain_info(struct winbindd_cli_state *state);
374 void winbindd_dc_info(struct winbindd_cli_state *state);
375 void winbindd_ping(struct winbindd_cli_state *state);
376 void winbindd_info(struct winbindd_cli_state *state);
377 void winbindd_interface_version(struct winbindd_cli_state *state);
378 void winbindd_domain_name(struct winbindd_cli_state *state);
379 void winbindd_netbios_name(struct winbindd_cli_state *state);
380 void winbindd_priv_pipe_dir(struct winbindd_cli_state *state);
381
382 /* The following definitions come from winbindd/winbindd_ndr.c  */
383 struct ndr_print;
384 void ndr_print_winbindd_child(struct ndr_print *ndr,
385                               const char *name,
386                               const struct winbindd_child *r);
387 void ndr_print_winbindd_cm_conn(struct ndr_print *ndr,
388                                 const char *name,
389                                 const struct winbindd_cm_conn *r);
390 void ndr_print_winbindd_methods(struct ndr_print *ndr,
391                                 const char *name,
392                                 const struct winbindd_methods *r);
393 void ndr_print_winbindd_domain(struct ndr_print *ndr,
394                                const char *name,
395                                const struct winbindd_domain *r);
396
397 /* The following definitions come from winbindd/winbindd_pam.c  */
398
399 bool check_request_flags(uint32_t flags);
400 NTSTATUS append_auth_data(TALLOC_CTX *mem_ctx,
401                           struct winbindd_response *resp,
402                           uint32_t request_flags,
403                           uint16_t validation_level,
404                           union netr_Validation *validation,
405                           const char *name_domain,
406                           const char *name_user);
407 uid_t get_uid_from_request(struct winbindd_request *request);
408 struct winbindd_domain *find_auth_domain(uint8_t flags,
409                                          const char *domain_name);
410 enum winbindd_result winbindd_dual_pam_auth(struct winbindd_domain *domain,
411                                             struct winbindd_cli_state *state) ;
412 enum winbindd_result winbindd_dual_pam_auth_crap(struct winbindd_domain *domain,
413                                                  struct winbindd_cli_state *state) ;
414 enum winbindd_result winbindd_dual_pam_chauthtok(struct winbindd_domain *contact_domain,
415                                                  struct winbindd_cli_state *state);
416 enum winbindd_result winbindd_dual_pam_logoff(struct winbindd_domain *domain,
417                                               struct winbindd_cli_state *state) ;
418 enum winbindd_result winbindd_dual_pam_chng_pswd_auth_crap(struct winbindd_domain *domainSt, struct winbindd_cli_state *state);
419 NTSTATUS winbindd_pam_auth_pac_send(struct winbindd_cli_state *state,
420                                     struct netr_SamInfo3 **info3);
421
422 NTSTATUS winbind_dual_SamLogon(struct winbindd_domain *domain,
423                                TALLOC_CTX *mem_ctx,
424                                uint32_t logon_parameters,
425                                const char *name_user,
426                                const char *name_domain,
427                                const char *workstation,
428                                const uint8_t chal[8],
429                                DATA_BLOB lm_response,
430                                DATA_BLOB nt_response,
431                                uint8_t *authoritative,
432                                bool skip_sam,
433                                uint32_t *flags,
434                                uint16_t *_validation_level,
435                                union netr_Validation **_validation);
436
437 /* The following definitions come from winbindd/winbindd_util.c  */
438
439 struct winbindd_domain *domain_list(void);
440 struct winbindd_domain *wb_next_domain(struct winbindd_domain *domain);
441 bool set_routing_domain(struct winbindd_domain *domain,
442                         const struct winbindd_domain *routing_domain);
443 bool add_trusted_domain_from_auth(uint16_t validation_level,
444                                   struct info3_text *info3,
445                                   struct info6_text *info6);
446 bool domain_is_forest_root(const struct winbindd_domain *domain);
447 void rescan_trusted_domains(struct tevent_context *ev, struct tevent_timer *te,
448                             struct timeval now, void *private_data);
449 enum winbindd_result winbindd_dual_init_connection(struct winbindd_domain *domain,
450                                                    struct winbindd_cli_state *state);
451 bool init_domain_list(void);
452 struct winbindd_domain *find_domain_from_name_noinit(const char *domain_name);
453 struct winbindd_domain *find_trust_from_name_noinit(const char *domain_name);
454 struct winbindd_domain *find_domain_from_name(const char *domain_name);
455 struct winbindd_domain *find_domain_from_sid_noinit(const struct dom_sid *sid);
456 struct winbindd_domain *find_trust_from_sid_noinit(const struct dom_sid *sid);
457 struct winbindd_domain *find_domain_from_sid(const struct dom_sid *sid);
458 struct winbindd_domain *find_our_domain(void);
459 struct winbindd_domain *find_default_route_domain(void);
460 struct winbindd_domain *find_lookup_domain_from_sid(const struct dom_sid *sid);
461 struct winbindd_domain *find_lookup_domain_from_name(const char *domain_name);
462 bool parse_domain_user(const char *domuser, fstring domain, fstring user);
463 bool parse_domain_user_talloc(TALLOC_CTX *mem_ctx, const char *domuser,
464                               char **domain, char **user);
465 bool canonicalize_username(fstring username_inout, fstring domain, fstring user);
466 void fill_domain_username(fstring name, const char *domain, const char *user, bool can_assume);
467 char *fill_domain_username_talloc(TALLOC_CTX *ctx,
468                                   const char *domain,
469                                   const char *user,
470                                   bool can_assume);
471 struct winbindd_cli_state *winbindd_client_list(void);
472 struct winbindd_cli_state *winbindd_client_list_tail(void);
473 struct winbindd_cli_state *
474 winbindd_client_list_prev(struct winbindd_cli_state *cli);
475 void winbindd_add_client(struct winbindd_cli_state *cli);
476 void winbindd_remove_client(struct winbindd_cli_state *cli);
477 void winbindd_promote_client(struct winbindd_cli_state *cli);
478 int winbindd_num_clients(void);
479 NTSTATUS lookup_usergroups_cached(TALLOC_CTX *mem_ctx,
480                                   const struct dom_sid *user_sid,
481                                   uint32_t *p_num_groups, struct dom_sid **user_sids);
482
483 NTSTATUS normalize_name_map(TALLOC_CTX *mem_ctx,
484                              const char *domain_name,
485                              const char *name,
486                              char **normalized);
487 NTSTATUS normalize_name_unmap(TALLOC_CTX *mem_ctx,
488                               char *name,
489                               char **normalized);
490
491 NTSTATUS resolve_username_to_alias(TALLOC_CTX *mem_ctx,
492                                    struct winbindd_domain *domain,
493                                    const char *name, char **alias);
494 NTSTATUS resolve_alias_to_username(TALLOC_CTX *mem_ctx,
495                                    struct winbindd_domain *domain,
496                                    const char *alias, char **name);
497
498 bool winbindd_can_contact_domain(struct winbindd_domain *domain);
499 bool winbindd_internal_child(struct winbindd_child *child);
500 void winbindd_set_locator_kdc_envs(const struct winbindd_domain *domain);
501 void winbindd_unset_locator_kdc_env(const struct winbindd_domain *domain);
502 void winbindd_set_locator_kdc_envs(const struct winbindd_domain *domain);
503 void winbindd_unset_locator_kdc_env(const struct winbindd_domain *domain);
504 void set_auth_errors(struct winbindd_response *resp, NTSTATUS result);
505 bool is_domain_offline(const struct winbindd_domain *domain);
506 bool is_domain_online(const struct winbindd_domain *domain);
507 bool parse_sidlist(TALLOC_CTX *mem_ctx, const char *sidstr,
508                    struct dom_sid **sids, uint32_t *num_sids);
509 bool parse_xidlist(TALLOC_CTX *mem_ctx, const char *xidstr,
510                    struct unixid **pxids, uint32_t *pnum_xids);
511
512 /* The following definitions come from winbindd/winbindd_wins.c  */
513
514 void winbindd_wins_byname(struct winbindd_cli_state *state);
515
516 struct tevent_req *wb_ping_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev,
517                                 struct winbindd_cli_state *cli,
518                                 struct winbindd_request *request);
519 NTSTATUS wb_ping_recv(struct tevent_req *req,
520                       struct winbindd_response *resp);
521
522 enum winbindd_result winbindd_dual_ping(struct winbindd_domain *domain,
523                                         struct winbindd_cli_state *state);
524
525 struct dcerpc_binding_handle *wbint_binding_handle(TALLOC_CTX *mem_ctx,
526                                                 struct winbindd_domain *domain,
527                                                 struct winbindd_child *child);
528 enum winbindd_result winbindd_dual_ndrcmd(struct winbindd_domain *domain,
529                                           struct winbindd_cli_state *state);
530
531 struct tevent_req *wb_lookupsid_send(TALLOC_CTX *mem_ctx,
532                                      struct tevent_context *ev,
533                                      const struct dom_sid *sid);
534 NTSTATUS wb_lookupsid_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
535                            enum lsa_SidType *type, const char **domain,
536                            const char **name);
537
538 struct tevent_req *winbindd_lookupsid_send(TALLOC_CTX *mem_ctx,
539                                            struct tevent_context *ev,
540                                            struct winbindd_cli_state *cli,
541                                            struct winbindd_request *request);
542 NTSTATUS winbindd_lookupsid_recv(struct tevent_req *req,
543                                  struct winbindd_response *response);
544
545 struct tevent_req *winbindd_lookupsids_send(TALLOC_CTX *mem_ctx,
546                                             struct tevent_context *ev,
547                                             struct winbindd_cli_state *cli,
548                                             struct winbindd_request *request);
549 NTSTATUS winbindd_lookupsids_recv(struct tevent_req *req,
550                                   struct winbindd_response *response);
551
552 struct tevent_req *wb_lookupname_send(TALLOC_CTX *mem_ctx,
553                                       struct tevent_context *ev,
554                                       const char *dom_name, const char *name,
555                                       uint32_t flags);
556 NTSTATUS wb_lookupname_recv(struct tevent_req *req, struct dom_sid *sid,
557                             enum lsa_SidType *type);
558
559 struct tevent_req *winbindd_lookupname_send(TALLOC_CTX *mem_ctx,
560                                             struct tevent_context *ev,
561                                             struct winbindd_cli_state *cli,
562                                             struct winbindd_request *request);
563 NTSTATUS winbindd_lookupname_recv(struct tevent_req *req,
564                                   struct winbindd_response *response);
565
566 struct tevent_req *winbindd_allocate_uid_send(TALLOC_CTX *mem_ctx,
567                                               struct tevent_context *ev,
568                                               struct winbindd_cli_state *cli,
569                                               struct winbindd_request *request);
570 NTSTATUS winbindd_allocate_uid_recv(struct tevent_req *req,
571                                     struct winbindd_response *response);
572
573 struct tevent_req *winbindd_allocate_gid_send(TALLOC_CTX *mem_ctx,
574                                               struct tevent_context *ev,
575                                               struct winbindd_cli_state *cli,
576                                               struct winbindd_request *request);
577 NTSTATUS winbindd_allocate_gid_recv(struct tevent_req *req,
578                                     struct winbindd_response *response);
579
580 struct tevent_req *wb_queryuser_send(TALLOC_CTX *mem_ctx,
581                                      struct tevent_context *ev,
582                                      const struct dom_sid *user_sid);
583 NTSTATUS wb_queryuser_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
584                            struct wbint_userinfo **pinfo);
585
586 struct tevent_req *wb_getpwsid_send(TALLOC_CTX *mem_ctx,
587                                     struct tevent_context *ev,
588                                     const struct dom_sid *user_sid,
589                                     struct winbindd_pw *pw);
590 NTSTATUS wb_getpwsid_recv(struct tevent_req *req);
591
592 struct tevent_req *winbindd_getpwsid_send(TALLOC_CTX *mem_ctx,
593                                           struct tevent_context *ev,
594                                           struct winbindd_cli_state *cli,
595                                           struct winbindd_request *request);
596 NTSTATUS winbindd_getpwsid_recv(struct tevent_req *req,
597                                 struct winbindd_response *response);
598
599 struct tevent_req *winbindd_getpwnam_send(TALLOC_CTX *mem_ctx,
600                                           struct tevent_context *ev,
601                                           struct winbindd_cli_state *cli,
602                                           struct winbindd_request *request);
603 NTSTATUS winbindd_getpwnam_recv(struct tevent_req *req,
604                                 struct winbindd_response *response);
605
606 struct tevent_req *winbindd_getpwuid_send(TALLOC_CTX *mem_ctx,
607                                           struct tevent_context *ev,
608                                           struct winbindd_cli_state *cli,
609                                           struct winbindd_request *request);
610 NTSTATUS winbindd_getpwuid_recv(struct tevent_req *req,
611                                 struct winbindd_response *response);
612 struct tevent_req *wb_lookupuseraliases_send(TALLOC_CTX *mem_ctx,
613                                              struct tevent_context *ev,
614                                              struct winbindd_domain *domain,
615                                              int num_sids,
616                                              const struct dom_sid *sids);
617 NTSTATUS wb_lookupuseraliases_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
618                                    uint32_t *num_aliases, uint32_t **aliases);
619 struct tevent_req *winbindd_getsidaliases_send(TALLOC_CTX *mem_ctx,
620                                                struct tevent_context *ev,
621                                                struct winbindd_cli_state *cli,
622                                                struct winbindd_request *request);
623 NTSTATUS winbindd_getsidaliases_recv(struct tevent_req *req,
624                                      struct winbindd_response *response);
625 struct tevent_req *wb_lookupusergroups_send(TALLOC_CTX *mem_ctx,
626                                             struct tevent_context *ev,
627                                             const struct dom_sid *sid);
628 NTSTATUS wb_lookupusergroups_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
629                                   int *num_sids, struct dom_sid **sids);
630
631 struct tevent_req *winbindd_getuserdomgroups_send(TALLOC_CTX *mem_ctx,
632                                                   struct tevent_context *ev,
633                                                   struct winbindd_cli_state *cli,
634                                                   struct winbindd_request *request);
635 NTSTATUS winbindd_getuserdomgroups_recv(struct tevent_req *req,
636                                         struct winbindd_response *response);
637 struct tevent_req *wb_gettoken_send(TALLOC_CTX *mem_ctx,
638                                     struct tevent_context *ev,
639                                     const struct dom_sid *sid,
640                                     bool expand_local_aliases);
641 NTSTATUS wb_gettoken_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
642                           int *num_sids, struct dom_sid **sids);
643 struct tevent_req *winbindd_getgroups_send(TALLOC_CTX *mem_ctx,
644                                            struct tevent_context *ev,
645                                            struct winbindd_cli_state *cli,
646                                            struct winbindd_request *request);
647 NTSTATUS winbindd_getgroups_recv(struct tevent_req *req,
648                                  struct winbindd_response *response);
649
650 struct tevent_req *wb_seqnum_send(TALLOC_CTX *mem_ctx,
651                                   struct tevent_context *ev,
652                                   struct winbindd_domain *domain);
653 NTSTATUS wb_seqnum_recv(struct tevent_req *req, uint32_t *seqnum);
654
655 struct tevent_req *wb_seqnums_send(TALLOC_CTX *mem_ctx,
656                                    struct tevent_context *ev);
657 NTSTATUS wb_seqnums_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
658                          int *num_domains, struct winbindd_domain ***domains,
659                          NTSTATUS **stati, uint32_t **seqnums);
660
661 struct tevent_req *winbindd_show_sequence_send(TALLOC_CTX *mem_ctx,
662                                                struct tevent_context *ev,
663                                                struct winbindd_cli_state *cli,
664                                                struct winbindd_request *request);
665 NTSTATUS winbindd_show_sequence_recv(struct tevent_req *req,
666                                      struct winbindd_response *response);
667
668 struct tevent_req *wb_group_members_send(TALLOC_CTX *mem_ctx,
669                                          struct tevent_context *ev,
670                                          const struct dom_sid *sid,
671                                          enum lsa_SidType type,
672                                          int max_depth);
673 NTSTATUS wb_group_members_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
674                                struct db_context **members);
675 NTSTATUS add_member_to_db(struct db_context *db, struct dom_sid *sid,
676                           const char *name);
677
678 struct tevent_req *wb_getgrsid_send(TALLOC_CTX *mem_ctx,
679                                     struct tevent_context *ev,
680                                     const struct dom_sid *group_sid,
681                                     int max_nesting);
682 NTSTATUS wb_getgrsid_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
683                           const char **domname, const char **name, gid_t *gid,
684                           struct db_context **members);
685
686 struct tevent_req *winbindd_getgrgid_send(TALLOC_CTX *mem_ctx,
687                                           struct tevent_context *ev,
688                                           struct winbindd_cli_state *cli,
689                                           struct winbindd_request *request);
690 NTSTATUS winbindd_getgrgid_recv(struct tevent_req *req,
691                                 struct winbindd_response *response);
692
693 struct tevent_req *winbindd_getgrnam_send(TALLOC_CTX *mem_ctx,
694                                           struct tevent_context *ev,
695                                           struct winbindd_cli_state *cli,
696                                           struct winbindd_request *request);
697 NTSTATUS winbindd_getgrnam_recv(struct tevent_req *req,
698                                 struct winbindd_response *response);
699
700 struct tevent_req *winbindd_getusersids_send(TALLOC_CTX *mem_ctx,
701                                              struct tevent_context *ev,
702                                              struct winbindd_cli_state *cli,
703                                              struct winbindd_request *request);
704 NTSTATUS winbindd_getusersids_recv(struct tevent_req *req,
705                                    struct winbindd_response *response);
706
707 struct tevent_req *winbindd_lookuprids_send(TALLOC_CTX *mem_ctx,
708                                             struct tevent_context *ev,
709                                             struct winbindd_cli_state *cli,
710                                             struct winbindd_request *request);
711 NTSTATUS winbindd_lookuprids_recv(struct tevent_req *req,
712                                   struct winbindd_response *response);
713
714 struct tevent_req *wb_query_user_list_send(TALLOC_CTX *mem_ctx,
715                                            struct tevent_context *ev,
716                                            struct winbindd_domain *domain);
717 NTSTATUS wb_query_user_list_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
718                                  char **users);
719
720 struct tevent_req *wb_query_group_list_send(TALLOC_CTX *mem_ctx,
721                                             struct tevent_context *ev,
722                                             struct winbindd_domain *domain);
723 NTSTATUS wb_query_group_list_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
724                                   int *num_users,
725                                   struct wbint_Principal **groups);
726
727 struct tevent_req *wb_next_pwent_send(TALLOC_CTX *mem_ctx,
728                                       struct tevent_context *ev,
729                                       struct getpwent_state *gstate,
730                                       struct winbindd_pw *pw);
731 NTSTATUS wb_next_pwent_recv(struct tevent_req *req);
732
733 struct tevent_req *winbindd_setpwent_send(TALLOC_CTX *mem_ctx,
734                                           struct tevent_context *ev,
735                                           struct winbindd_cli_state *cli,
736                                           struct winbindd_request *request);
737 NTSTATUS winbindd_setpwent_recv(struct tevent_req *req,
738                                 struct winbindd_response *presp);
739
740 struct tevent_req *winbindd_getpwent_send(TALLOC_CTX *mem_ctx,
741                                           struct tevent_context *ev,
742                                           struct winbindd_cli_state *cli,
743                                           struct winbindd_request *request);
744 NTSTATUS winbindd_getpwent_recv(struct tevent_req *req,
745                                 struct winbindd_response *response);
746
747 struct tevent_req *winbindd_endpwent_send(TALLOC_CTX *mem_ctx,
748                                           struct tevent_context *ev,
749                                           struct winbindd_cli_state *cli,
750                                           struct winbindd_request *request);
751 NTSTATUS winbindd_endpwent_recv(struct tevent_req *req,
752                                 struct winbindd_response *response);
753
754 struct tevent_req *winbindd_dsgetdcname_send(TALLOC_CTX *mem_ctx,
755                                              struct tevent_context *ev,
756                                              struct winbindd_cli_state *cli,
757                                              struct winbindd_request *request);
758 NTSTATUS winbindd_dsgetdcname_recv(struct tevent_req *req,
759                                    struct winbindd_response *response);
760
761 struct tevent_req *wb_dsgetdcname_send(TALLOC_CTX *mem_ctx,
762                                        struct tevent_context *ev,
763                                        const char *domain_name,
764                                        const struct GUID *domain_guid,
765                                        const char *site_name,
766                                        uint32_t flags);
767 NTSTATUS wb_dsgetdcname_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
768                              struct netr_DsRGetDCNameInfo **pdcinfo);
769 NTSTATUS wb_dsgetdcname_gencache_set(const char *domname,
770                                      struct netr_DsRGetDCNameInfo *dcinfo);
771 NTSTATUS wb_dsgetdcname_gencache_get(TALLOC_CTX *mem_ctx,
772                                      const char *domname,
773                                      struct netr_DsRGetDCNameInfo **dcinfo);
774
775 struct tevent_req *winbindd_getdcname_send(TALLOC_CTX *mem_ctx,
776                                            struct tevent_context *ev,
777                                            struct winbindd_cli_state *cli,
778                                            struct winbindd_request *request);
779 NTSTATUS winbindd_getdcname_recv(struct tevent_req *req,
780                                  struct winbindd_response *response);
781
782 struct tevent_req *wb_next_grent_send(TALLOC_CTX *mem_ctx,
783                                       struct tevent_context *ev,
784                                       int max_nesting,
785                                       struct getgrent_state *gstate,
786                                       struct winbindd_gr *gr);
787 NTSTATUS wb_next_grent_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
788                             struct db_context **members);
789
790 struct tevent_req *winbindd_setgrent_send(TALLOC_CTX *mem_ctx,
791                                           struct tevent_context *ev,
792                                           struct winbindd_cli_state *cli,
793                                           struct winbindd_request *request);
794 NTSTATUS winbindd_setgrent_recv(struct tevent_req *req,
795                                 struct winbindd_response *response);
796 struct tevent_req *winbindd_getgrent_send(TALLOC_CTX *mem_ctx,
797                                           struct tevent_context *ev,
798                                           struct winbindd_cli_state *cli,
799                                           struct winbindd_request *request);
800 NTSTATUS winbindd_getgrent_recv(struct tevent_req *req,
801                                 struct winbindd_response *response);
802 struct tevent_req *winbindd_endgrent_send(TALLOC_CTX *mem_ctx,
803                                           struct tevent_context *ev,
804                                           struct winbindd_cli_state *cli,
805                                           struct winbindd_request *request);
806 NTSTATUS winbindd_endgrent_recv(struct tevent_req *req,
807                                 struct winbindd_response *response);
808
809 struct tevent_req *winbindd_list_users_send(TALLOC_CTX *mem_ctx,
810                                             struct tevent_context *ev,
811                                             struct winbindd_cli_state *cli,
812                                             struct winbindd_request *request);
813 NTSTATUS winbindd_list_users_recv(struct tevent_req *req,
814                                   struct winbindd_response *response);
815
816 struct tevent_req *winbindd_list_groups_send(TALLOC_CTX *mem_ctx,
817                                              struct tevent_context *ev,
818                                              struct winbindd_cli_state *cli,
819                                              struct winbindd_request *request);
820 NTSTATUS winbindd_list_groups_recv(struct tevent_req *req,
821                                    struct winbindd_response *response);
822
823 struct tevent_req *winbindd_check_machine_acct_send(TALLOC_CTX *mem_ctx,
824                                                     struct tevent_context *ev,
825                                                     struct winbindd_cli_state *cli,
826                                                     struct winbindd_request *request);
827 NTSTATUS winbindd_check_machine_acct_recv(struct tevent_req *req,
828                                           struct winbindd_response *presp);
829
830 struct tevent_req *winbindd_ping_dc_send(TALLOC_CTX *mem_ctx,
831                                          struct tevent_context *ev,
832                                          struct winbindd_cli_state *cli,
833                                          struct winbindd_request *request);
834 NTSTATUS winbindd_ping_dc_recv(struct tevent_req *req,
835                                struct winbindd_response *presp);
836
837 struct tevent_req *winbindd_change_machine_acct_send(TALLOC_CTX *mem_ctx,
838                                                      struct tevent_context *ev,
839                                                      struct winbindd_cli_state *cli,
840                                                      struct winbindd_request *request);
841 NTSTATUS winbindd_change_machine_acct_recv(struct tevent_req *req,
842                                            struct winbindd_response *presp);
843
844 struct tevent_req *winbindd_pam_auth_send(TALLOC_CTX *mem_ctx,
845                                           struct tevent_context *ev,
846                                           struct winbindd_cli_state *cli,
847                                           struct winbindd_request *request);
848 NTSTATUS winbindd_pam_auth_recv(struct tevent_req *req,
849                                 struct winbindd_response *response);
850
851 struct tevent_req *winbindd_pam_auth_crap_send(
852         TALLOC_CTX *mem_ctx,
853         struct tevent_context *ev,
854         struct winbindd_cli_state *cli,
855         struct winbindd_request *request);
856 NTSTATUS winbindd_pam_auth_crap_recv(struct tevent_req *req,
857                                      struct winbindd_response *response);
858
859 struct tevent_req *winbindd_pam_chauthtok_send(
860         TALLOC_CTX *mem_ctx,
861         struct tevent_context *ev,
862         struct winbindd_cli_state *cli,
863         struct winbindd_request *request);
864 NTSTATUS winbindd_pam_chauthtok_recv(struct tevent_req *req,
865                                      struct winbindd_response *response);
866
867 struct tevent_req *winbindd_pam_logoff_send(TALLOC_CTX *mem_ctx,
868                                             struct tevent_context *ev,
869                                             struct winbindd_cli_state *cli,
870                                             struct winbindd_request *request);
871 NTSTATUS winbindd_pam_logoff_recv(struct tevent_req *req,
872                                   struct winbindd_response *response);
873
874 struct tevent_req *winbindd_pam_chng_pswd_auth_crap_send(
875         TALLOC_CTX *mem_ctx,
876         struct tevent_context *ev,
877         struct winbindd_cli_state *cli,
878         struct winbindd_request *request);
879 NTSTATUS winbindd_pam_chng_pswd_auth_crap_recv(
880         struct tevent_req *req,
881         struct winbindd_response *response);
882
883 struct tevent_req *wb_lookupsids_send(TALLOC_CTX *mem_ctx,
884                                       struct tevent_context *ev,
885                                       struct dom_sid *sids,
886                                       uint32_t num_sids);
887 NTSTATUS wb_lookupsids_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
888                             struct lsa_RefDomainList **domains,
889                             struct lsa_TransNameArray **names);
890
891 struct tevent_req *wb_sids2xids_send(TALLOC_CTX *mem_ctx,
892                                      struct tevent_context *ev,
893                                      const struct dom_sid *sids,
894                                      const uint32_t num_sids);
895 NTSTATUS wb_sids2xids_recv(struct tevent_req *req,
896                            struct unixid xids[], uint32_t num_xids);
897 struct tevent_req *winbindd_sids_to_xids_send(TALLOC_CTX *mem_ctx,
898                                               struct tevent_context *ev,
899                                               struct winbindd_cli_state *cli,
900                                               struct winbindd_request *request);
901 NTSTATUS winbindd_sids_to_xids_recv(struct tevent_req *req,
902                                     struct winbindd_response *response);
903 struct tevent_req *wb_xids2sids_send(TALLOC_CTX *mem_ctx,
904                                      struct tevent_context *ev,
905                                      struct unixid *xids,
906                                      uint32_t num_xids);
907 NTSTATUS wb_xids2sids_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
908                            struct dom_sid **sids);
909 struct tevent_req *winbindd_xids_to_sids_send(TALLOC_CTX *mem_ctx,
910                                               struct tevent_context *ev,
911                                               struct winbindd_cli_state *cli,
912                                               struct winbindd_request *request);
913 NTSTATUS winbindd_xids_to_sids_recv(struct tevent_req *req,
914                                     struct winbindd_response *response);
915 struct tevent_req *winbindd_wins_byip_send(TALLOC_CTX *mem_ctx,
916                                            struct tevent_context *ev,
917                                            struct winbindd_cli_state *cli,
918                                            struct winbindd_request *request);
919 NTSTATUS winbindd_wins_byip_recv(struct tevent_req *req,
920                                  struct winbindd_response *presp);
921 struct tevent_req *winbindd_wins_byname_send(TALLOC_CTX *mem_ctx,
922                                              struct tevent_context *ev,
923                                              struct winbindd_cli_state *cli,
924                                              struct winbindd_request *request);
925 NTSTATUS winbindd_wins_byname_recv(struct tevent_req *req,
926                                    struct winbindd_response *presp);
927
928
929 /* The following definitions come from winbindd/winbindd_samr.c  */
930
931 NTSTATUS open_internal_samr_conn(TALLOC_CTX *mem_ctx,
932                                  struct winbindd_domain *domain,
933                                  struct rpc_pipe_client **samr_pipe,
934                                  struct policy_handle *samr_domain_hnd);
935 NTSTATUS open_internal_lsa_conn(TALLOC_CTX *mem_ctx,
936                                 struct rpc_pipe_client **lsa_pipe,
937                                 struct policy_handle *lsa_hnd);
938
939 /* The following definitions come from winbindd/winbindd_irpc.c  */
940 NTSTATUS wb_irpc_register(void);
941
942 /* The following definitions come from winbindd/winbindd_reconnect.c  */
943 bool reconnect_need_retry(NTSTATUS status, struct winbindd_domain *domain);
944
945 #endif /*  _WINBINDD_PROTO_H_  */