2 Unix SMB/CIFS implementation.
4 Copyright (C) Simo Sorce 2002
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #define GUMS_VERSION_MAJOR 0
25 #define GUMS_VERSION_MINOR 1
26 #define GUMS_OBJECT_VERSION 1
27 #define GUMS_PRIVILEGE_VERSION 1
28 #define GUMS_INTERFACE_VERSION 1
30 #define GUMS_OBJ_DOMAIN 0x10
31 #define GUMS_OBJ_NORMAL_USER 0x20
32 #define GUMS_OBJ_GROUP 0x30
33 #define GUMS_OBJ_ALIAS 0x31
35 /* define value types */
36 #define GUMS_SET_PRIMARY_GROUP 0x1
37 #define GUMS_SET_SEC_DESC 0x2
39 #define GUMS_SET_NAME 0x10
40 #define GUMS_SET_DESCRIPTION 0x11
41 #define GUMS_SET_FULL_NAME 0x12
43 /* user specific type values */
44 #define GUMS_SET_LOGON_TIME 0x20
45 #define GUMS_SET_LOGOFF_TIME 0x21
46 #define GUMS_SET_KICKOFF_TIME 0x23
47 #define GUMS_SET_PASS_LAST_SET_TIME 0x24
48 #define GUMS_SET_PASS_CAN_CHANGE_TIME 0x25
49 #define GUMS_SET_PASS_MUST_CHANGE_TIME 0x26
52 #define GUMS_SET_HOME_DIRECTORY 0x31
53 #define GUMS_SET_DRIVE 0x32
54 #define GUMS_SET_LOGON_SCRIPT 0x33
55 #define GUMS_SET_PROFILE_PATH 0x34
56 #define GUMS_SET_WORKSTATIONS 0x35
57 #define GUMS_SET_UNKNOWN_STRING 0x36
58 #define GUMS_SET_MUNGED_DIAL 0x37
60 #define GUMS_SET_LM_PASSWORD 0x40
61 #define GUMS_SET_NT_PASSWORD 0x41
62 #define GUMS_SET_PLAINTEXT_PASSWORD 0x42
63 #define GUMS_SET_UNKNOWN_3 0x43
64 #define GUMS_SET_LOGON_DIVS 0x44
65 #define GUMS_SET_HOURS_LEN 0x45
66 #define GUMS_SET_HOURS 0x46
67 #define GUMS_SET_BAD_PASSWORD_COUNT 0x47
68 #define GUMS_SET_LOGON_COUNT 0x48
69 #define GUMS_SET_UNKNOWN_6 0x49
71 #define GUMS_SET_MUST_CHANGE_PASS 0x50
72 #define GUMS_SET_CANNOT_CHANGE_PASS 0x51
73 #define GUMS_SET_PASS_NEVER_EXPIRE 0x52
74 #define GUMS_SET_ACCOUNT_DISABLED 0x53
75 #define GUMS_SET_ACCOUNT_LOCKOUT 0x54
77 /*group specific type values */
78 #define GUMS_ADD_SID_LIST 0x60
79 #define GUMS_DEL_SID_LIST 0x61
80 #define GUMS_SET_SID_LIST 0x62
82 GENSTRUCT
struct gums_user
84 DOM_SID
*group_sid
; /* Primary Group SID */
86 NTTIME logon_time
; /* logon time */
87 NTTIME logoff_time
; /* logoff time */
88 NTTIME kickoff_time
; /* kickoff time */
89 NTTIME pass_last_set_time
; /* password last set time */
90 NTTIME pass_can_change_time
; /* password can change time */
91 NTTIME pass_must_change_time
; /* password must change time */
93 char *full_name
; _NULLTERM
/* user's full name string */
94 char *home_dir
; _NULLTERM
/* home directory string */
95 char *dir_drive
; _NULLTERM
/* home directory drive string */
96 char *logon_script
; _NULLTERM
/* logon script string */
97 char *profile_path
; _NULLTERM
/* profile path string */
98 char *workstations
; _NULLTERM
/* login from workstations string */
99 char *unknown_str
; _NULLTERM
/* don't know what this is, yet. */
100 char *munged_dial
; _NULLTERM
/* munged path name and dial-back tel number */
102 DATA_BLOB lm_pw
; /* .data is Null if no password */
103 DATA_BLOB nt_pw
; /* .data is Null if no password */
105 uint16 acct_ctrl
; /* account type & status flags */
106 uint16 logon_divs
; /* 168 - number of hours in a week */
107 uint32 hours_len
; /* normally 21 bytes */
108 uint8
*hours
; _LEN(hours_len
) /* normally 21 bytes (depends on hours_len) */
110 uint16 bad_password_count
; /* 0 */
111 uint16 logon_count
; /* 0 */
112 uint32 unknown_3
; /* 0x00ff ffff */
113 uint32 unknown_6
; /* 0x0000 04ec */
117 GENSTRUCT
struct gums_group
119 uint32 count
; /* Number of SIDs */
120 DOM_SID
*members
; _LEN(count
) /* SID array */
124 GENSTRUCT
struct gums_domain
130 GENSTRUCT
struct gums_object
134 uint32 type
; /* Object Type */
135 uint32 version
; /* Object Version */
136 uint32 seq_num
; /* Object Sequence Number */
138 SEC_DESC
*sec_desc
; /* Security Descriptor */
140 DOM_SID
*sid
; /* Object Sid */
141 char *name
; _NULLTERM
/* Object Name - it should be in DOMAIN\NAME format */
142 char *description
; _NULLTERM
/* Object Description */
144 struct gums_user
*user
;
145 struct gums_group
*group
;
146 struct gums_domain
*domain
;
150 GENSTRUCT
struct gums_privilege
154 uint32 version
; /* Object Version */
155 uint32 seq_num
; /* Object Sequence Number */
157 char *name
; _NULLTERM
/* Object Name */
158 char *description
; _NULLTERM
/* Object Description */
160 LUID_ATTR
*privilege
; /* Privilege Type */
163 DOM_SID
*members
; _LEN(count
)
167 typedef struct gums_user GUMS_USER
;
168 typedef struct gums_group GUMS_GROUP
;
169 typedef struct gums_domain GUMS_DOMAIN
;
170 typedef struct gums_object GUMS_OBJECT
;
171 typedef struct gums_privilege GUMS_PRIVILEGE
;
173 typedef struct gums_data_set
175 int type
; /* GUMS_SET_xxx */
180 typedef struct gums_commit_set
184 uint32 type
; /* Object type */
185 DOM_SID sid
; /* Object Sid */
186 uint32 count
; /* number of changes */
191 typedef struct gums_priv_commit_set
195 uint32 type
; /* Object type */
196 char *name
; /* Object Sid */
197 uint32 count
; /* number of changes */
200 } GUMS_PRIV_COMMIT_SET
;
203 typedef struct gums_functions
209 void (*free_private_data
)(void **);
211 /* Generic object functions */
213 NTSTATUS (*get_domain_sid
) (DOM_SID
*sid
, const char* name
);
214 NTSTATUS (*set_domain_sid
) (const DOM_SID
*sid
);
216 NTSTATUS (*get_sequence_number
) (void);
218 NTSTATUS (*new_object
) (DOM_SID
*sid
, const char *name
, const int obj_type
);
219 NTSTATUS (*delete_object
) (const DOM_SID
*sid
);
221 NTSTATUS (*get_object_from_sid
) (GUMS_OBJECT
**object
, const DOM_SID
*sid
, const int obj_type
);
222 NTSTATUS (*get_object_from_name
) (GUMS_OBJECT
**object
, const char *domain
, const char *name
, const int obj_type
);
223 /* This function is used to get the list of all objects changed since b_time, it is
224 used to support PDC<->BDC synchronization */
225 NTSTATUS (*get_updated_objects
) (GUMS_OBJECT
**objects
, const NTTIME base_time
);
227 NTSTATUS (*enumerate_objects_start
) (void **handle
, const DOM_SID
*sid
, const int obj_type
);
228 NTSTATUS (*enumerate_objects_get_next
) (GUMS_OBJECT
**object
, void *handle
);
229 NTSTATUS (*enumerate_objects_stop
) (void *handle
);
231 /* This function MUST be used ONLY by PDC<->BDC replication code or recovery tools.
232 Never use this function to update an object in the database, use set_object_values() */
233 NTSTATUS (*set_object
) (GUMS_OBJECT
*object
);
235 /* set object values function */
236 NTSTATUS (*set_object_values
) (DOM_SID
*sid
, uint32 count
, GUMS_DATA_SET
*data_set
);
238 /* Group related functions */
239 NTSTATUS (*add_members_to_group
) (const DOM_SID
*group
, const DOM_SID
**members
);
240 NTSTATUS (*delete_members_from_group
) (const DOM_SID
*group
, const DOM_SID
**members
);
241 NTSTATUS (*enumerate_group_members
) (DOM_SID
**members
, const DOM_SID
*sid
, const int type
);
243 NTSTATUS (*get_sid_groups
) (DOM_SID
**groups
, const DOM_SID
*sid
);
245 NTSTATUS (*lock_sid
) (const DOM_SID
*sid
);
246 NTSTATUS (*unlock_sid
) (const DOM_SID
*sid
);
248 /* privileges related functions */
250 NTSTATUS (*get_privilege
) (GUMS_OBJECT
**object
, const char *name
);
251 NTSTATUS (*add_members_to_privilege
) (const char *name
, const DOM_SID
**members
);
252 NTSTATUS (*delete_members_from_privilege
) (const char *name
, const DOM_SID
**members
);
253 NTSTATUS (*enumerate_privilege_members
) (const char *name
, DOM_SID
**members
);
254 NTSTATUS (*get_sid_privileges
) (const DOM_SID
*sid
, const char **privs
);
256 /* warning!: set_privilege will overwrite a prior existing privilege if such exist */
257 NTSTATUS (*set_privilege
) (GUMS_PRIVILEGE
*priv
);
261 typedef NTSTATUS (*gums_init_function
)(
262 struct gums_functions
*,
265 struct gums_init_function_entry
{
268 gums_init_function init_fn
;
269 struct gums_init_function_entry
*prev
, *next
;