Move some libgpo files to root.
[sfrench/samba-autobuild/.git] / libgpo / gpo.h
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  Group Policy Object Support
4  *  Copyright (C) Guenther Deschner 2005-2008
5  *
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 3 of the License, or
9  *  (at your option) any later version.
10  *
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.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
18  */
19
20 #ifndef __GPO_H__
21 #define __GPO_H__
22
23 enum GPO_LINK_TYPE {
24         GP_LINK_UNKOWN  = 0,
25         GP_LINK_MACHINE = 1,
26         GP_LINK_SITE    = 2,
27         GP_LINK_DOMAIN  = 3,
28         GP_LINK_OU      = 4,
29         GP_LINK_LOCAL   = 5 /* for convenience */
30 };
31
32 /* GPO_OPTIONS */
33 #define GPO_FLAG_DISABLE        0x00000001
34 #define GPO_FLAG_FORCE          0x00000002
35
36 /* GPO_LIST_FLAGS */
37 #define GPO_LIST_FLAG_MACHINE   0x00000001
38 #define GPO_LIST_FLAG_SITEONLY  0x00000002
39
40 /* following flags from http://support.microsoft.com/kb/312164/EN-US/ */
41 #define GPO_INFO_FLAG_MACHINE                   0x00000001
42 #define GPO_INFO_FLAG_BACKGROUND                0x00000010
43 #define GPO_INFO_FLAG_SLOWLINK                  0x00000020
44 #define GPO_INFO_FLAG_VERBOSE                   0x00000040
45 #define GPO_INFO_FLAG_NOCHANGES                 0x00000080
46 #define GPO_INFO_FLAG_LINKTRANSITION            0x00000100
47 #define GPO_INFO_FLAG_LOGRSOP_TRANSITION        0x00000200
48 #define GPO_INFO_FLAG_FORCED_REFRESH            0x00000400
49 #define GPO_INFO_FLAG_SAFEMODE_BOOT             0x00000800
50
51 #define GPO_VERSION_USER(x) (x >> 16)
52 #define GPO_VERSION_MACHINE(x) (x & 0xffff)
53
54 struct GROUP_POLICY_OBJECT {
55         uint32_t options;       /* GPFLAGS_* */
56         uint32_t version;
57         const char *ds_path;
58         const char *file_sys_path;
59         const char *display_name;
60         const char *name;
61         const char *link;
62         enum GPO_LINK_TYPE link_type;
63         const char *user_extensions;
64         const char *machine_extensions;
65         struct security_descriptor *security_descriptor;
66         struct GROUP_POLICY_OBJECT *next, *prev;
67 };
68
69 /* the following is seen on the DS (see adssearch.pl for details) */
70
71 /* the type field in a 'gPLink', the same as GPO_FLAG ? */
72 #define GPO_LINK_OPT_NONE       0x00000000
73 #define GPO_LINK_OPT_DISABLED   0x00000001
74 #define GPO_LINK_OPT_ENFORCED   0x00000002
75
76 /* GPO_LINK_OPT_ENFORCED takes precedence over GPOPTIONS_BLOCK_INHERITANCE */
77
78 /* 'gPOptions', maybe a bitmask as well */
79 enum GPO_INHERIT {
80         GPOPTIONS_INHERIT               = 0,
81         GPOPTIONS_BLOCK_INHERITANCE     = 1
82 };
83
84 /* 'flags' in a 'groupPolicyContainer' object */
85 #define GPFLAGS_ALL_ENABLED                     0x00000000
86 #define GPFLAGS_USER_SETTINGS_DISABLED          0x00000001
87 #define GPFLAGS_MACHINE_SETTINGS_DISABLED       0x00000002
88 #define GPFLAGS_ALL_DISABLED (GPFLAGS_USER_SETTINGS_DISABLED | \
89                               GPFLAGS_MACHINE_SETTINGS_DISABLED)
90
91 struct GP_LINK {
92         const char *gp_link;    /* raw link name */
93         uint32_t gp_opts;               /* inheritance options GPO_INHERIT */
94         uint32_t num_links;     /* number of links */
95         char **link_names;      /* array of parsed link names */
96         uint32_t *link_opts;    /* array of parsed link opts GPO_LINK_OPT_* */
97 };
98
99 struct GP_EXT {
100         const char *gp_extension;       /* raw extension name */
101         uint32_t num_exts;
102         char **extensions;
103         char **extensions_guid;
104         char **snapins;
105         char **snapins_guid;
106         struct GP_EXT *next, *prev;
107 };
108
109 #define GPO_CACHE_DIR "gpo_cache"
110 #define GPT_INI "GPT.INI"
111 #define GPO_REFRESH_INTERVAL 60*90
112
113 #define GPO_REG_STATE_MACHINE "State\\Machine"
114
115 enum gp_reg_action {
116         GP_REG_ACTION_NONE = 0,
117         GP_REG_ACTION_ADD_VALUE = 1,
118         GP_REG_ACTION_ADD_KEY = 2,
119         GP_REG_ACTION_DEL_VALUES = 3,
120         GP_REG_ACTION_DEL_VALUE = 4,
121         GP_REG_ACTION_DEL_ALL_VALUES = 5,
122         GP_REG_ACTION_DEL_KEYS = 6,
123         GP_REG_ACTION_SEC_KEY_SET = 7,
124         GP_REG_ACTION_SEC_KEY_RESET = 8
125 };
126
127 struct gp_registry_entry {
128         enum gp_reg_action action;
129         const char *key;
130         const char *value;
131         struct registry_value *data;
132 };
133
134 struct gp_registry_value {
135         const char *value;
136         struct registry_value *data;
137 };
138
139 struct gp_registry_entry2 {
140         enum gp_reg_action action;
141         const char *key;
142         size_t num_values;
143         struct gp_registry_value **values;
144 };
145
146 struct gp_registry_entries {
147         size_t num_entries;
148         struct gp_registry_entry **entries;
149 };
150
151 struct gp_registry_context {
152         const struct nt_user_token *token;
153         const char *path;
154         struct registry_key *curr_key;
155 };
156
157 #define GP_EXT_GUID_SECURITY "827D319E-6EAC-11D2-A4EA-00C04F79F83A"
158 #define GP_EXT_GUID_REGISTRY "35378EAC-683F-11D2-A89A-00C04FBBCFA2"
159 #define GP_EXT_GUID_SCRIPTS  "42B5FAAE-6536-11D2-AE5A-0000F87571E3"
160
161 #include "../libgpo/gpext/gpext.h"
162
163 #endif