smbd: Ensure we grant owner sid in check_parent_access_fsp()
[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 struct cli_credentials;
36
37 enum ads_sasl_state_e {
38         ADS_SASL_PLAIN = 0,
39         ADS_SASL_SIGN,
40         ADS_SASL_SEAL,
41 };
42
43 /* The following definitions come from libads/ads_struct.c  */
44
45 ADS_STATUS ads_build_path(const char *realm,
46                           const char *sep,
47                           const char *field,
48                           int reverse,
49                           char **_path);
50 ADS_STATUS ads_build_dn(const char *realm, TALLOC_CTX *mem_ctx, char **_dn);
51 char *ads_build_domain(const char *dn);
52 ADS_STRUCT *ads_init(TALLOC_CTX *mem_ctx,
53                      const char *realm,
54                      const char *workgroup,
55                      const char *ldap_server,
56                      enum ads_sasl_state_e sasl_state);
57 bool ads_set_sasl_wrap_flags(ADS_STRUCT *ads, unsigned flags);
58
59 /* The following definitions come from libads/disp_sec.c  */
60
61 void ads_disp_sd(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, struct security_descriptor *sd);
62
63 /* The following definitions come from libads/kerberos_keytab.c  */
64
65 int ads_keytab_add_entry(ADS_STRUCT *ads, const char *srvPrinc,
66                          bool update_ads);
67 int ads_keytab_delete_entry(ADS_STRUCT *ads, const char *srvPrinc);
68 int ads_keytab_flush(ADS_STRUCT *ads);
69 int ads_keytab_create_default(ADS_STRUCT *ads);
70 int ads_keytab_list(const char *keytab_name);
71
72 /* The following definitions come from libads/net_ads_setspn.c  */
73 bool ads_setspn_list(ADS_STRUCT *ads, const char *machine);
74 bool ads_setspn_add(ADS_STRUCT *ads, const char *machine_name,
75                     const char * spn);
76 bool ads_setspn_delete(ADS_STRUCT *ads, const char *machine_name,
77                        const char * spn);
78
79 /* The following definitions come from libads/krb5_errs.c  */
80
81 /* The following definitions come from libads/ldap.c  */
82
83 bool ads_sitename_match(ADS_STRUCT *ads);
84 bool ads_closest_dc(ADS_STRUCT *ads);
85 ADS_STATUS ads_connect_cldap_only(ADS_STRUCT *ads);
86 ADS_STATUS ads_connect_creds(ADS_STRUCT *ads, struct cli_credentials *creds);
87 ADS_STATUS ads_connect_simple_anon(ADS_STRUCT *ads);
88 ADS_STATUS ads_connect_machine(ADS_STRUCT *ads);
89 ADS_STATUS ads_connect(ADS_STRUCT *ads);
90 ADS_STATUS ads_connect_user_creds(ADS_STRUCT *ads);
91 void ads_zero_ldap(ADS_STRUCT *ads);
92 void ads_disconnect(ADS_STRUCT *ads);
93 ADS_STATUS ads_do_search_all_fn(ADS_STRUCT *ads, const char *bind_path,
94                                 int scope, const char *expr, const char **attrs,
95                                 bool (*fn)(ADS_STRUCT *, char *, void **, void *),
96                                 void *data_area);
97 char *ads_parent_dn(const char *dn);
98 ADS_MODLIST ads_init_mods(TALLOC_CTX *ctx);
99 ADS_STATUS ads_mod_str(TALLOC_CTX *ctx, ADS_MODLIST *mods,
100                        const char *name, const char *val);
101 ADS_STATUS ads_mod_strlist(TALLOC_CTX *ctx, ADS_MODLIST *mods,
102                            const char *name, const char **vals);
103 ADS_STATUS ads_gen_mod(ADS_STRUCT *ads, const char *mod_dn, ADS_MODLIST mods);
104 ADS_STATUS ads_gen_add(ADS_STRUCT *ads, const char *new_dn, ADS_MODLIST mods);
105 ADS_STATUS ads_del_dn(ADS_STRUCT *ads, char *del_dn);
106 char *ads_ou_string(ADS_STRUCT *ads, const char *org_unit);
107 char *ads_default_ou_string(ADS_STRUCT *ads, const char *wknguid);
108 ADS_STATUS ads_add_strlist(TALLOC_CTX *ctx, ADS_MODLIST *mods,
109                                 const char *name, const char **vals);
110 uint32_t ads_get_kvno(ADS_STRUCT *ads, const char *account_name);
111 uint32_t ads_get_machine_kvno(ADS_STRUCT *ads, const char *machine_name);
112
113 bool ads_element_in_array(const char **el_array, size_t num_el, const char *el);
114
115 ADS_STATUS ads_get_service_principal_names(TALLOC_CTX *mem_ctx,
116                                            ADS_STRUCT *ads,
117                                            const char *machine_name,
118                                            char ***spn_array,
119                                            size_t *num_spns);
120 ADS_STATUS ads_clear_service_principal_names(ADS_STRUCT *ads, const char *machine_name);
121 ADS_STATUS ads_add_service_principal_names(ADS_STRUCT *ads, const char *machine_name,
122                                           const char **spns);
123 ADS_STATUS ads_create_machine_acct(ADS_STRUCT *ads,
124                                    const char *machine_name,
125                                    const char *machine_password,
126                                    const char *org_unit,
127                                    uint32_t etype_list,
128                                    const char *dns_domain_name);
129 ADS_STATUS ads_move_machine_acct(ADS_STRUCT *ads, const char *machine_name,
130                                  const char *org_unit, bool *moved);
131 int ads_count_replies(ADS_STRUCT *ads, void *res);
132 ADS_STATUS ads_USN(ADS_STRUCT *ads, uint32_t *usn);
133 ADS_STATUS ads_current_time(ADS_STRUCT *ads);
134 ADS_STATUS ads_domain_func_level(ADS_STRUCT *ads, uint32_t *val);
135 ADS_STATUS ads_domain_sid(ADS_STRUCT *ads, struct dom_sid *sid);
136 ADS_STATUS ads_site_dn(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, const char **site_name);
137 ADS_STATUS ads_site_dn_for_machine(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, const char *computer_name, const char **site_dn);
138 ADS_STATUS ads_upn_suffixes(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, char ***suffixes, size_t *num_suffixes);
139 ADS_STATUS ads_get_joinable_ous(ADS_STRUCT *ads,
140                                 TALLOC_CTX *mem_ctx,
141                                 char ***ous,
142                                 size_t *num_ous);
143 ADS_STATUS ads_get_sid_from_extended_dn(TALLOC_CTX *mem_ctx,
144                                         const char *extended_dn,
145                                         enum ads_extended_dn_flags flags,
146                                         struct dom_sid *sid);
147 char* ads_get_dnshostname( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine_name );
148 ADS_STATUS ads_get_additional_dns_hostnames(TALLOC_CTX *mem_ctx,
149                                             ADS_STRUCT *ads,
150                                             const char *machine_name,
151                                             char ***hostnames_array,
152                                             size_t *num_hostnames);
153 char* ads_get_upn( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine_name );
154 bool ads_has_samaccountname( ADS_STRUCT *ads, TALLOC_CTX *ctx, const char *machine_name );
155 ADS_STATUS ads_join_realm(ADS_STRUCT *ads, const char *machine_name,
156                         uint32_t account_type, const char *org_unit);
157 ADS_STATUS ads_leave_realm(ADS_STRUCT *ads, const char *hostname);
158 ADS_STATUS ads_find_samaccount(ADS_STRUCT *ads,
159                                TALLOC_CTX *mem_ctx,
160                                const char *samaccountname,
161                                uint32_t *uac_ret,
162                                const char **dn_ret);
163 ADS_STATUS ads_config_path(ADS_STRUCT *ads,
164                            TALLOC_CTX *mem_ctx,
165                            char **config_path);
166 const char *ads_get_extended_right_name_by_guid(ADS_STRUCT *ads,
167                                                 const char *config_path,
168                                                 TALLOC_CTX *mem_ctx,
169                                                 const struct GUID *rights_guid);
170 ADS_STATUS ads_check_ou_dn(TALLOC_CTX *mem_ctx,
171                            ADS_STRUCT *ads,
172                            const char **account_ou);
173
174 /* The following definitions come from libads/ldap_printer.c  */
175
176 ADS_STATUS ads_mod_printer_entry(ADS_STRUCT *ads, char *prt_dn,
177                                  TALLOC_CTX *ctx, const ADS_MODLIST *mods);
178 ADS_STATUS ads_add_printer_entry(ADS_STRUCT *ads, char *prt_dn,
179                                         TALLOC_CTX *ctx, ADS_MODLIST *mods);
180 WERROR get_remote_printer_publishing_data(struct rpc_pipe_client *cli,
181                                           TALLOC_CTX *mem_ctx,
182                                           ADS_MODLIST *mods,
183                                           const char *printer);
184
185 /* The following definitions come from libads/ldap_user.c  */
186
187 ADS_STATUS ads_add_user_acct(ADS_STRUCT *ads, const char *user,
188                              const char *container, const char *fullname);
189 ADS_STATUS ads_add_group_acct(ADS_STRUCT *ads, const char *group,
190                               const char *container, const char *comment);
191
192 /* The following definitions come from libads/ldap_utils.c  */
193
194 ADS_STATUS ads_ranged_search(ADS_STRUCT *ads,
195                              TALLOC_CTX *mem_ctx,
196                              int scope,
197                              const char *base,
198                              const char *filter,
199                              void *args,
200                              const char *range_attr,
201                              char ***strings,
202                              size_t *num_strings);
203
204 /* The following definitions come from libads/sasl.c  */
205
206 NTSTATUS ads_simple_creds(TALLOC_CTX *mem_ctx,
207                           const char *account_domain,
208                           const char *account_name,
209                           const char *password,
210                           struct cli_credentials **_creds);
211 ADS_STATUS ads_sasl_bind(ADS_STRUCT *ads, struct cli_credentials *creds);
212
213 /* The following definitions come from libads/sasl_wrapping.c  */
214
215 ADS_STATUS ads_setup_sasl_wrapping(struct ads_saslwrap *wrap, LDAP *ld,
216                                    const struct ads_saslwrap_ops *ops,
217                                    void *private_data);
218 void ndr_print_ads_saslwrap_struct(struct ndr_print *ndr,
219                                    const char *name,
220                                    const struct ads_saslwrap *r);
221
222 /* The following definitions come from libads/tls_wrapping.c  */
223
224 void ndr_print_ads_tlswrap_struct(struct ndr_print *ndr,
225                                    const char *name,
226                                    const struct ads_tlswrap *r);
227 ADS_STATUS ads_setup_tls_wrapping(struct ads_tlswrap *wrap,
228                                   LDAP *ld,
229                                   const char *server_name);
230 const DATA_BLOB *ads_tls_channel_bindings(struct ads_tlswrap *wrap);
231
232 /* The following definitions come from libads/util.c  */
233
234 ADS_STATUS ads_change_trust_account_password(ADS_STRUCT *ads, char *host_principal);
235
236 struct spn_struct {
237         const char *serviceclass;
238         const char *servicename;
239         const char *host;
240         int32_t port;
241 };
242
243 /* parse a windows style SPN, returns NULL if parsing fails */
244 struct spn_struct *parse_spn(TALLOC_CTX *ctx, const char *srvprinc);
245
246 #endif /* _LIBADS_ADS_PROTO_H_ */