s3:passdb/proto.h: add GPL/copyright comment header
[Samba/gebeck_regimport.git] / source3 / passdb / proto.h
blob17882a99d8b64d2a8549df5c6d415b97b8920877
1 /*
2 * Unix SMB/CIFS implementation.
3 * passdb - password and authentication handling
5 * Copyright (C) Andrew Tridgell 1992-1998
6 * Copyright (C) Jeremy Allison 1995-2009
7 * Copyright (C) Luke Kenneth Casson Leighton 1996-1998
8 * Copyright (C) Jean François Micouleau 1998-2001
9 * Copyright (C) Gerald (Jerry) Carter 2000-2006
10 * Copyright (C) Simo Sorce 2000-2003,2006
11 * Copyright (C) Andrew Bartlett 2001-2002
12 * Copyright (C) Shahms King 2001
13 * Copyright (C) Jelmer Vernooij 2002
14 * Copyright (C) Rafal Szczesniak 2002
15 * Copyright (C) Stefan (metze) Metzmacher 2002-2003
16 * Copyright (C) Guenther Deschner 2004-2005
17 * Copyright (C) Jim McDonough (jmcd@us.ibm.com) 2004-2005
18 * Copyright (C) Vince Brimhall 2004-2005
19 * Copyright (C) Volker Lendecke 2006
20 * Copyright (C) Michael Adam 2007
21 * Copyright (C) Dan Sledz 2009
23 * This program is free software; you can redistribute it and/or modify
24 * it under the terms of the GNU General Public License as published by
25 * the Free Software Foundation; either version 3 of the License, or
26 * (at your option) any later version.
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
33 * You should have received a copy of the GNU General Public License
34 * along with this program; if not, see <http://www.gnu.org/licenses/>.
38 /* The following definitions come from passdb/account_pol.c */
40 void account_policy_names_list(const char ***names, int *num_names);
41 const char *decode_account_policy_name(enum pdb_policy_type type);
42 const char *get_account_policy_attr(enum pdb_policy_type type);
43 const char *account_policy_get_desc(enum pdb_policy_type type);
44 enum pdb_policy_type account_policy_name_to_typenum(const char *name);
45 bool account_policy_get_default(enum pdb_policy_type type, uint32_t *val);
46 bool init_account_policy(void);
47 bool account_policy_get(enum pdb_policy_type type, uint32_t *value);
48 bool account_policy_set(enum pdb_policy_type type, uint32_t value);
49 bool cache_account_policy_set(enum pdb_policy_type type, uint32_t value);
50 bool cache_account_policy_get(enum pdb_policy_type type, uint32_t *value);
51 struct db_context *get_account_pol_db( void );
53 /* The following definitions come from passdb/login_cache.c */
55 bool login_cache_init(void);
56 bool login_cache_shutdown(void);
57 bool login_cache_read(struct samu *sampass, struct login_cache *entry);
58 bool login_cache_write(const struct samu *sampass,
59 const struct login_cache *entry);
60 bool login_cache_delentry(const struct samu *sampass);
62 /* The following definitions come from passdb/passdb.c */
64 const char *my_sam_name(void);
65 struct samu *samu_new( TALLOC_CTX *ctx );
66 NTSTATUS samu_set_unix(struct samu *user, const struct passwd *pwd);
67 NTSTATUS samu_alloc_rid_unix(struct samu *user, const struct passwd *pwd);
68 char *pdb_encode_acct_ctrl(uint32_t acct_ctrl, size_t length);
69 uint32_t pdb_decode_acct_ctrl(const char *p);
70 void pdb_sethexpwd(char p[33], const unsigned char *pwd, uint32_t acct_ctrl);
71 bool pdb_gethexpwd(const char *p, unsigned char *pwd);
72 void pdb_sethexhours(char *p, const unsigned char *hours);
73 bool pdb_gethexhours(const char *p, unsigned char *hours);
74 int algorithmic_rid_base(void);
75 uid_t algorithmic_pdb_user_rid_to_uid(uint32_t user_rid);
76 uid_t max_algorithmic_uid(void);
77 uint32_t algorithmic_pdb_uid_to_user_rid(uid_t uid);
78 gid_t pdb_group_rid_to_gid(uint32_t group_rid);
79 gid_t max_algorithmic_gid(void);
80 uint32_t algorithmic_pdb_gid_to_group_rid(gid_t gid);
81 bool algorithmic_pdb_rid_is_user(uint32_t rid);
82 bool lookup_global_sam_name(const char *name, int flags, uint32_t *rid,
83 enum lsa_SidType *type);
84 NTSTATUS local_password_change(const char *user_name,
85 int local_flags,
86 const char *new_passwd,
87 char **pp_err_str,
88 char **pp_msg_str);
89 bool init_samu_from_buffer(struct samu *sampass, uint32_t level,
90 uint8_t *buf, uint32_t buflen);
91 uint32_t init_buffer_from_samu (uint8_t **buf, struct samu *sampass, bool size_only);
92 bool pdb_copy_sam_account(struct samu *dst, struct samu *src );
93 bool pdb_update_bad_password_count(struct samu *sampass, bool *updated);
94 bool pdb_update_autolock_flag(struct samu *sampass, bool *updated);
95 bool pdb_increment_bad_password_count(struct samu *sampass);
96 bool is_dc_trusted_domain_situation(const char *domain_name);
97 bool get_trust_pw_clear(const char *domain, char **ret_pwd,
98 const char **account_name,
99 enum netr_SchannelType *channel);
100 bool get_trust_pw_hash(const char *domain, uint8_t ret_pwd[16],
101 const char **account_name,
102 enum netr_SchannelType *channel);
104 /* The following definitions come from passdb/pdb_compat.c */
106 uint32_t pdb_get_user_rid (const struct samu *sampass);
107 uint32_t pdb_get_group_rid (struct samu *sampass);
108 bool pdb_set_user_sid_from_rid (struct samu *sampass, uint32_t rid, enum pdb_value_state flag);
109 bool pdb_set_group_sid_from_rid (struct samu *sampass, uint32_t grid, enum pdb_value_state flag);
111 /* The following definitions come from passdb/pdb_get_set.c */
113 uint32_t pdb_get_acct_ctrl(const struct samu *sampass);
114 time_t pdb_get_logon_time(const struct samu *sampass);
115 time_t pdb_get_logoff_time(const struct samu *sampass);
116 time_t pdb_get_kickoff_time(const struct samu *sampass);
117 time_t pdb_get_bad_password_time(const struct samu *sampass);
118 time_t pdb_get_pass_last_set_time(const struct samu *sampass);
119 time_t pdb_get_pass_can_change_time(const struct samu *sampass);
120 time_t pdb_get_pass_can_change_time_noncalc(const struct samu *sampass);
121 time_t pdb_get_pass_must_change_time(const struct samu *sampass);
122 bool pdb_get_pass_can_change(const struct samu *sampass);
123 uint16_t pdb_get_logon_divs(const struct samu *sampass);
124 uint32_t pdb_get_hours_len(const struct samu *sampass);
125 const uint8_t *pdb_get_hours(const struct samu *sampass);
126 const uint8_t *pdb_get_nt_passwd(const struct samu *sampass);
127 const uint8_t *pdb_get_lanman_passwd(const struct samu *sampass);
128 const uint8_t *pdb_get_pw_history(const struct samu *sampass, uint32_t *current_hist_len);
129 const char *pdb_get_plaintext_passwd(const struct samu *sampass);
130 const struct dom_sid *pdb_get_user_sid(const struct samu *sampass);
131 const struct dom_sid *pdb_get_group_sid(struct samu *sampass);
132 enum pdb_value_state pdb_get_init_flags(const struct samu *sampass, enum pdb_elements element);
133 const char *pdb_get_username(const struct samu *sampass);
134 const char *pdb_get_domain(const struct samu *sampass);
135 const char *pdb_get_nt_username(const struct samu *sampass);
136 const char *pdb_get_fullname(const struct samu *sampass);
137 const char *pdb_get_homedir(const struct samu *sampass);
138 const char *pdb_get_dir_drive(const struct samu *sampass);
139 const char *pdb_get_logon_script(const struct samu *sampass);
140 const char *pdb_get_profile_path(const struct samu *sampass);
141 const char *pdb_get_acct_desc(const struct samu *sampass);
142 const char *pdb_get_workstations(const struct samu *sampass);
143 const char *pdb_get_comment(const struct samu *sampass);
144 const char *pdb_get_munged_dial(const struct samu *sampass);
145 uint16_t pdb_get_bad_password_count(const struct samu *sampass);
146 uint16_t pdb_get_logon_count(const struct samu *sampass);
147 uint16_t pdb_get_country_code(const struct samu *sampass);
148 uint16_t pdb_get_code_page(const struct samu *sampass);
149 uint32_t pdb_get_unknown_6(const struct samu *sampass);
150 void *pdb_get_backend_private_data(const struct samu *sampass, const struct pdb_methods *my_methods);
151 bool pdb_set_acct_ctrl(struct samu *sampass, uint32_t acct_ctrl, enum pdb_value_state flag);
152 bool pdb_set_logon_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
153 bool pdb_set_logoff_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
154 bool pdb_set_kickoff_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
155 bool pdb_set_bad_password_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
156 bool pdb_set_pass_can_change_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
157 bool pdb_set_pass_must_change_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
158 bool pdb_set_pass_last_set_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
159 bool pdb_set_hours_len(struct samu *sampass, uint32_t len, enum pdb_value_state flag);
160 bool pdb_set_logon_divs(struct samu *sampass, uint16_t hours, enum pdb_value_state flag);
161 bool pdb_set_init_flags(struct samu *sampass, enum pdb_elements element, enum pdb_value_state value_flag);
162 bool pdb_set_user_sid(struct samu *sampass, const struct dom_sid *u_sid, enum pdb_value_state flag);
163 bool pdb_set_user_sid_from_string(struct samu *sampass, fstring u_sid, enum pdb_value_state flag);
164 bool pdb_set_group_sid(struct samu *sampass, const struct dom_sid *g_sid, enum pdb_value_state flag);
165 bool pdb_set_username(struct samu *sampass, const char *username, enum pdb_value_state flag);
166 bool pdb_set_domain(struct samu *sampass, const char *domain, enum pdb_value_state flag);
167 bool pdb_set_nt_username(struct samu *sampass, const char *nt_username, enum pdb_value_state flag);
168 bool pdb_set_fullname(struct samu *sampass, const char *full_name, enum pdb_value_state flag);
169 bool pdb_set_logon_script(struct samu *sampass, const char *logon_script, enum pdb_value_state flag);
170 bool pdb_set_profile_path(struct samu *sampass, const char *profile_path, enum pdb_value_state flag);
171 bool pdb_set_dir_drive(struct samu *sampass, const char *dir_drive, enum pdb_value_state flag);
172 bool pdb_set_homedir(struct samu *sampass, const char *home_dir, enum pdb_value_state flag);
173 bool pdb_set_acct_desc(struct samu *sampass, const char *acct_desc, enum pdb_value_state flag);
174 bool pdb_set_workstations(struct samu *sampass, const char *workstations, enum pdb_value_state flag);
175 bool pdb_set_comment(struct samu *sampass, const char *comment, enum pdb_value_state flag);
176 bool pdb_set_munged_dial(struct samu *sampass, const char *munged_dial, enum pdb_value_state flag);
177 bool pdb_set_nt_passwd(struct samu *sampass, const uint8_t pwd[NT_HASH_LEN], enum pdb_value_state flag);
178 bool pdb_set_lanman_passwd(struct samu *sampass, const uint8_t pwd[LM_HASH_LEN], enum pdb_value_state flag);
179 bool pdb_set_pw_history(struct samu *sampass, const uint8_t *pwd, uint32_t historyLen, enum pdb_value_state flag);
180 bool pdb_set_plaintext_pw_only(struct samu *sampass, const char *password, enum pdb_value_state flag);
181 bool pdb_set_bad_password_count(struct samu *sampass, uint16_t bad_password_count, enum pdb_value_state flag);
182 bool pdb_set_logon_count(struct samu *sampass, uint16_t logon_count, enum pdb_value_state flag);
183 bool pdb_set_country_code(struct samu *sampass, uint16_t country_code,
184 enum pdb_value_state flag);
185 bool pdb_set_code_page(struct samu *sampass, uint16_t code_page,
186 enum pdb_value_state flag);
187 bool pdb_set_unknown_6(struct samu *sampass, uint32_t unkn, enum pdb_value_state flag);
188 bool pdb_set_hours(struct samu *sampass, const uint8 *hours, int hours_len,
189 enum pdb_value_state flag);
190 bool pdb_set_backend_private_data(struct samu *sampass, void *private_data,
191 void (*free_fn)(void **),
192 const struct pdb_methods *my_methods,
193 enum pdb_value_state flag);
194 bool pdb_set_pass_can_change(struct samu *sampass, bool canchange);
195 bool pdb_set_plaintext_passwd(struct samu *sampass, const char *plaintext);
196 uint32_t pdb_build_fields_present(struct samu *sampass);
198 /* The following definitions come from passdb/pdb_interface.c */
200 NTSTATUS smb_register_passdb(int version, const char *name, pdb_init_function init) ;
201 struct pdb_init_function_entry *pdb_find_backend_entry(const char *name);
202 struct event_context *pdb_get_event_context(void);
203 NTSTATUS make_pdb_method_name(struct pdb_methods **methods, const char *selected);
204 struct pdb_domain_info *pdb_get_domain_info(TALLOC_CTX *mem_ctx);
205 bool pdb_getsampwnam(struct samu *sam_acct, const char *username) ;
206 bool pdb_getsampwsid(struct samu *sam_acct, const struct dom_sid *sid) ;
207 NTSTATUS pdb_create_user(TALLOC_CTX *mem_ctx, const char *name, uint32_t flags,
208 uint32_t *rid);
209 NTSTATUS pdb_delete_user(TALLOC_CTX *mem_ctx, struct samu *sam_acct);
210 NTSTATUS pdb_add_sam_account(struct samu *sam_acct) ;
211 NTSTATUS pdb_update_sam_account(struct samu *sam_acct) ;
212 NTSTATUS pdb_delete_sam_account(struct samu *sam_acct) ;
213 NTSTATUS pdb_rename_sam_account(struct samu *oldname, const char *newname);
214 NTSTATUS pdb_update_login_attempts(struct samu *sam_acct, bool success);
215 bool pdb_getgrsid(GROUP_MAP *map, struct dom_sid sid);
216 bool pdb_getgrgid(GROUP_MAP *map, gid_t gid);
217 bool pdb_getgrnam(GROUP_MAP *map, const char *name);
218 NTSTATUS pdb_create_dom_group(TALLOC_CTX *mem_ctx, const char *name,
219 uint32_t *rid);
220 NTSTATUS pdb_delete_dom_group(TALLOC_CTX *mem_ctx, uint32_t rid);
221 NTSTATUS pdb_add_group_mapping_entry(GROUP_MAP *map);
222 NTSTATUS pdb_update_group_mapping_entry(GROUP_MAP *map);
223 NTSTATUS pdb_delete_group_mapping_entry(struct dom_sid sid);
224 bool pdb_enum_group_mapping(const struct dom_sid *sid, enum lsa_SidType sid_name_use, GROUP_MAP **pp_rmap,
225 size_t *p_num_entries, bool unix_only);
226 NTSTATUS pdb_enum_group_members(TALLOC_CTX *mem_ctx,
227 const struct dom_sid *sid,
228 uint32_t **pp_member_rids,
229 size_t *p_num_members);
230 NTSTATUS pdb_enum_group_memberships(TALLOC_CTX *mem_ctx, struct samu *user,
231 struct dom_sid **pp_sids, gid_t **pp_gids,
232 uint32_t *p_num_groups);
233 NTSTATUS pdb_set_unix_primary_group(TALLOC_CTX *mem_ctx, struct samu *user);
234 NTSTATUS pdb_add_groupmem(TALLOC_CTX *mem_ctx, uint32_t group_rid,
235 uint32_t member_rid);
236 NTSTATUS pdb_del_groupmem(TALLOC_CTX *mem_ctx, uint32_t group_rid,
237 uint32_t member_rid);
238 NTSTATUS pdb_create_alias(const char *name, uint32_t *rid);
239 NTSTATUS pdb_delete_alias(const struct dom_sid *sid);
240 NTSTATUS pdb_get_aliasinfo(const struct dom_sid *sid, struct acct_info *info);
241 NTSTATUS pdb_set_aliasinfo(const struct dom_sid *sid, struct acct_info *info);
242 NTSTATUS pdb_add_aliasmem(const struct dom_sid *alias, const struct dom_sid *member);
243 NTSTATUS pdb_del_aliasmem(const struct dom_sid *alias, const struct dom_sid *member);
244 NTSTATUS pdb_enum_aliasmem(const struct dom_sid *alias, TALLOC_CTX *mem_ctx,
245 struct dom_sid **pp_members, size_t *p_num_members);
246 NTSTATUS pdb_enum_alias_memberships(TALLOC_CTX *mem_ctx,
247 const struct dom_sid *domain_sid,
248 const struct dom_sid *members, size_t num_members,
249 uint32_t **pp_alias_rids,
250 size_t *p_num_alias_rids);
251 NTSTATUS pdb_lookup_rids(const struct dom_sid *domain_sid,
252 int num_rids,
253 uint32_t *rids,
254 const char **names,
255 enum lsa_SidType *attrs);
256 NTSTATUS pdb_lookup_names(const struct dom_sid *domain_sid,
257 int num_names,
258 const char **names,
259 uint32_t *rids,
260 enum lsa_SidType *attrs);
261 bool pdb_get_account_policy(enum pdb_policy_type type, uint32_t *value);
262 bool pdb_set_account_policy(enum pdb_policy_type type, uint32_t value);
263 bool pdb_get_seq_num(time_t *seq_num);
264 bool pdb_uid_to_sid(uid_t uid, struct dom_sid *sid);
265 bool pdb_gid_to_sid(gid_t gid, struct dom_sid *sid);
266 bool pdb_sid_to_id(const struct dom_sid *sid, union unid_t *id,
267 enum lsa_SidType *type);
268 uint32_t pdb_capabilities(void);
269 bool pdb_new_rid(uint32_t *rid);
270 bool initialize_password_db(bool reload, struct event_context *event_ctx);
271 struct pdb_search *pdb_search_init(TALLOC_CTX *mem_ctx,
272 enum pdb_search_type type);
273 struct pdb_search *pdb_search_users(TALLOC_CTX *mem_ctx, uint32_t acct_flags);
274 struct pdb_search *pdb_search_groups(TALLOC_CTX *mem_ctx);
275 struct pdb_search *pdb_search_aliases(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
276 uint32_t pdb_search_entries(struct pdb_search *search,
277 uint32_t start_idx, uint32_t max_entries,
278 struct samr_displayentry **result);
279 bool pdb_get_trusteddom_pw(const char *domain, char** pwd, struct dom_sid *sid,
280 time_t *pass_last_set_time);
281 bool pdb_set_trusteddom_pw(const char* domain, const char* pwd,
282 const struct dom_sid *sid);
283 bool pdb_del_trusteddom_pw(const char *domain);
284 NTSTATUS pdb_enum_trusteddoms(TALLOC_CTX *mem_ctx, uint32_t *num_domains,
285 struct trustdom_info ***domains);
286 NTSTATUS pdb_get_trusted_domain(TALLOC_CTX *mem_ctx, const char *domain,
287 struct pdb_trusted_domain **td);
288 NTSTATUS pdb_get_trusted_domain_by_sid(TALLOC_CTX *mem_ctx, struct dom_sid *sid,
289 struct pdb_trusted_domain **td);
290 NTSTATUS pdb_set_trusted_domain(const char* domain,
291 const struct pdb_trusted_domain *td);
292 NTSTATUS pdb_del_trusted_domain(const char *domain);
293 NTSTATUS pdb_enum_trusted_domains(TALLOC_CTX *mem_ctx, uint32_t *num_domains,
294 struct pdb_trusted_domain ***domains);
295 NTSTATUS make_pdb_method( struct pdb_methods **methods ) ;
297 /* The following definitions come from passdb/pdb_ldap.c */
299 const char** get_userattr_list( TALLOC_CTX *mem_ctx, int schema_ver );
300 NTSTATUS pdb_init_ldapsam_compat(struct pdb_methods **pdb_method, const char *location);
301 NTSTATUS pdb_init_ldapsam(struct pdb_methods **pdb_method, const char *location);
302 NTSTATUS pdb_ldap_init(void);
304 /* The following definitions come from passdb/pdb_nds.c */
306 struct smbldap_state;
308 int pdb_nds_get_password(
309 struct smbldap_state *ldap_state,
310 char *object_dn,
311 size_t *pwd_len,
312 char *pwd );
313 int pdb_nds_set_password(
314 struct smbldap_state *ldap_state,
315 char *object_dn,
316 const char *pwd );
317 NTSTATUS pdb_nds_init(void);
319 /* The following definitions come from passdb/pdb_nds.c */
321 NTSTATUS pdb_ipa_init(void);
323 /* The following definitions come from passdb/pdb_smbpasswd.c */
325 NTSTATUS pdb_smbpasswd_init(void) ;
327 /* The following definitions come from passdb/pdb_wbc_sam.c */
329 NTSTATUS pdb_wbc_sam_init(void);
331 /* The following definitions come from passdb/pdb_tdb.c */
333 NTSTATUS pdb_tdbsam_init(void);
335 /* The following definitions come from passdb/pdb_util.c */
337 NTSTATUS create_builtin_users(const struct dom_sid *sid);
338 NTSTATUS create_builtin_administrators(const struct dom_sid *sid);