s3:libads: add tls_wrapping into openldap
[samba.git] / source3 / libads / ads_proto.h
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  ads (active directory) utility library
4  *
5  *  Copyright (C) Andrew Bartlett                       2001
6  *  Copyright (C) Andrew Tridgell                       2001
7  *  Copyright (C) Remus Koos (remuskoos@yahoo.com)      2001
8  *  Copyright (C) Alexey Kotovich                       2002
9  *  Copyright (C) Jim McDonough <jmcd@us.ibm.com>       2002-2003
10  *  Copyright (C) Luke Howard                           2003
11  *  Copyright (C) Guenther Deschner                     2003-2008
12  *  Copyright (C) Rakesh Patel                          2004
13  *  Copyright (C) Dan Perry                             2004
14  *  Copyright (C) Jeremy Allison                        2004
15  *  Copyright (C) Gerald Carter                         2006
16  *  Copyright (C) Stefan Metzmacher                     2007
17  *
18  *  This program is free software; you can redistribute it and/or modify
19  *  it under the terms of the GNU General Public License as published by
20  *  the Free Software Foundation; either version 3 of the License, or
21  *  (at your option) any later version.
22  *
23  *  This program is distributed in the hope that it will be useful,
24  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
25  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  *  GNU General Public License for more details.
27  *
28  *  You should have received a copy of the GNU General Public License
29  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
30  */
31
32 #ifndef _LIBADS_ADS_PROTO_H_
33 #define _LIBADS_ADS_PROTO_H_
34
35 enum ads_sasl_state_e {
36         ADS_SASL_PLAIN = 0,
37         ADS_SASL_SIGN,
38         ADS_SASL_SEAL,
39 };
40
41 /* The following definitions come from libads/ads_struct.c  */
42
43 ADS_STATUS ads_build_path(const char *realm,
44                           const char *sep,
45                           const char *field,
46                           int reverse,
47                           char **_path);
48 ADS_STATUS ads_build_dn(const char *realm, TALLOC_CTX *mem_ctx, char **_dn);
49 char *ads_build_domain(const char *dn);
50 ADS_STRUCT *ads_init(TALLOC_CTX *mem_ctx,
51                      const char *realm,
52                      const char *workgroup,
53                      const char *ldap_server,
54                      enum ads_sasl_state_e sasl_state);
55 bool ads_set_sasl_wrap_flags(ADS_STRUCT *ads, unsigned flags);
56
57 /* The following definitions come from libads/disp_sec.c  */
58
59 void ads_disp_sd(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, struct security_descriptor *sd);
60
61 /* The following definitions come from libads/kerberos_keytab.c  */
62
63 int ads_keytab_add_entry(ADS_STRUCT *ads, const char *srvPrinc,
64                          bool update_ads);
65 int ads_keytab_delete_entry(ADS_STRUCT *ads, const char *srvPrinc);
66 int ads_keytab_flush(ADS_STRUCT *ads);
67 int ads_keytab_create_default(ADS_STRUCT *ads);
68 int ads_keytab_list(const char *keytab_name);
69
70 /* The following definitions come from libads/net_ads_setspn.c  */
71 bool ads_setspn_list(ADS_STRUCT *ads, const char *machine);
72 bool ads_setspn_add(ADS_STRUCT *ads, const char *machine_name,
73                     const char * spn);
74 bool ads_setspn_delete(ADS_STRUCT *ads, const char *machine_name,
75                        const char * spn);
76
77 /* The following definitions come from libads/krb5_errs.c  */
78
79 /* The following definitions come from libads/kerberos_util.c  */
80
81 int ads_kinit_password(ADS_STRUCT *ads);
82
83 /* The following definitions come from libads/ldap.c  */
84
85 bool ads_sitename_match(ADS_STRUCT *ads);
86 bool ads_closest_dc(ADS_STRUCT *ads);
87 ADS_STATUS ads_connect(ADS_STRUCT *ads);
88 ADS_STATUS ads_connect_user_creds(ADS_STRUCT *ads);
89 void ads_zero_ldap(ADS_STRUCT *ads);
90 void ads_disconnect(ADS_STRUCT *ads);
91 ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path,
92                                 int scope, const char *expr, const char **attrs,
93                                 bool (*fn)(ADS_STRUCT *, char *, void **, void *),
94                                 void *data_area);
95 char *ads_parent_dn(const char *dn);
96 ADS_MODLIST ads_init_mods(TALLOC_CTX *ctx);
97 ADS_STATUS ads_mod_str(TALLOC_CTX *ctx, ADS_MODLIST *mods,
98                        const char *name, const char *val);
99 ADS_STATUS ads_mod_strlist(TALLOC_CTX *ctx, ADS_MODLIST *mods,
100                            const char *name, const char **vals);
101 ADS_STATUS ads_gen_mod(ADS_STRUCT *ads, const char *mod_dn, ADS_MODLIST mods);
102 ADS_STATUS ads_gen_add(ADS_STRUCT *ads, const char *new_dn, ADS_MODLIST mods);
103 ADS_STATUS ads_del_dn(ADS_STRUCT *ads, char *del_dn);
104 char *ads_ou_string(ADS_STRUCT *ads, const char *org_unit);
105 char *ads_default_ou_string(ADS_STRUCT *ads, const char *wknguid);
106 ADS_STATUS ads_add_strlist(TALLOC_CTX *ctx, ADS_MODLIST *mods,
107                                 const char *name, const char **vals);
108 uint32_t ads_get_kvno(ADS_STRUCT *ads, const char *account_name);
109 uint32_t ads_get_machine_kvno(ADS_STRUCT *ads, const char *machine_name);
110
111 bool ads_element_in_array(const char **el_array, size_t num_el, const char *el);
112
113 ADS_STATUS ads_get_service_principal_names(TALLOC_CTX *mem_ctx,
114                                            ADS_STRUCT *ads,
115                                            const char *machine_name,
116                                            char ***spn_array,
117                                            size_t *num_spns);
118 ADS_STATUS ads_clear_service_principal_names(ADS_STRUCT *ads, const char *machine_name);
119 ADS_STATUS ads_add_service_principal_names(ADS_STRUCT *ads, const char *machine_name,
120                                           const char **spns);
121 ADS_STATUS ads_create_machine_acct(ADS_STRUCT *ads,
122                                    const char *machine_name,
123                                    const char *machine_password,
124                                    const char *org_unit,
125                                    uint32_t etype_list,
126                                    const char *dns_domain_name);
127 ADS_STATUS ads_move_machine_acct(ADS_STRUCT *ads, const char *machine_name,
128                                  const char *org_unit, bool *moved);
129 int ads_count_replies(ADS_STRUCT *ads, void *res);
130 ADS_STATUS ads_USN(ADS_STRUCT *ads, uint32_t *usn);
131 ADS_STATUS ads_current_time(ADS_STRUCT *ads);
132 ADS_STATUS ads_domain_func_level(ADS_STRUCT *ads, uint32_t *val);
133 ADS_STATUS ads_domain_sid(ADS_STRUCT *ads, struct dom_sid *sid);
134 ADS_STATUS ads_site_dn(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, const char **site_name);
135 ADS_STATUS ads_site_dn_for_machine(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, const char *computer_name, const char **site_dn);
136 ADS_STATUS ads_upn_suffixes(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, char ***suffixes, size_t *num_suffixes);
137 ADS_STATUS ads_get_joinable_ous(ADS_STRUCT *ads,
138                                 TALLOC_CTX *mem_ctx,
139                                 char ***ous,
140                                 size_t *num_ous);
141 ADS_STATUS ads_get_sid_from_extended_dn(TALLOC_CTX *mem_ctx,
142                                         const char *extended_dn,
143                                         enum ads_extended_dn_flags flags,
144                                         struct dom_sid *sid);
145 char* ads_get_dnshostname( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine_name );
146 ADS_STATUS ads_get_additional_dns_hostnames(TALLOC_CTX *mem_ctx,
147                                             ADS_STRUCT *ads,
148                                             const char *machine_name,
149                                             char ***hostnames_array,
150                                             size_t *num_hostnames);
151 char* ads_get_upn( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine_name );
152 bool ads_has_samaccountname( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine_name );
153 ADS_STATUS ads_join_realm(ADS_STRUCT *ads, const char *machine_name,
154                         uint32_t account_type, const char *org_unit);
155 ADS_STATUS ads_leave_realm(ADS_STRUCT *ads, const char *hostname);
156 ADS_STATUS ads_find_samaccount(ADS_STRUCT *ads,
157                                TALLOC_CTX *mem_ctx,
158                                const char *samaccountname,
159                                uint32_t *uac_ret,
160                                const char **dn_ret);
161 ADS_STATUS ads_config_path(ADS_STRUCT *ads,
162                            TALLOC_CTX *mem_ctx,
163                            char **config_path);
164 const char *ads_get_extended_right_name_by_guid(ADS_STRUCT *ads,
165                                                 const char *config_path,
166                                                 TALLOC_CTX *mem_ctx,
167                                                 const struct GUID *rights_guid);
168 ADS_STATUS ads_check_ou_dn(TALLOC_CTX *mem_ctx,
169                            ADS_STRUCT *ads,
170                            const char **account_ou);
171
172 /* The following definitions come from libads/ldap_printer.c  */
173
174 ADS_STATUS ads_mod_printer_entry(ADS_STRUCT *ads, char *prt_dn,
175                                  TALLOC_CTX *ctx, const ADS_MODLIST *mods);
176 ADS_STATUS ads_add_printer_entry(ADS_STRUCT *ads, char *prt_dn,
177                                         TALLOC_CTX *ctx, ADS_MODLIST *mods);
178 WERROR get_remote_printer_publishing_data(struct rpc_pipe_client *cli,
179                                           TALLOC_CTX *mem_ctx,
180                                           ADS_MODLIST *mods,
181                                           const char *printer);
182
183 /* The following definitions come from libads/ldap_user.c  */
184
185 ADS_STATUS ads_add_user_acct(ADS_STRUCT *ads, const char *user,
186                              const char *container, const char *fullname);
187 ADS_STATUS ads_add_group_acct(ADS_STRUCT *ads, const char *group,
188                               const char *container, const char *comment);
189
190 /* The following definitions come from libads/ldap_utils.c  */
191
192 ADS_STATUS ads_ranged_search(ADS_STRUCT *ads,
193                              TALLOC_CTX *mem_ctx,
194                              int scope,
195                              const char *base,
196                              const char *filter,
197                              void *args,
198                              const char *range_attr,
199                              char ***strings,
200                              size_t *num_strings);
201
202 /* The following definitions come from libads/sasl.c  */
203
204 ADS_STATUS ads_sasl_bind(ADS_STRUCT *ads);
205
206 /* The following definitions come from libads/sasl_wrapping.c  */
207
208 ADS_STATUS ads_setup_sasl_wrapping(struct ads_saslwrap *wrap, LDAP *ld,
209                                    const struct ads_saslwrap_ops *ops,
210                                    void *private_data);
211 void ndr_print_ads_saslwrap_struct(struct ndr_print *ndr,
212                                    const char *name,
213                                    const struct ads_saslwrap *r);
214
215 /* The following definitions come from libads/tls_wrapping.c  */
216
217 void ndr_print_ads_tlswrap_struct(struct ndr_print *ndr,
218                                    const char *name,
219                                    const struct ads_tlswrap *r);
220 ADS_STATUS ads_setup_tls_wrapping(struct ads_tlswrap *wrap,
221                                   LDAP *ld,
222                                   const char *server_name);
223 const DATA_BLOB *ads_tls_channel_bindings(struct ads_tlswrap *wrap);
224
225 /* The following definitions come from libads/util.c  */
226
227 ADS_STATUS ads_change_trust_account_password(ADS_STRUCT *ads, char *host_principal);
228
229 struct spn_struct {
230         const char *serviceclass;
231         const char *servicename;
232         const char *host;
233         int32_t port;
234 };
235
236 /* parse a windows style SPN, returns NULL if parsing fails */
237 struct spn_struct *parse_spn(TALLOC_CTX *ctx, const char *srvprinc);
238
239 #endif /* _LIBADS_ADS_PROTO_H_ */