summaryrefslogtreecommitdiff
path: root/source4/include/gums.h
blob: ca124d74423062b7bda0977fff6a5c81e986a9cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/* 
   Unix SMB/CIFS implementation.
   GUMS structures
   Copyright (C) Simo Sorce 2002
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.
   
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef _GUMS_H
#define _GUMS_H

#define GUMS_VERSION_MAJOR 0
#define GUMS_VERSION_MINOR 1
#define GUMS_OBJECT_VERSION	1

#define GUMS_OBJ_DOMAIN			1
#define GUMS_OBJ_NORMAL_USER		2
#define GUMS_OBJ_GROUP			3
#define GUMS_OBJ_ALIAS			4
#define GUMS_OBJ_WORKSTATION_TRUST	5
#define GUMS_OBJ_SERVER_TRUST		6
#define GUMS_OBJ_DOMAIN_TRUST		7

typedef struct gums_user
{
	DOM_SID *group_sid;		/* Primary Group SID */

	NTTIME logon_time;		/* logon time */
	NTTIME logoff_time;		/* logoff time */
	NTTIME kickoff_time;		/* kickoff time */
	NTTIME pass_last_set_time;	/* password last set time */
	NTTIME pass_can_change_time;	/* password can change time */
	NTTIME pass_must_change_time;	/* password must change time */

	char *full_name;		/* user's full name string */
	char *home_dir;			/* home directory string */
	char *dir_drive;		/* home directory drive string */
	char *logon_script;		/* logon script string */
	char *profile_path;		/* profile path string */
	char *workstations;		/* login from workstations string */
	char *unknown_str;		/* don't know what this is, yet. */
	char *munged_dial;		/* munged path name and dial-back tel number */
		
	DATA_BLOB lm_pw; 		/* .data is Null if no password */
	DATA_BLOB nt_pw; 		/* .data is Null if no password */
		
	uint32 unknown_3;		/* 0x00ff ffff */
		
	uint16 logon_divs;		/* 168 - number of hours in a week */
	uint32 hours_len;		/* normally 21 bytes */
	uint8 *hours;
		
	uint32 unknown_5;		/* 0x0002 0000 */
	uint32 unknown_6;		/* 0x0000 04ec */

} GUMS_USER;

typedef struct gums_group
{
	uint32 count;			/* Number of SIDs */
	DOM_SID **members;		/* SID array */

} GUMS_GROUP;

union gums_obj_p {
	gums_user *user;
	gums_group *group;
}

typedef struct gums_object
{
	TALLOC_CTX *mem_ctx;

	uint32 type;			/* Object Type */
	uint32 version;			/* Object Version */
	uint32 seq_num;			/* Object Sequence Number */

	SEC_DESC *sec_desc;		/* Security Descriptor */

	DOM_SID *sid;			/* Object Sid */
	char *name;			/* Object Name */
	char *description;		/* Object Description */

	union gums_obj_p data;		/* Object Specific data */

} GUMS_OBJECT;

typedef struct gums_data_set
{
	int type; /* GUMS_SET_xxx */
	void *data;

} GUMS_DATA_SET;

typedef struct gums_commit_set
{
	TALLOC_CTX *mem_ctx;

	uint32 type;			/* Object type */
	DOM_SID sid;			/* Object Sid */
	uint32 count;			/* number of changes */
	GUMS_DATA_SET **data;
} GUMS_COMMIT_SET;

typedef struct gums_privilege
{
	TALLOC_CTX *mem_ctx;

	uint32 type;			/* Object Type */
	uint32 version;			/* Object Version */
	uint32 seq_num;			/* Object Sequence Number */

	LUID_ATTR *privilege;		/* Privilege Type */
	char *name;			/* Object Name */
	char *description;		/* Object Description */

	uint32 count;
	DOM_SID **members;

} GUMS_PRIVILEGE;


typedef struct gums_functions
{
	/* Generic object functions */

	NTSTATUS (*get_domain_sid) (DOM_SID **sid, const char* name);
	NTSTATUS (*set_domain_sid) (const DOM_SID *sid);

	NTSTATUS (*get_sequence_number) (void);

	NTSTATUS (*new_object) (DOM_SID **sid, const char *name, const int obj_type);
	NTSTATUS (*delete_object) (const DOM_SID *sid);

	NTSTATUS (*get_object_from_sid) (GUMS_OBJECT **object, const DOM_SID *sid, const int obj_type);
	NTSTATUS (*get_sid_from_name) (GUMS_OBJECT **object, const char *name);
	/* This function is used to get the list of all objects changed since b_time, it is
	   used to support PDC<->BDC synchronization */
	NTSTATUS (*get_updated_objects) (GUMS_OBJECT **objects, const NTTIME base_time);

	NTSTATUS (*enumerate_objects_start) (void *handle, const DOM_SID *sid, const int obj_type);
	NTSTATUS (*enumerate_objects_get_next) (GUMS_OBJECT **object, void *handle);
	NTSTATUS (*enumerate_objects_stop) (void *handle);

	/* This function MUST be used ONLY by PDC<->BDC replication code or recovery tools.
	   Never use this function to update an object in the database, use set_object_values() */
	NTSTATUS (*set_object) (const GUMS_OBJECT *object);

	/* set object values function */
	NTSTATUS (*set_object_values) (DOM_SID *sid, uint32 count, GUMS_DATA_SET *data_set);

	/* Group related functions */
	NTSTATUS (*add_memberss_to_group) (const DOM_SID *group, const DOM_SID **members);
	NTSTATUS (*delete_members_from_group) (const DOM_SID *group, const DOM_SID **members);
	NTSTATUS (*enumerate_group_members) (DOM_SID **members, const DOM_SID *sid, const int type);

	NTSTATUS (*get_sid_groups) (DOM_SID **groups, const DOM_SID *sid);

	NTSTATUS (*lock_sid) (const DOM_SID *sid);
	NTSTATUS (*unlock_sid) (const DOM_SID *sid);

	/* privileges related functions */

	NTSTATUS (*add_members_to_privilege) (const LUID_ATTR *priv, const DOM_SID **members);
	NTSTATUS (*delete_members_from_privilege) (const LUID_ATTR *priv, const DOM_SID **members);
	NTSTATUS (*enumerate_privilege_members) (DOM_SID **members, const LUID_ATTR *priv);
	NTSTATUS (*get_sid_privileges) (DOM_SID **privs, const DOM_SID *sid);
	/* warning!: set_privilege will overwrite a prior existing privilege if such exist */
	NTSTATUS (*set_privilege) (GUMS_PRIVILEGE *priv);

} GUMS_FUNCTIONS;

/* define value types */

#define GUMS_SET_PRIMARY_GROUP		1
#define GUMS_SET_SEC_DESC		2

/* user specific type values */
#define GUMS_SET_LOGON_TIME		10  /* keep NTTIME consecutive */
#define GUMS_SET_LOGOFF_TIME		11 /* too ease checking */
#define GUMS_SET_KICKOFF_TIME		13
#define GUMS_SET_PASS_LAST_SET_TIME	14
#define GUMS_SET_PASS_CAN_CHANGE_TIME	15
#define GUMS_SET_PASS_MUST_CHANGE_TIME	16 /* NTTIME end */

#define GUMS_SET_NAME			20 /* keep strings consecutive */
#define GUMS_SET_DESCRIPTION		21 /* too ease checking */
#define GUMS_SET_FULL_NAME		22
#define GUMS_SET_HOME_DIRECTORY		23
#define GUMS_SET_DRIVE			24
#define GUMS_SET_LOGON_SCRIPT		25
#define GUMS_SET_PROFILE_PATH		26
#define GUMS_SET_WORKSTATIONS		27
#define GUMS_SET_UNKNOWN_STRING		28
#define GUMS_SET_MUNGED_DIAL		29 /* strings end */

#define GUMS_SET_LM_PASSWORD		40
#define GUMS_SET_NT_PASSWORD		41
#define GUMS_SET_PLAINTEXT_PASSWORD	42
#define GUMS_SET_UNKNOWN_3		43
#define GUMS_SET_LOGON_DIVS		44
#define GUMS_SET_HOURS_LEN		45
#define GUMS_SET_HOURS			46
#define GUMS_SET_UNKNOWN_5		47
#define GUMS_SET_UNKNOWN_6		48

#define GUMS_SET_MUST_CHANGE_PASS	50
#define GUMS_SET_CANNOT_CHANGE_PASS	51
#define GUMS_SET_PASS_NEVER_EXPIRE	52
#define GUMS_SET_ACCOUNT_DISABLED	53
#define GUMS_SET_ACCOUNT_LOCKOUT	54

/*group specific type values */
#define GUMS_ADD_SID_LIST		60
#define GUMS_DEL_SID_LIST		61
#define GUMS_SET_SID_LIST		62

#endif /* _GUMS_H */