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
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 2 of the License, or
12 (at your option) any later version.
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.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 * bit flags representing initialized fields in SAM_ACCOUNT
65 /* this must be the last element */
69 enum pdb_group_elements {
72 PDB_GROUP_SID_NAME_USE,
75 /* this must be the last element */
80 enum pdb_value_state {
86 #define IS_SAM_SET(x, flag) (pdb_get_init_flags(x, flag) == PDB_SET)
87 #define IS_SAM_CHANGED(x, flag) (pdb_get_init_flags(x, flag) == PDB_CHANGED)
88 #define IS_SAM_DEFAULT(x, flag) (pdb_get_init_flags(x, flag) == PDB_DEFAULT)
90 typedef struct sam_passwd
94 void (*free_fn)(struct sam_passwd **);
96 struct pdb_methods *methods;
99 /* initiailization flags */
100 struct bitmap *change_flags;
101 struct bitmap *set_flags;
103 time_t logon_time; /* logon time */
104 time_t logoff_time; /* logoff time */
105 time_t kickoff_time; /* kickoff time */
106 time_t pass_last_set_time; /* password last set time */
107 time_t pass_can_change_time; /* password can change time */
108 time_t pass_must_change_time; /* password must change time */
110 const char * username; /* UNIX username string */
111 const char * domain; /* Windows Domain name */
112 const char * nt_username; /* Windows username string */
113 const char * full_name; /* user's full name string */
114 const char * unix_home_dir; /* UNIX home directory string */
115 const char * home_dir; /* home directory string */
116 const char * dir_drive; /* home directory drive string */
117 const char * logon_script; /* logon script string */
118 const char * profile_path; /* profile path string */
119 const char * acct_desc ; /* user description string */
120 const char * workstations; /* login from workstations string */
121 const char * unknown_str ; /* don't know what this is, yet. */
122 const char * munged_dial ; /* munged path name and dial-back tel number */
124 DOM_SID user_sid; /* Primary User SID */
125 DOM_SID group_sid; /* Primary Group SID */
127 DATA_BLOB lm_pw; /* .data is Null if no password */
128 DATA_BLOB nt_pw; /* .data is Null if no password */
129 char* plaintext_pw; /* is Null if not available */
131 uint16 acct_ctrl; /* account info (ACB_xxxx bit-mask) */
132 uint32 unknown_3; /* 0x00ff ffff */
134 uint16 logon_divs; /* 168 - number of hours in a week */
135 uint32 hours_len; /* normally 21 bytes */
136 uint8 hours[MAX_HOURS_LEN];
138 uint32 unknown_5; /* 0x0002 0000 */
139 uint32 unknown_6; /* 0x0000 04ec */
142 /* Lets see if the remaining code can get the hint that you
143 are meant to use the pdb_...() functions. */
147 typedef struct sam_group {
150 void (*free_fn)(struct sam_group **);
152 struct pdb_methods *methods;
155 /* initiailization flags */
156 struct bitmap *change_flags;
157 struct bitmap *set_flags;
159 const char *name; /* Windows group name string */
161 DOM_SID sid; /* Group SID */
162 enum SID_NAME_USE sid_name_use; /* Group type */
164 uint32 mem_num; /* Number of member SIDs */
165 DOM_SID *members; /* SID array */
171 /*****************************************************************
172 Functions to be implemented by the new (v2) passdb API
173 ****************************************************************/
176 * This next constant specifies the version number of the PASSDB interface
177 * this SAMBA will load. Increment this if *ANY* changes are made to the interface.
180 #define PASSDB_INTERFACE_VERSION 4
182 typedef struct pdb_context
184 struct pdb_methods *pdb_methods;
185 struct pdb_methods *pwent_methods;
187 /* These functions are wrappers for the functions listed above.
188 They may do extra things like re-reading a SAM_ACCOUNT on update */
190 NTSTATUS (*pdb_setsampwent)(struct pdb_context *, BOOL update);
192 void (*pdb_endsampwent)(struct pdb_context *);
194 NTSTATUS (*pdb_getsampwent)(struct pdb_context *, SAM_ACCOUNT *user);
196 NTSTATUS (*pdb_getsampwnam)(struct pdb_context *, SAM_ACCOUNT *sam_acct, const char *username);
198 NTSTATUS (*pdb_getsampwsid)(struct pdb_context *, SAM_ACCOUNT *sam_acct, const DOM_SID *sid);
200 NTSTATUS (*pdb_add_sam_account)(struct pdb_context *, SAM_ACCOUNT *sampass);
202 NTSTATUS (*pdb_update_sam_account)(struct pdb_context *, SAM_ACCOUNT *sampass);
204 NTSTATUS (*pdb_delete_sam_account)(struct pdb_context *, SAM_ACCOUNT *username);
206 NTSTATUS (*pdb_getgrsid)(struct pdb_context *context, GROUP_MAP *map,
207 DOM_SID sid, BOOL with_priv);
209 NTSTATUS (*pdb_getgrgid)(struct pdb_context *context, GROUP_MAP *map,
210 gid_t gid, BOOL with_priv);
212 NTSTATUS (*pdb_getgrnam)(struct pdb_context *context, GROUP_MAP *map,
213 char *name, BOOL with_priv);
215 NTSTATUS (*pdb_add_group_mapping_entry)(struct pdb_context *context,
218 NTSTATUS (*pdb_update_group_mapping_entry)(struct pdb_context *context,
221 NTSTATUS (*pdb_delete_group_mapping_entry)(struct pdb_context *context,
224 NTSTATUS (*pdb_enum_group_mapping)(struct pdb_context *context,
225 enum SID_NAME_USE sid_name_use,
226 GROUP_MAP **rmap, int *num_entries,
227 BOOL unix_only, BOOL with_priv);
229 void (*free_fn)(struct pdb_context **);
235 typedef struct pdb_methods
237 const char *name; /* What name got this module */
238 struct pdb_context *parent;
240 /* Use macros from dlinklist.h on these two */
241 struct pdb_methods *next;
242 struct pdb_methods *prev;
244 NTSTATUS (*setsampwent)(struct pdb_methods *, BOOL update);
246 void (*endsampwent)(struct pdb_methods *);
248 NTSTATUS (*getsampwent)(struct pdb_methods *, SAM_ACCOUNT *user);
250 NTSTATUS (*getsampwnam)(struct pdb_methods *, SAM_ACCOUNT *sam_acct, const char *username);
252 NTSTATUS (*getsampwsid)(struct pdb_methods *, SAM_ACCOUNT *sam_acct, const DOM_SID *sid);
254 NTSTATUS (*add_sam_account)(struct pdb_methods *, SAM_ACCOUNT *sampass);
256 NTSTATUS (*update_sam_account)(struct pdb_methods *, SAM_ACCOUNT *sampass);
258 NTSTATUS (*delete_sam_account)(struct pdb_methods *, SAM_ACCOUNT *username);
260 NTSTATUS (*getgrsid)(struct pdb_methods *methods, GROUP_MAP *map,
261 DOM_SID sid, BOOL with_priv);
263 NTSTATUS (*getgrgid)(struct pdb_methods *methods, GROUP_MAP *map,
264 gid_t gid, BOOL with_priv);
266 NTSTATUS (*getgrnam)(struct pdb_methods *methods, GROUP_MAP *map,
267 char *name, BOOL with_priv);
269 NTSTATUS (*add_group_mapping_entry)(struct pdb_methods *methods,
272 NTSTATUS (*update_group_mapping_entry)(struct pdb_methods *methods,
275 NTSTATUS (*delete_group_mapping_entry)(struct pdb_methods *methods,
278 NTSTATUS (*enum_group_mapping)(struct pdb_methods *methods,
279 enum SID_NAME_USE sid_name_use,
280 GROUP_MAP **rmap, int *num_entries,
281 BOOL unix_only, BOOL with_priv);
283 void *private_data; /* Private data of some kind */
285 void (*free_private_data)(void **);
289 typedef NTSTATUS (*pdb_init_function)(struct pdb_context *,
290 struct pdb_methods **,
293 struct pdb_init_function_entry {
295 /* Function to create a member of the pdb_methods list */
296 pdb_init_function init;
297 struct pdb_init_function_entry *prev, *next;
300 #endif /* _PASSDB_H */