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