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