1 /*
2    Unix SMB/CIFS implementation.
3    passdb structures and parameters
4    Copyright (C) Gerald Carter 2001
5    Copyright (C) Luke Kenneth Casson Leighton 1998 - 2000
6    Copyright (C) Andrew Bartlett 2002
7    Copyright (C) Simo Sorce 2003
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 _PASSDB_H
24 #define _PASSDB_H
25 
26 #ifndef NT_HASH_LEN
27 #define NT_HASH_LEN 16
28 #endif
29 
30 #ifndef LM_HASH_LEN
31 #define LM_HASH_LEN 16
32 #endif
33 
34 #include "../librpc/gen_ndr/lsa.h"
35 #include <tevent.h>
36 struct unixid;
37 struct cli_credentials;
38 
39 /* group mapping headers */
40 
41 #define ENUM_ONLY_MAPPED True
42 #define ENUM_ALL_MAPPED False
43 
44 typedef struct _GROUP_MAP {
45 	struct pdb_methods *methods;
46 	gid_t gid;
47 	struct dom_sid sid;
48 	enum lsa_SidType sid_name_use;
49 	char *nt_name;
50 	char *comment;
51 } GROUP_MAP;
52 
53 struct acct_info {
54 	char *acct_name; /* account name */
55 	char *acct_desc; /* account name */
56 	uint32_t rid; /* domain-relative RID */
57 };
58 
59 /* The following definitions come from groupdb/mapping.c  */
60 
61 NTSTATUS add_initial_entry(gid_t gid, const char *sid, enum lsa_SidType sid_name_use, const char *nt_name, const char *comment);
62 bool get_domain_group_from_sid(struct dom_sid sid, GROUP_MAP *map);
63 int smb_create_group(const char *unix_group, gid_t *new_gid);
64 int smb_delete_group(const char *unix_group);
65 int smb_set_primary_group(const char *unix_group, const char* unix_user);
66 int smb_add_user_group(const char *unix_group, const char *unix_user);
67 int smb_delete_user_group(const char *unix_group, const char *unix_user);
68 NTSTATUS pdb_default_getgrsid(struct pdb_methods *methods, GROUP_MAP *map,
69 				 struct dom_sid sid);
70 NTSTATUS pdb_default_getgrgid(struct pdb_methods *methods, GROUP_MAP *map,
71 				 gid_t gid);
72 NTSTATUS pdb_default_getgrnam(struct pdb_methods *methods, GROUP_MAP *map,
73 				 const char *name);
74 NTSTATUS pdb_default_add_group_mapping_entry(struct pdb_methods *methods,
75 						GROUP_MAP *map);
76 NTSTATUS pdb_default_update_group_mapping_entry(struct pdb_methods *methods,
77 						   GROUP_MAP *map);
78 NTSTATUS pdb_default_delete_group_mapping_entry(struct pdb_methods *methods,
79 						   struct dom_sid sid);
80 NTSTATUS pdb_default_enum_group_mapping(struct pdb_methods *methods,
81 					const struct dom_sid *sid,
82 					enum lsa_SidType sid_name_use,
83 					GROUP_MAP ***pp_rmap,
84 					size_t *p_num_entries,
85 					bool unix_only);
86 NTSTATUS pdb_default_create_alias(struct pdb_methods *methods,
87 				  const char *name, uint32_t *rid);
88 NTSTATUS pdb_default_delete_alias(struct pdb_methods *methods,
89 				  const struct dom_sid *sid);
90 NTSTATUS pdb_default_get_aliasinfo(struct pdb_methods *methods,
91 				   const struct dom_sid *sid,
92 				   struct acct_info *info);
93 NTSTATUS pdb_default_set_aliasinfo(struct pdb_methods *methods,
94 				   const struct dom_sid *sid,
95 				   struct acct_info *info);
96 NTSTATUS pdb_default_add_aliasmem(struct pdb_methods *methods,
97 				  const struct dom_sid *alias, const struct dom_sid *member);
98 NTSTATUS pdb_default_del_aliasmem(struct pdb_methods *methods,
99 				  const struct dom_sid *alias, const struct dom_sid *member);
100 NTSTATUS pdb_default_enum_aliasmem(struct pdb_methods *methods,
101 				   const struct dom_sid *alias, TALLOC_CTX *mem_ctx,
102 				   struct dom_sid **pp_members,
103 				   size_t *p_num_members);
104 NTSTATUS pdb_default_alias_memberships(struct pdb_methods *methods,
105 				       TALLOC_CTX *mem_ctx,
106 				       const struct dom_sid *domain_sid,
107 				       const struct dom_sid *members,
108 				       size_t num_members,
109 				       uint32_t **pp_alias_rids,
110 				       size_t *p_num_alias_rids);
111 NTSTATUS pdb_nop_getgrsid(struct pdb_methods *methods, GROUP_MAP *map,
112 				 struct dom_sid sid);
113 NTSTATUS pdb_nop_getgrgid(struct pdb_methods *methods, GROUP_MAP *map,
114 				 gid_t gid);
115 NTSTATUS pdb_nop_getgrnam(struct pdb_methods *methods, GROUP_MAP *map,
116 				 const char *name);
117 NTSTATUS pdb_nop_add_group_mapping_entry(struct pdb_methods *methods,
118 						GROUP_MAP *map);
119 NTSTATUS pdb_nop_update_group_mapping_entry(struct pdb_methods *methods,
120 						   GROUP_MAP *map);
121 NTSTATUS pdb_nop_delete_group_mapping_entry(struct pdb_methods *methods,
122 						   struct dom_sid sid);
123 NTSTATUS pdb_nop_enum_group_mapping(struct pdb_methods *methods,
124 					   enum lsa_SidType sid_name_use,
125 					   GROUP_MAP **rmap, size_t *num_entries,
126 					   bool unix_only);
127 NTSTATUS pdb_create_builtin_alias(uint32_t rid, gid_t gid);
128 
129 
130 /* passdb headers */
131 
132 /**********************************************************************
133  * Masks for mappings between unix uid and gid types and
134  * NT RIDS.
135  **********************************************************************/
136 
137 /* Take the bottom bit. */
138 #define RID_TYPE_MASK 		1
139 #define RID_MULTIPLIER 		2
140 
141 /* The two common types. */
142 #define USER_RID_TYPE 		0
143 #define GROUP_RID_TYPE 		1
144 
145 /*
146  * Flags for local user manipulation.
147  */
148 
149 #define LOCAL_ADD_USER 0x1
150 #define LOCAL_DELETE_USER 0x2
151 #define LOCAL_DISABLE_USER 0x4
152 #define LOCAL_ENABLE_USER 0x8
153 #define LOCAL_TRUST_ACCOUNT 0x10
154 #define LOCAL_SET_NO_PASSWORD 0x20
155 #define LOCAL_SET_PASSWORD 0x40
156 #define LOCAL_SET_LDAP_ADMIN_PW 0x80
157 #define LOCAL_INTERDOM_ACCOUNT 0x100
158 #define LOCAL_AM_ROOT 0x200  /* Act as root */
159 
160 /*
161  * Size of new password account encoding string.  This is enough space to
162  * hold 11 ACB characters, plus the surrounding [] and a terminating null.
163  * Do not change unless you are adding new ACB bits!
164  */
165 
166 #define NEW_PW_FORMAT_SPACE_PADDED_LEN 14
167 
168 /* Password history contants. */
169 #define PW_HISTORY_SALT_LEN 16
170 #define SALTED_MD5_HASH_LEN 16
171 #define PW_HISTORY_ENTRY_LEN (PW_HISTORY_SALT_LEN+SALTED_MD5_HASH_LEN)
172 #define MAX_PW_HISTORY_LEN 24
173 
174 /*
175  * bit flags representing initialized fields in struct samu
176  */
177 enum pdb_elements {
178 	PDB_UNINIT,
179 	PDB_SMBHOME,
180 	PDB_PROFILE,
181 	PDB_DRIVE,
182 	PDB_LOGONSCRIPT,
183 	PDB_LOGONTIME,
184 	PDB_LOGOFFTIME,
185 	PDB_KICKOFFTIME,
186 	PDB_BAD_PASSWORD_TIME,
187 	PDB_CANCHANGETIME,
188 	PDB_PLAINTEXT_PW,
189 	PDB_USERNAME,
190 	PDB_FULLNAME,
191 	PDB_DOMAIN,
192 	PDB_NTUSERNAME,
193 	PDB_HOURSLEN,
194 	PDB_LOGONDIVS,
195 	PDB_USERSID,
196 	PDB_GROUPSID,
197 	PDB_ACCTCTRL,
198 	PDB_PASSLASTSET,
199 	PDB_ACCTDESC,
200 	PDB_WORKSTATIONS,
201 	PDB_COMMENT,
202 	PDB_MUNGEDDIAL,
203 	PDB_HOURS,
204 	PDB_FIELDS_PRESENT,
205 	PDB_BAD_PASSWORD_COUNT,
206 	PDB_LOGON_COUNT,
207 	PDB_COUNTRY_CODE,
208 	PDB_CODE_PAGE,
209 	PDB_UNKNOWN6,
210 	PDB_LMPASSWD,
211 	PDB_NTPASSWD,
212 	PDB_PWHISTORY,
213 	PDB_BACKEND_PRIVATE_DATA,
214 
215 	/* this must be the last element */
216 	PDB_COUNT
217 };
218 
219 enum pdb_group_elements {
220 	PDB_GROUP_NAME,
221 	PDB_GROUP_SID,
222 	PDB_GROUP_SID_NAME_USE,
223 	PDB_GROUP_MEMBERS,
224 
225 	/* this must be the last element */
226 	PDB_GROUP_COUNT
227 };
228 
229 
230 enum pdb_value_state {
231 	PDB_DEFAULT=0,
232 	PDB_SET,
233 	PDB_CHANGED
234 };
235 
236 #define IS_SAM_SET(x, flag)	(pdb_get_init_flags(x, flag) == PDB_SET)
237 #define IS_SAM_CHANGED(x, flag)	(pdb_get_init_flags(x, flag) == PDB_CHANGED)
238 #define IS_SAM_DEFAULT(x, flag)	(pdb_get_init_flags(x, flag) == PDB_DEFAULT)
239 
240 /* cache for bad password lockout data, to be used on replicated SAMs */
241 struct login_cache {
242 	time_t entry_timestamp;
243 	uint32_t acct_ctrl;
244 	uint16_t bad_password_count;
245 	time_t bad_password_time;
246 };
247 
248 #define SAMU_BUFFER_V0		0
249 #define SAMU_BUFFER_V1		1
250 #define SAMU_BUFFER_V2		2
251 #define SAMU_BUFFER_V3		3
252 /* nothing changed from V3 to V4 */
253 #define SAMU_BUFFER_V4		4
254 #define SAMU_BUFFER_LATEST	SAMU_BUFFER_V4
255 
256 #define MAX_HOURS_LEN 32
257 
258 struct samu {
259 	struct pdb_methods *methods;
260 
261 	/* initialization flags */
262 	struct bitmap *change_flags;
263 	struct bitmap *set_flags;
264 
265 	time_t logon_time;            /* logon time */
266 	time_t logoff_time;           /* logoff time */
267 	time_t kickoff_time;          /* kickoff time */
268 	time_t bad_password_time;     /* last bad password entered */
269 	time_t pass_last_set_time;    /* password last set time */
270 	time_t pass_can_change_time;  /* password can change time */
271 
272 	const char *username;     /* UNIX username string */
273 	const char *domain;       /* Windows Domain name */
274 	const char *nt_username;  /* Windows username string */
275 	const char *full_name;    /* user's full name string */
276 	const char *home_dir;     /* home directory string */
277 	const char *dir_drive;    /* home directory drive string */
278 	const char *logon_script; /* logon script string */
279 	const char *profile_path; /* profile path string */
280 	const char *acct_desc;    /* user description string */
281 	const char *workstations; /* login from workstations string */
282 	const char *comment;
283 	const char *munged_dial;  /* munged path name and dial-back tel number */
284 
285 	struct dom_sid user_sid;
286 	struct dom_sid *group_sid;
287 
288 	DATA_BLOB lm_pw; /* .data is Null if no password */
289 	DATA_BLOB nt_pw; /* .data is Null if no password */
290 	DATA_BLOB nt_pw_his; /* nt hashed password history .data is Null if not available */
291 	char* plaintext_pw; /* is Null if not available */
292 
293 	uint32_t acct_ctrl; /* account info (ACB_xxxx bit-mask) */
294 	uint32_t fields_present; /* 0x00ff ffff */
295 
296 	uint16_t logon_divs; /* 168 - number of hours in a week */
297 	uint32_t hours_len; /* normally 21 bytes */
298 	uint8_t hours[MAX_HOURS_LEN];
299 
300 	/* Was unknown_5. */
301 	uint16_t bad_password_count;
302 	uint16_t logon_count;
303 
304 	uint16_t country_code;
305 	uint16_t code_page;
306 
307 	uint32_t unknown_6; /* 0x0000 04ec */
308 
309 	/* a tag for who added the private methods */
310 
311 	const struct pdb_methods *backend_private_methods;
312 	void *backend_private_data;
313 	void (*backend_private_data_free_fn)(void **);
314 
315 	/* maintain a copy of the user's struct passwd */
316 
317 	struct passwd *unix_pw;
318 };
319 
320 struct samr_displayentry {
321 	uint32_t idx;
322 	uint32_t rid;
323 	uint32_t acct_flags;
324 	const char *account_name;
325 	const char *fullname;
326 	const char *description;
327 };
328 
329 enum pdb_search_type {
330 	PDB_USER_SEARCH,
331 	PDB_GROUP_SEARCH,
332 	PDB_ALIAS_SEARCH
333 };
334 
335 struct pdb_search {
336 	enum pdb_search_type type;
337 	struct samr_displayentry *cache;
338 	uint32_t num_entries;
339 	ssize_t cache_size;
340 	bool search_ended;
341 	void *private_data;
342 	bool (*next_entry)(struct pdb_search *search,
343 			   struct samr_displayentry *entry);
344 	void (*search_end)(struct pdb_search *search);
345 };
346 
347 struct pdb_domain_info {
348 	char *name;
349 	char *dns_domain;
350 	char *dns_forest;
351 	struct dom_sid sid;
352 	struct GUID guid;
353 };
354 
355 struct pdb_trusted_domain {
356 	char *domain_name;
357 	char *netbios_name;
358 	struct dom_sid security_identifier;
359 	DATA_BLOB trust_auth_incoming;
360 	DATA_BLOB trust_auth_outgoing;
361 	uint32_t trust_direction;
362 	uint32_t trust_type;
363 	uint32_t trust_attributes;
364 	uint32_t *trust_posix_offset;
365 	uint32_t *supported_enc_type;
366 	DATA_BLOB trust_forest_trust_info;
367 };
368 
369 /*
370  * trusted domain entry/entries returned by secrets_get_trusted_domains
371  * (used in _lsa_enum_trust_dom call)
372  */
373 struct trustdom_info {
374 	char *name;
375 	struct dom_sid sid;
376 };
377 
378 /*
379  * Types of account policy.
380  */
381 enum pdb_policy_type {
382 	PDB_POLICY_MIN_PASSWORD_LEN = 1,
383 	PDB_POLICY_PASSWORD_HISTORY = 2,
384 	PDB_POLICY_USER_MUST_LOGON_TO_CHG_PASS	= 3,
385 	PDB_POLICY_MAX_PASSWORD_AGE = 4,
386 	PDB_POLICY_MIN_PASSWORD_AGE = 5,
387 	PDB_POLICY_LOCK_ACCOUNT_DURATION = 6,
388 	PDB_POLICY_RESET_COUNT_TIME = 7,
389 	PDB_POLICY_BAD_ATTEMPT_LOCKOUT = 8,
390 	PDB_POLICY_TIME_TO_LOGOUT = 9,
391 	PDB_POLICY_REFUSE_MACHINE_PW_CHANGE = 10
392 };
393 
394 #define PDB_CAP_STORE_RIDS		0x0001
395 #define PDB_CAP_ADS			0x0002
396 #define PDB_CAP_TRUSTED_DOMAINS_EX	0x0004
397 
398 /*****************************************************************
399  Functions to be implemented by the new (v2) passdb API
400 ****************************************************************/
401 
402 /*
403  * This next constant specifies the version number of the PASSDB interface
404  * this SAMBA will load. Increment this if *ANY* changes are made to the interface.
405  * Changed interface to fix int -> size_t problems. JRA.
406  * There's no point in allocating arrays in
407  * samr_lookup_rids twice. It was done in the srv_samr_nt.c code as well as in
408  * the pdb module. Remove the latter, this might happen more often. VL.
409  * changed to version 14 to move lookup_rids and lookup_names to return
410  * enum lsa_SidType rather than uint32_t.
411  * Changed to 16 for access to the trusted domain passwords (obnox).
412  * Changed to 17, the sampwent interface is gone.
413  * Changed to 18, pdb_rid_algorithm -> pdb_capabilities
414  * Changed to 19, removed uid_to_rid
415  * Changed to 20, pdb_secret calls
416  * Changed to 21, set/enum_upn_suffixes. AB.
417  * Changed to 22, idmap control functions
418  * Changed to 23, new idmap control functions
419  * Changed to 24, removed uid_to_sid and gid_to_sid, replaced with id_to_sid
420  * Leave at 24, add optional get_trusteddom_creds()
421  * Change to 25, loadable modules now have a TALLOC_CTX * parameter in init.
422  */
423 
424 #define PASSDB_INTERFACE_VERSION 25
425 
426 struct pdb_methods
427 {
428 	const char *name; /* What name got this module */
429 
430 	struct pdb_domain_info *(*get_domain_info)(struct pdb_methods *,
431 						   TALLOC_CTX *mem_ctx);
432 
433 	NTSTATUS (*getsampwnam)(struct pdb_methods *, struct samu *sam_acct, const char *username);
434 
435 	NTSTATUS (*getsampwsid)(struct pdb_methods *, struct samu *sam_acct, const struct dom_sid *sid);
436 
437 	NTSTATUS (*create_user)(struct pdb_methods *, TALLOC_CTX *tmp_ctx,
438 				const char *name, uint32_t acct_flags,
439 				uint32_t *rid);
440 
441 	NTSTATUS (*delete_user)(struct pdb_methods *, TALLOC_CTX *tmp_ctx,
442 				struct samu *sam_acct);
443 
444 	NTSTATUS (*add_sam_account)(struct pdb_methods *, struct samu *sampass);
445 
446 	NTSTATUS (*update_sam_account)(struct pdb_methods *, struct samu *sampass);
447 
448 	NTSTATUS (*delete_sam_account)(struct pdb_methods *, struct samu *username);
449 
450 	NTSTATUS (*rename_sam_account)(struct pdb_methods *, struct samu *oldname, const char *newname);
451 
452 	NTSTATUS (*update_login_attempts)(struct pdb_methods *methods, struct samu *sam_acct, bool success);
453 
454 	NTSTATUS (*getgrsid)(struct pdb_methods *methods, GROUP_MAP *map, struct dom_sid sid);
455 
456 	NTSTATUS (*getgrgid)(struct pdb_methods *methods, GROUP_MAP *map, gid_t gid);
457 
458 	NTSTATUS (*getgrnam)(struct pdb_methods *methods, GROUP_MAP *map, const char *name);
459 
460 	NTSTATUS (*create_dom_group)(struct pdb_methods *methods,
461 				     TALLOC_CTX *mem_ctx, const char *name,
462 				     uint32_t *rid);
463 
464 	NTSTATUS (*delete_dom_group)(struct pdb_methods *methods,
465 				     TALLOC_CTX *mem_ctx, uint32_t rid);
466 
467 	NTSTATUS (*add_group_mapping_entry)(struct pdb_methods *methods,
468 					    GROUP_MAP *map);
469 
470 	NTSTATUS (*update_group_mapping_entry)(struct pdb_methods *methods,
471 					       GROUP_MAP *map);
472 
473 	NTSTATUS (*delete_group_mapping_entry)(struct pdb_methods *methods,
474 					       struct dom_sid sid);
475 
476 	NTSTATUS (*enum_group_mapping)(struct pdb_methods *methods,
477 				       const struct dom_sid *sid, enum lsa_SidType sid_name_use,
478 				       GROUP_MAP ***pp_rmap, size_t *p_num_entries,
479 				       bool unix_only);
480 
481 	NTSTATUS (*enum_group_members)(struct pdb_methods *methods,
482 				       TALLOC_CTX *mem_ctx,
483 				       const struct dom_sid *group,
484 				       uint32_t **pp_member_rids,
485 				       size_t *p_num_members);
486 
487 	NTSTATUS (*enum_group_memberships)(struct pdb_methods *methods,
488 					   TALLOC_CTX *mem_ctx,
489 					   struct samu *user,
490 					   struct dom_sid **pp_sids, gid_t **pp_gids,
491 					   uint32_t *p_num_groups);
492 
493 	NTSTATUS (*set_unix_primary_group)(struct pdb_methods *methods,
494 					   TALLOC_CTX *mem_ctx,
495 					   struct samu *user);
496 
497 	NTSTATUS (*add_groupmem)(struct pdb_methods *methods,
498 				 TALLOC_CTX *mem_ctx,
499 				 uint32_t group_rid, uint32_t member_rid);
500 
501 	NTSTATUS (*del_groupmem)(struct pdb_methods *methods,
502 				 TALLOC_CTX *mem_ctx,
503 				 uint32_t group_rid, uint32_t member_rid);
504 
505 	NTSTATUS (*create_alias)(struct pdb_methods *methods,
506 				 const char *name, uint32_t *rid);
507 
508 	NTSTATUS (*delete_alias)(struct pdb_methods *methods,
509 				 const struct dom_sid *sid);
510 
511 	NTSTATUS (*get_aliasinfo)(struct pdb_methods *methods,
512 				  const struct dom_sid *sid,
513 				  struct acct_info *info);
514 
515 	NTSTATUS (*set_aliasinfo)(struct pdb_methods *methods,
516 				  const struct dom_sid *sid,
517 				  struct acct_info *info);
518 
519 	NTSTATUS (*add_aliasmem)(struct pdb_methods *methods,
520 				 const struct dom_sid *alias, const struct dom_sid *member);
521 	NTSTATUS (*del_aliasmem)(struct pdb_methods *methods,
522 				 const struct dom_sid *alias, const struct dom_sid *member);
523 	NTSTATUS (*enum_aliasmem)(struct pdb_methods *methods,
524 				  const struct dom_sid *alias, TALLOC_CTX *mem_ctx,
525 				  struct dom_sid **members, size_t *p_num_members);
526 	NTSTATUS (*enum_alias_memberships)(struct pdb_methods *methods,
527 					   TALLOC_CTX *mem_ctx,
528 					   const struct dom_sid *domain_sid,
529 					   const struct dom_sid *members,
530 					   size_t num_members,
531 					   uint32_t **pp_alias_rids,
532 					   size_t *p_num_alias_rids);
533 
534 	NTSTATUS (*lookup_rids)(struct pdb_methods *methods,
535 				const struct dom_sid *domain_sid,
536 				int num_rids,
537 				uint32_t *rids,
538 				const char **pp_names,
539 				enum lsa_SidType *attrs);
540 
541 	NTSTATUS (*lookup_names)(struct pdb_methods *methods,
542 				 const struct dom_sid *domain_sid,
543 				 int num_names,
544 				 const char **pp_names,
545 				 uint32_t *rids,
546 				 enum lsa_SidType *attrs);
547 
548 	NTSTATUS (*get_account_policy)(struct pdb_methods *methods,
549 				       enum pdb_policy_type type,
550 				       uint32_t *value);
551 
552 	NTSTATUS (*set_account_policy)(struct pdb_methods *methods,
553 				       enum pdb_policy_type type,
554 				       uint32_t value);
555 
556 	NTSTATUS (*get_seq_num)(struct pdb_methods *methods, time_t *seq_num);
557 
558 	bool (*search_users)(struct pdb_methods *methods,
559 			     struct pdb_search *search,
560 			     uint32_t acct_flags);
561 	bool (*search_groups)(struct pdb_methods *methods,
562 			      struct pdb_search *search);
563 	bool (*search_aliases)(struct pdb_methods *methods,
564 			       struct pdb_search *search,
565 			       const struct dom_sid *sid);
566 
567 	/*
568 	 * Instead of passing down a gid or uid, this function sends down a pointer
569 	 * to a unixid.
570 	 *
571 	 * This acts as an in-out variable so that the idmap functions can correctly
572 	 * receive ID_TYPE_BOTH, filling in cache details correctly rather than forcing
573 	 * the cache to store ID_TYPE_UID or ID_TYPE_GID.
574 	 */
575 	bool (*id_to_sid)(struct pdb_methods *methods, struct unixid *id,
576 			  struct dom_sid *sid);
577 	bool (*sid_to_id)(struct pdb_methods *methods, const struct dom_sid *sid,
578 			  struct unixid *id);
579 
580 	uint32_t (*capabilities)(struct pdb_methods *methods);
581 	bool (*new_rid)(struct pdb_methods *methods, uint32_t *rid);
582 
583 
584 	bool (*get_trusteddom_pw)(struct pdb_methods *methods,
585 				  const char *domain, char** pwd,
586 				  struct dom_sid *sid, time_t *pass_last_set_time);
587 	NTSTATUS (*get_trusteddom_creds)(struct pdb_methods *methods,
588 					 const char *domain,
589 					 TALLOC_CTX *mem_ctx,
590 					 struct cli_credentials **creds);
591 	bool (*set_trusteddom_pw)(struct pdb_methods *methods,
592 				  const char* domain, const char* pwd,
593 				  const struct dom_sid *sid);
594 	bool (*del_trusteddom_pw)(struct pdb_methods *methods,
595 				  const char *domain);
596 	NTSTATUS (*enum_trusteddoms)(struct pdb_methods *methods,
597 				     TALLOC_CTX *mem_ctx, uint32_t *num_domains,
598 				     struct trustdom_info ***domains);
599 
600 	NTSTATUS (*get_trusted_domain)(struct pdb_methods *methods,
601 				       TALLOC_CTX *mem_ctx,
602 				       const char *domain,
603 				       struct pdb_trusted_domain **td);
604 	NTSTATUS (*get_trusted_domain_by_sid)(struct pdb_methods *methods,
605 					      TALLOC_CTX *mem_ctx,
606 					      struct dom_sid *sid,
607 					      struct pdb_trusted_domain **td);
608 	NTSTATUS (*set_trusted_domain)(struct pdb_methods *methods,
609 				       const char* domain,
610 				       const struct pdb_trusted_domain *td);
611 	NTSTATUS (*del_trusted_domain)(struct pdb_methods *methods,
612 				       const char *domain);
613 	NTSTATUS (*enum_trusted_domains)(struct pdb_methods *methods,
614 					 TALLOC_CTX *mem_ctx,
615 					 uint32_t *num_domains,
616 					 struct pdb_trusted_domain ***domains);
617 
618 	NTSTATUS (*get_secret)(struct pdb_methods *methods,
619 			       TALLOC_CTX *mem_ctx,
620 			       const char *secret_name,
621 			       DATA_BLOB *secret_current,
622 			       NTTIME *secret_current_lastchange,
623 			       DATA_BLOB *secret_old,
624 			       NTTIME *secret_old_lastchange,
625 			       struct security_descriptor **sd);
626 	NTSTATUS (*set_secret)(struct pdb_methods *methods,
627 			       const char *secret_name,
628 			       DATA_BLOB *secret_current,
629 			       DATA_BLOB *secret_old,
630 			       struct security_descriptor *sd);
631 	NTSTATUS (*delete_secret)(struct pdb_methods *methods,
632 				  const char *secret_name);
633 
634 	NTSTATUS (*enum_upn_suffixes)(struct pdb_methods *methods,
635 				      TALLOC_CTX *mem_ctx,
636 				      uint32_t *num_suffixes,
637 				      char ***suffixes);
638 
639 	NTSTATUS (*set_upn_suffixes)(struct pdb_methods *methods,
640 				     uint32_t num_suffixes,
641 				     const char **suffixes);
642 
643 	bool (*is_responsible_for_our_sam)(struct pdb_methods *methods);
644 	bool (*is_responsible_for_builtin)(struct pdb_methods *methods);
645 	bool (*is_responsible_for_wellknown)(struct pdb_methods *methods);
646 	bool (*is_responsible_for_unix_users)(struct pdb_methods *methods);
647 	bool (*is_responsible_for_unix_groups)(struct pdb_methods *methods);
648 	bool (*is_responsible_for_everything_else)(struct pdb_methods *methods);
649 
650 	void *private_data;  /* Private data of some kind */
651 
652 	void (*free_private_data)(void **);
653 };
654 
655 typedef NTSTATUS (*pdb_init_function)(struct pdb_methods **, const char *);
656 
657 struct pdb_init_function_entry {
658 	const char *name;
659 
660 	/* Function to create a member of the pdb_methods list */
661 	pdb_init_function init;
662 
663 	struct pdb_init_function_entry *prev, *next;
664 };
665 
666 /* The following definitions come from passdb/account_pol.c  */
667 
668 void account_policy_names_list(TALLOC_CTX *mem_ctx, const char ***names, int *num_names);
669 const char *decode_account_policy_name(enum pdb_policy_type type);
670 const char *get_account_policy_attr(enum pdb_policy_type type);
671 const char *account_policy_get_desc(enum pdb_policy_type type);
672 enum pdb_policy_type account_policy_name_to_typenum(const char *name);
673 bool account_policy_get_default(enum pdb_policy_type type, uint32_t *val);
674 bool init_account_policy(void);
675 bool account_policy_get(enum pdb_policy_type type, uint32_t *value);
676 bool account_policy_set(enum pdb_policy_type type, uint32_t value);
677 bool cache_account_policy_set(enum pdb_policy_type type, uint32_t value);
678 bool cache_account_policy_get(enum pdb_policy_type type, uint32_t *value);
679 struct db_context *get_account_pol_db( void );
680 
681 /* The following definitions come from passdb/login_cache.c  */
682 
683 bool login_cache_init(void);
684 bool login_cache_shutdown(void);
685 bool login_cache_read(struct samu *sampass, struct login_cache *entry);
686 bool login_cache_write(const struct samu *sampass,
687 		       const struct login_cache *entry);
688 bool login_cache_delentry(const struct samu *sampass);
689 
690 /* The following definitions come from passdb/passdb.c  */
691 
692 struct samu *samu_new( TALLOC_CTX *ctx );
693 NTSTATUS samu_set_unix(struct samu *user, const struct passwd *pwd);
694 NTSTATUS samu_alloc_rid_unix(struct pdb_methods *methods,
695 			     struct samu *user, const struct passwd *pwd);
696 char *pdb_encode_acct_ctrl(uint32_t acct_ctrl, size_t length);
697 uint32_t pdb_decode_acct_ctrl(const char *p);
698 void pdb_sethexpwd(char p[33], const unsigned char *pwd, uint32_t acct_ctrl);
699 bool pdb_gethexpwd(const char *p, unsigned char *pwd);
700 void pdb_sethexhours(char *p, const unsigned char *hours);
701 bool pdb_gethexhours(const char *p, unsigned char *hours);
702 int algorithmic_rid_base(void);
703 uid_t algorithmic_pdb_user_rid_to_uid(uint32_t user_rid);
704 uid_t max_algorithmic_uid(void);
705 uint32_t algorithmic_pdb_uid_to_user_rid(uid_t uid);
706 gid_t pdb_group_rid_to_gid(uint32_t group_rid);
707 gid_t max_algorithmic_gid(void);
708 uint32_t algorithmic_pdb_gid_to_group_rid(gid_t gid);
709 bool algorithmic_pdb_rid_is_user(uint32_t rid);
710 bool lookup_global_sam_name(const char *name, int flags, uint32_t *rid,
711 			    enum lsa_SidType *type);
712 NTSTATUS local_password_change(const char *user_name,
713 				int local_flags,
714 				const char *new_passwd,
715 				char **pp_err_str,
716 				char **pp_msg_str);
717 bool init_samu_from_buffer(struct samu *sampass, uint32_t level,
718 			   uint8_t *buf, uint32_t buflen);
719 uint32_t init_buffer_from_samu (uint8_t **buf, struct samu *sampass, bool size_only);
720 bool pdb_copy_sam_account(struct samu *dst, struct samu *src );
721 bool pdb_update_bad_password_count(struct samu *sampass, bool *updated);
722 bool pdb_update_autolock_flag(struct samu *sampass, bool *updated);
723 bool pdb_increment_bad_password_count(struct samu *sampass);
724 bool is_dc_trusted_domain_situation(const char *domain_name);
725 bool get_trust_pw_clear(const char *domain, char **ret_pwd,
726 			const char **account_name,
727 			enum netr_SchannelType *channel);
728 bool get_trust_pw_hash(const char *domain, uint8_t ret_pwd[16],
729 		       const char **account_name,
730 		       enum netr_SchannelType *channel);
731 struct cli_credentials;
732 NTSTATUS pdb_get_trust_credentials(const char *netbios_domain,
733 				   const char *dns_domain, /* optional */
734 				   TALLOC_CTX *mem_ctx,
735 				   struct cli_credentials **_creds);
736 
737 /* The following definitions come from passdb/pdb_compat.c  */
738 
739 uint32_t pdb_get_user_rid (const struct samu *sampass);
740 uint32_t pdb_get_group_rid (struct samu *sampass);
741 bool pdb_set_user_sid_from_rid (struct samu *sampass, uint32_t rid, enum pdb_value_state flag);
742 bool pdb_set_group_sid_from_rid (struct samu *sampass, uint32_t grid, enum pdb_value_state flag);
743 
744 /* The following definitions come from passdb/pdb_get_set.c  */
745 
746 bool pdb_is_password_change_time_max(time_t test_time);
747 uint32_t pdb_get_acct_ctrl(const struct samu *sampass);
748 time_t pdb_get_logon_time(const struct samu *sampass);
749 time_t pdb_get_logoff_time(const struct samu *sampass);
750 time_t pdb_get_kickoff_time(const struct samu *sampass);
751 time_t pdb_get_bad_password_time(const struct samu *sampass);
752 time_t pdb_get_pass_last_set_time(const struct samu *sampass);
753 time_t pdb_get_pass_can_change_time(const struct samu *sampass);
754 time_t pdb_get_pass_can_change_time_noncalc(const struct samu *sampass);
755 time_t pdb_get_pass_must_change_time(const struct samu *sampass);
756 bool pdb_get_pass_can_change(const struct samu *sampass);
757 uint16_t pdb_get_logon_divs(const struct samu *sampass);
758 uint32_t pdb_get_hours_len(const struct samu *sampass);
759 const uint8_t *pdb_get_hours(const struct samu *sampass);
760 const uint8_t *pdb_get_nt_passwd(const struct samu *sampass);
761 const uint8_t *pdb_get_lanman_passwd(const struct samu *sampass);
762 const uint8_t *pdb_get_pw_history(const struct samu *sampass, uint32_t *current_hist_len);
763 const char *pdb_get_plaintext_passwd(const struct samu *sampass);
764 const struct dom_sid *pdb_get_user_sid(const struct samu *sampass);
765 const struct dom_sid *pdb_get_group_sid(struct samu *sampass);
766 enum pdb_value_state pdb_get_init_flags(const struct samu *sampass, enum pdb_elements element);
767 const char *pdb_get_username(const struct samu *sampass);
768 const char *pdb_get_domain(const struct samu *sampass);
769 const char *pdb_get_nt_username(const struct samu *sampass);
770 const char *pdb_get_fullname(const struct samu *sampass);
771 const char *pdb_get_homedir(const struct samu *sampass);
772 const char *pdb_get_dir_drive(const struct samu *sampass);
773 const char *pdb_get_logon_script(const struct samu *sampass);
774 const char *pdb_get_profile_path(const struct samu *sampass);
775 const char *pdb_get_acct_desc(const struct samu *sampass);
776 const char *pdb_get_workstations(const struct samu *sampass);
777 const char *pdb_get_comment(const struct samu *sampass);
778 const char *pdb_get_munged_dial(const struct samu *sampass);
779 uint16_t pdb_get_bad_password_count(const struct samu *sampass);
780 uint16_t pdb_get_logon_count(const struct samu *sampass);
781 uint16_t pdb_get_country_code(const struct samu *sampass);
782 uint16_t pdb_get_code_page(const struct samu *sampass);
783 uint32_t pdb_get_unknown_6(const struct samu *sampass);
784 void *pdb_get_backend_private_data(const struct samu *sampass, const struct pdb_methods *my_methods);
785 bool pdb_set_acct_ctrl(struct samu *sampass, uint32_t acct_ctrl, enum pdb_value_state flag);
786 bool pdb_set_logon_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
787 bool pdb_set_logoff_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
788 bool pdb_set_kickoff_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
789 bool pdb_set_bad_password_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
790 bool pdb_set_pass_can_change_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
791 bool pdb_set_pass_last_set_time(struct samu *sampass, time_t mytime, enum pdb_value_state flag);
792 bool pdb_set_hours_len(struct samu *sampass, uint32_t len, enum pdb_value_state flag);
793 bool pdb_set_logon_divs(struct samu *sampass, uint16_t hours, enum pdb_value_state flag);
794 bool pdb_set_init_flags(struct samu *sampass, enum pdb_elements element, enum pdb_value_state value_flag);
795 bool pdb_set_user_sid(struct samu *sampass, const struct dom_sid *u_sid, enum pdb_value_state flag);
796 bool pdb_set_user_sid_from_string(struct samu *sampass, const char *u_sid, enum pdb_value_state flag);
797 bool pdb_set_group_sid(struct samu *sampass, const struct dom_sid *g_sid, enum pdb_value_state flag);
798 bool pdb_set_username(struct samu *sampass, const char *username, enum pdb_value_state flag);
799 bool pdb_set_domain(struct samu *sampass, const char *domain, enum pdb_value_state flag);
800 bool pdb_set_nt_username(struct samu *sampass, const char *nt_username, enum pdb_value_state flag);
801 bool pdb_set_fullname(struct samu *sampass, const char *full_name, enum pdb_value_state flag);
802 bool pdb_set_logon_script(struct samu *sampass, const char *logon_script, enum pdb_value_state flag);
803 bool pdb_set_profile_path(struct samu *sampass, const char *profile_path, enum pdb_value_state flag);
804 bool pdb_set_dir_drive(struct samu *sampass, const char *dir_drive, enum pdb_value_state flag);
805 bool pdb_set_homedir(struct samu *sampass, const char *home_dir, enum pdb_value_state flag);
806 bool pdb_set_acct_desc(struct samu *sampass, const char *acct_desc, enum pdb_value_state flag);
807 bool pdb_set_workstations(struct samu *sampass, const char *workstations, enum pdb_value_state flag);
808 bool pdb_set_comment(struct samu *sampass, const char *comment, enum pdb_value_state flag);
809 bool pdb_set_munged_dial(struct samu *sampass, const char *munged_dial, enum pdb_value_state flag);
810 bool pdb_set_nt_passwd(struct samu *sampass, const uint8_t pwd[NT_HASH_LEN], enum pdb_value_state flag);
811 bool pdb_set_lanman_passwd(struct samu *sampass, const uint8_t pwd[LM_HASH_LEN], enum pdb_value_state flag);
812 bool pdb_set_pw_history(struct samu *sampass, const uint8_t *pwd, uint32_t historyLen, enum pdb_value_state flag);
813 bool pdb_set_plaintext_pw_only(struct samu *sampass, const char *password, enum pdb_value_state flag);
814 bool pdb_update_history(struct samu *sampass, const uint8_t new_nt[NT_HASH_LEN]);
815 bool pdb_set_bad_password_count(struct samu *sampass, uint16_t bad_password_count, enum pdb_value_state flag);
816 bool pdb_set_logon_count(struct samu *sampass, uint16_t logon_count, enum pdb_value_state flag);
817 bool pdb_set_country_code(struct samu *sampass, uint16_t country_code,
818 			  enum pdb_value_state flag);
819 bool pdb_set_code_page(struct samu *sampass, uint16_t code_page,
820 		       enum pdb_value_state flag);
821 bool pdb_set_unknown_6(struct samu *sampass, uint32_t unkn, enum pdb_value_state flag);
822 bool pdb_set_hours(struct samu *sampass, const uint8_t *hours, int hours_len,
823 		   enum pdb_value_state flag);
824 bool pdb_set_backend_private_data(struct samu *sampass, void *private_data,
825 				   void (*free_fn)(void **),
826 				   const struct pdb_methods *my_methods,
827 				   enum pdb_value_state flag);
828 bool pdb_set_pass_can_change(struct samu *sampass, bool canchange);
829 bool pdb_set_plaintext_passwd(struct samu *sampass, const char *plaintext);
830 uint32_t pdb_build_fields_present(struct samu *sampass);
831 bool pdb_element_is_changed(const struct samu *sampass,
832 			    enum pdb_elements element);
833 bool pdb_element_is_set_or_changed(const struct samu *sampass,
834 				   enum pdb_elements element);
835 
836 /* The following definitions come from passdb/pdb_interface.c  */
837 
838 NTSTATUS smb_register_passdb(int version, const char *name, pdb_init_function init) ;
839 struct pdb_init_function_entry *pdb_find_backend_entry(const char *name);
840 const struct pdb_init_function_entry *pdb_get_backends(void);
841 struct tevent_context *pdb_get_tevent_context(void);
842 NTSTATUS make_pdb_method_name(struct pdb_methods **methods, const char *selected);
843 struct pdb_domain_info *pdb_get_domain_info(TALLOC_CTX *mem_ctx);
844 bool pdb_getsampwnam(struct samu *sam_acct, const char *username) ;
845 bool pdb_getsampwsid(struct samu *sam_acct, const struct dom_sid *sid) ;
846 NTSTATUS pdb_create_user(TALLOC_CTX *mem_ctx, const char *name, uint32_t flags,
847 			 uint32_t *rid);
848 NTSTATUS pdb_delete_user(TALLOC_CTX *mem_ctx, struct samu *sam_acct);
849 NTSTATUS pdb_add_sam_account(struct samu *sam_acct) ;
850 NTSTATUS pdb_update_sam_account(struct samu *sam_acct) ;
851 NTSTATUS pdb_delete_sam_account(struct samu *sam_acct) ;
852 NTSTATUS pdb_rename_sam_account(struct samu *oldname, const char *newname);
853 NTSTATUS pdb_update_login_attempts(struct samu *sam_acct, bool success);
854 bool pdb_getgrsid(GROUP_MAP *map, struct dom_sid sid);
855 bool pdb_getgrgid(GROUP_MAP *map, gid_t gid);
856 bool pdb_getgrnam(GROUP_MAP *map, const char *name);
857 NTSTATUS pdb_create_dom_group(TALLOC_CTX *mem_ctx, const char *name,
858 			      uint32_t *rid);
859 NTSTATUS pdb_delete_dom_group(TALLOC_CTX *mem_ctx, uint32_t rid);
860 NTSTATUS pdb_add_group_mapping_entry(GROUP_MAP *map);
861 NTSTATUS pdb_update_group_mapping_entry(GROUP_MAP *map);
862 NTSTATUS pdb_delete_group_mapping_entry(struct dom_sid sid);
863 bool pdb_enum_group_mapping(const struct dom_sid *sid,
864 			    enum lsa_SidType sid_name_use,
865 			    GROUP_MAP ***pp_rmap,
866 			    size_t *p_num_entries,
867 			    bool unix_only);
868 NTSTATUS pdb_enum_group_members(TALLOC_CTX *mem_ctx,
869 				const struct dom_sid *sid,
870 				uint32_t **pp_member_rids,
871 				size_t *p_num_members);
872 NTSTATUS pdb_enum_group_memberships(TALLOC_CTX *mem_ctx, struct samu *user,
873 				    struct dom_sid **pp_sids, gid_t **pp_gids,
874 				    uint32_t *p_num_groups);
875 NTSTATUS pdb_set_unix_primary_group(TALLOC_CTX *mem_ctx, struct samu *user);
876 NTSTATUS pdb_add_groupmem(TALLOC_CTX *mem_ctx, uint32_t group_rid,
877 			  uint32_t member_rid);
878 NTSTATUS pdb_del_groupmem(TALLOC_CTX *mem_ctx, uint32_t group_rid,
879 			  uint32_t member_rid);
880 NTSTATUS pdb_create_alias(const char *name, uint32_t *rid);
881 NTSTATUS pdb_delete_alias(const struct dom_sid *sid);
882 NTSTATUS pdb_get_aliasinfo(const struct dom_sid *sid, struct acct_info *info);
883 NTSTATUS pdb_set_aliasinfo(const struct dom_sid *sid, struct acct_info *info);
884 NTSTATUS pdb_add_aliasmem(const struct dom_sid *alias, const struct dom_sid *member);
885 NTSTATUS pdb_del_aliasmem(const struct dom_sid *alias, const struct dom_sid *member);
886 NTSTATUS pdb_enum_aliasmem(const struct dom_sid *alias, TALLOC_CTX *mem_ctx,
887 			   struct dom_sid **pp_members, size_t *p_num_members);
888 NTSTATUS pdb_enum_alias_memberships(TALLOC_CTX *mem_ctx,
889 				    const struct dom_sid *domain_sid,
890 				    const struct dom_sid *members, size_t num_members,
891 				    uint32_t **pp_alias_rids,
892 				    size_t *p_num_alias_rids);
893 NTSTATUS pdb_lookup_rids(const struct dom_sid *domain_sid,
894 			 int num_rids,
895 			 uint32_t *rids,
896 			 const char **names,
897 			 enum lsa_SidType *attrs);
898 bool pdb_get_account_policy(enum pdb_policy_type type, uint32_t *value);
899 bool pdb_set_account_policy(enum pdb_policy_type type, uint32_t value);
900 bool pdb_get_seq_num(time_t *seq_num);
901 /*
902  * Instead of passing down a gid or uid, this function sends down a pointer
903  * to a unixid.
904  *
905  * This acts as an in-out variable so that the idmap functions can correctly
906  * receive ID_TYPE_BOTH, filling in cache details correctly rather than forcing
907  * the cache to store ID_TYPE_UID or ID_TYPE_GID.
908  */
909 bool pdb_id_to_sid(struct unixid *id, struct dom_sid *sid);
910 bool pdb_sid_to_id(const struct dom_sid *sid, struct unixid *id);
911 uint32_t pdb_capabilities(void);
912 bool pdb_new_rid(uint32_t *rid);
913 bool initialize_password_db(bool reload, struct tevent_context *tevent_ctx);
914 struct pdb_search *pdb_search_init(TALLOC_CTX *mem_ctx,
915 				   enum pdb_search_type type);
916 struct pdb_search *pdb_search_users(TALLOC_CTX *mem_ctx, uint32_t acct_flags);
917 struct pdb_search *pdb_search_groups(TALLOC_CTX *mem_ctx);
918 struct pdb_search *pdb_search_aliases(TALLOC_CTX *mem_ctx, const struct dom_sid *sid);
919 uint32_t pdb_search_entries(struct pdb_search *search,
920 			  uint32_t start_idx, uint32_t max_entries,
921 			  struct samr_displayentry **result);
922 bool pdb_get_trusteddom_pw(const char *domain, char** pwd, struct dom_sid *sid,
923 			   time_t *pass_last_set_time);
924 NTSTATUS pdb_get_trusteddom_creds(const char *domain, TALLOC_CTX *mem_ctx,
925 				  struct cli_credentials **creds);
926 bool pdb_set_trusteddom_pw(const char* domain, const char* pwd,
927 			   const struct dom_sid *sid);
928 bool pdb_del_trusteddom_pw(const char *domain);
929 NTSTATUS pdb_enum_trusteddoms(TALLOC_CTX *mem_ctx, uint32_t *num_domains,
930 			      struct trustdom_info ***domains);
931 NTSTATUS pdb_get_trusted_domain(TALLOC_CTX *mem_ctx, const char *domain,
932 				struct pdb_trusted_domain **td);
933 NTSTATUS pdb_get_trusted_domain_by_sid(TALLOC_CTX *mem_ctx, struct dom_sid *sid,
934 				struct pdb_trusted_domain **td);
935 NTSTATUS pdb_set_trusted_domain(const char* domain,
936 				const struct pdb_trusted_domain *td);
937 NTSTATUS pdb_del_trusted_domain(const char *domain);
938 NTSTATUS pdb_enum_trusted_domains(TALLOC_CTX *mem_ctx, uint32_t *num_domains,
939 				  struct pdb_trusted_domain ***domains);
940 NTSTATUS make_pdb_method( struct pdb_methods **methods ) ;
941 NTSTATUS pdb_get_secret(TALLOC_CTX *mem_ctx,
942 			const char *secret_name,
943 			DATA_BLOB *secret_current,
944 			NTTIME *secret_current_lastchange,
945 			DATA_BLOB *secret_old,
946 			NTTIME *secret_old_lastchange,
947 			struct security_descriptor **sd);
948 NTSTATUS pdb_set_secret(const char *secret_name,
949 			DATA_BLOB *secret_current,
950 			DATA_BLOB *secret_old,
951 			struct security_descriptor *sd);
952 NTSTATUS pdb_delete_secret(const char *secret_name);
953 bool pdb_sid_to_id_unix_users_and_groups(const struct dom_sid *sid,
954 					 struct unixid *id);
955 
956 NTSTATUS pdb_enum_upn_suffixes(TALLOC_CTX *mem_ctx,
957 			       uint32_t *num_suffixes,
958 			       char ***suffixes);
959 
960 NTSTATUS pdb_set_upn_suffixes(uint32_t num_suffixes,
961 			      const char **suffixes);
962 bool pdb_is_responsible_for_our_sam(void);
963 bool pdb_is_responsible_for_builtin(void);
964 bool pdb_is_responsible_for_wellknown(void);
965 bool pdb_is_responsible_for_unix_users(void);
966 bool pdb_is_responsible_for_unix_groups(void);
967 bool pdb_is_responsible_for_everything_else(void);
968 
969 /* The following definitions come from passdb/pdb_util.c  */
970 
971 NTSTATUS pdb_create_builtin(uint32_t rid);
972 NTSTATUS create_builtin_users(const struct dom_sid *sid);
973 NTSTATUS create_builtin_administrators(const struct dom_sid *sid);
974 NTSTATUS create_builtin_guests(const struct dom_sid *dom_sid);
975 
976 #include "passdb/machine_sid.h"
977 #include "passdb/lookup_sid.h"
978 
979 /* The following definitions come from passdb/pdb_secrets.c
980  * and should be used by PDB modules if they need to store
981  * sid/guid information for the domain in secrets database
982  */
983 bool PDB_secrets_mark_domain_protected(const char *domain);
984 bool PDB_secrets_clear_domain_protection(const char *domain);
985 bool PDB_secrets_store_domain_sid(const char *domain, const struct dom_sid  *sid);
986 bool PDB_secrets_fetch_domain_sid(const char *domain, struct dom_sid  *sid);
987 bool PDB_secrets_store_domain_guid(const char *domain, struct GUID *guid);
988 bool PDB_secrets_fetch_domain_guid(const char *domain, struct GUID *guid);
989 
990 #endif /* _PASSDB_H */
991