s4-dns: dlz_bind9: Create dns-HOSTNAME account disabled
[Samba.git] / libgpo / gpo.h
blob62e9091156e28a07997f0860ff270a6e5fc8cf14
1 /*
2 * Unix SMB/CIFS implementation.
3 * Group Policy Object Support
4 * Copyright (C) Guenther Deschner 2005-2008
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.
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, see <http://www.gnu.org/licenses/>.
20 #ifndef __GPO_H__
21 #define __GPO_H__
23 struct loadparm_context;
24 #include "ads.h"
26 enum GPO_LINK_TYPE {
27 GP_LINK_UNKOWN = 0,
28 GP_LINK_MACHINE = 1,
29 GP_LINK_SITE = 2,
30 GP_LINK_DOMAIN = 3,
31 GP_LINK_OU = 4,
32 GP_LINK_LOCAL = 5 /* for convenience */
35 /* GPO_OPTIONS */
36 #define GPO_FLAG_DISABLE 0x00000001
37 #define GPO_FLAG_FORCE 0x00000002
39 /* GPO_LIST_FLAGS */
40 #define GPO_LIST_FLAG_MACHINE 0x00000001
41 #define GPO_LIST_FLAG_SITEONLY 0x00000002
43 /* following flags from http://support.microsoft.com/kb/312164/EN-US/ */
44 #define GPO_INFO_FLAG_MACHINE 0x00000001
45 #define GPO_INFO_FLAG_BACKGROUND 0x00000010
46 #define GPO_INFO_FLAG_SLOWLINK 0x00000020
47 #define GPO_INFO_FLAG_VERBOSE 0x00000040
48 #define GPO_INFO_FLAG_NOCHANGES 0x00000080
49 #define GPO_INFO_FLAG_LINKTRANSITION 0x00000100
50 #define GPO_INFO_FLAG_LOGRSOP_TRANSITION 0x00000200
51 #define GPO_INFO_FLAG_FORCED_REFRESH 0x00000400
52 #define GPO_INFO_FLAG_SAFEMODE_BOOT 0x00000800
54 #define GPO_VERSION_USER(x) (x >> 16)
55 #define GPO_VERSION_MACHINE(x) (x & 0xffff)
57 struct GROUP_POLICY_OBJECT {
58 uint32_t options; /* GPFLAGS_* */
59 uint32_t version;
60 const char *ds_path;
61 const char *file_sys_path;
62 const char *display_name;
63 const char *name;
64 const char *link;
65 enum GPO_LINK_TYPE link_type;
66 const char *user_extensions;
67 const char *machine_extensions;
68 struct security_descriptor *security_descriptor;
69 struct GROUP_POLICY_OBJECT *next, *prev;
72 /* the following is seen on the DS (see adssearch.pl for details) */
74 /* the type field in a 'gPLink', the same as GPO_FLAG ? */
75 #define GPO_LINK_OPT_NONE 0x00000000
76 #define GPO_LINK_OPT_DISABLED 0x00000001
77 #define GPO_LINK_OPT_ENFORCED 0x00000002
79 /* GPO_LINK_OPT_ENFORCED takes precedence over GPOPTIONS_BLOCK_INHERITANCE */
81 /* 'gPOptions', maybe a bitmask as well */
82 enum GPO_INHERIT {
83 GPOPTIONS_INHERIT = 0,
84 GPOPTIONS_BLOCK_INHERITANCE = 1
87 /* 'flags' in a 'groupPolicyContainer' object */
88 #define GPFLAGS_ALL_ENABLED 0x00000000
89 #define GPFLAGS_USER_SETTINGS_DISABLED 0x00000001
90 #define GPFLAGS_MACHINE_SETTINGS_DISABLED 0x00000002
91 #define GPFLAGS_ALL_DISABLED (GPFLAGS_USER_SETTINGS_DISABLED | \
92 GPFLAGS_MACHINE_SETTINGS_DISABLED)
94 struct GP_LINK {
95 const char *gp_link; /* raw link name */
96 uint32_t gp_opts; /* inheritance options GPO_INHERIT */
97 uint32_t num_links; /* number of links */
98 char **link_names; /* array of parsed link names */
99 uint32_t *link_opts; /* array of parsed link opts GPO_LINK_OPT_* */
102 struct GP_EXT {
103 const char *gp_extension; /* raw extension name */
104 uint32_t num_exts;
105 char **extensions;
106 char **extensions_guid;
107 char **snapins;
108 char **snapins_guid;
109 struct GP_EXT *next, *prev;
112 #define GPO_CACHE_DIR "gpo_cache"
113 #define GPT_INI "GPT.INI"
114 #define GPO_REFRESH_INTERVAL 60*90
116 #define GPO_REG_STATE_MACHINE "State\\Machine"
118 enum gp_reg_action {
119 GP_REG_ACTION_NONE = 0,
120 GP_REG_ACTION_ADD_VALUE = 1,
121 GP_REG_ACTION_ADD_KEY = 2,
122 GP_REG_ACTION_DEL_VALUES = 3,
123 GP_REG_ACTION_DEL_VALUE = 4,
124 GP_REG_ACTION_DEL_ALL_VALUES = 5,
125 GP_REG_ACTION_DEL_KEYS = 6,
126 GP_REG_ACTION_SEC_KEY_SET = 7,
127 GP_REG_ACTION_SEC_KEY_RESET = 8
130 struct gp_registry_entry {
131 enum gp_reg_action action;
132 const char *key;
133 const char *value;
134 struct registry_value *data;
137 struct gp_registry_value {
138 const char *value;
139 struct registry_value *data;
142 struct gp_registry_entry2 {
143 enum gp_reg_action action;
144 const char *key;
145 size_t num_values;
146 struct gp_registry_value **values;
149 struct gp_registry_entries {
150 size_t num_entries;
151 struct gp_registry_entry **entries;
154 struct gp_registry_context {
155 const struct security_token *token;
156 const char *path;
157 struct registry_key *curr_key;
160 #define GP_EXT_GUID_SECURITY "827D319E-6EAC-11D2-A4EA-00C04F79F83A"
161 #define GP_EXT_GUID_REGISTRY "35378EAC-683F-11D2-A89A-00C04FBBCFA2"
162 #define GP_EXT_GUID_SCRIPTS "42B5FAAE-6536-11D2-AE5A-0000F87571E3"
163 #define ADS_EXTENDED_RIGHT_APPLY_GROUP_POLICY "edacfd8f-ffb3-11d1-b41d-00a0c968f939"
166 struct cli_state;
168 /* The following definitions come from libgpo/gpo_fetch.c */
170 NTSTATUS gpo_explode_filesyspath(TALLOC_CTX *mem_ctx,
171 const char *cache_dir,
172 const char *file_sys_path,
173 char **server,
174 char **service,
175 char **nt_path,
176 char **unix_path);
177 NTSTATUS gpo_fetch_files(TALLOC_CTX *mem_ctx,
178 ADS_STRUCT *ads,
179 struct loadparm_context *lp_ctx,
180 const char *cache_dir,
181 struct GROUP_POLICY_OBJECT *gpo);
182 NTSTATUS gpo_get_sysvol_gpt_version(TALLOC_CTX *mem_ctx,
183 const char *unix_path,
184 uint32_t *sysvol_version,
185 char **display_name);
187 /* The following definitions come from libgpo/gpo_ldap.c */
189 bool ads_parse_gp_ext(TALLOC_CTX *mem_ctx,
190 const char *extension_raw,
191 struct GP_EXT **gp_ext);
192 ADS_STATUS ads_get_gpo_link(ADS_STRUCT *ads,
193 TALLOC_CTX *mem_ctx,
194 const char *link_dn,
195 struct GP_LINK *gp_link_struct);
196 ADS_STATUS ads_add_gpo_link(ADS_STRUCT *ads,
197 TALLOC_CTX *mem_ctx,
198 const char *link_dn,
199 const char *gpo_dn,
200 uint32_t gpo_opt);
201 ADS_STATUS ads_delete_gpo_link(ADS_STRUCT *ads,
202 TALLOC_CTX *mem_ctx,
203 const char *link_dn,
204 const char *gpo_dn);
205 ADS_STATUS ads_get_gpo(ADS_STRUCT *ads,
206 TALLOC_CTX *mem_ctx,
207 const char *gpo_dn,
208 const char *display_name,
209 const char *guid_name,
210 struct GROUP_POLICY_OBJECT *gpo);
211 ADS_STATUS ads_get_sid_token(ADS_STRUCT *ads,
212 TALLOC_CTX *mem_ctx,
213 const char *dn,
214 struct security_token **token);
215 ADS_STATUS ads_get_gpo_list(ADS_STRUCT *ads,
216 TALLOC_CTX *mem_ctx,
217 const char *dn,
218 uint32_t flags,
219 const struct security_token *token,
220 struct GROUP_POLICY_OBJECT **gpo_list);
222 /* The following definitions come from libgpo/gpo_sec.c */
224 NTSTATUS gpo_apply_security_filtering(const struct GROUP_POLICY_OBJECT *gpo,
225 const struct security_token *token);
227 /* The following definitions come from libgpo/gpo_util.c */
229 const char *cse_gpo_guid_string_to_name(const char *guid);
230 const char *cse_gpo_name_to_guid_string(const char *name);
231 const char *cse_snapin_gpo_guid_string_to_name(const char *guid);
232 void dump_gp_ext(struct GP_EXT *gp_ext, int debuglevel);
233 void dump_gpo(ADS_STRUCT *ads,
234 TALLOC_CTX *mem_ctx,
235 struct GROUP_POLICY_OBJECT *gpo,
236 int debuglevel);
237 void dump_gpo_list(ADS_STRUCT *ads,
238 TALLOC_CTX *mem_ctx,
239 struct GROUP_POLICY_OBJECT *gpo_list,
240 int debuglevel);
241 void dump_gplink(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, struct GP_LINK *gp_link);
242 ADS_STATUS gpo_process_a_gpo(ADS_STRUCT *ads,
243 TALLOC_CTX *mem_ctx,
244 const struct security_token *token,
245 struct registry_key *root_key,
246 struct GROUP_POLICY_OBJECT *gpo,
247 const char *extension_guid_filter,
248 uint32_t flags);
249 ADS_STATUS gpo_process_gpo_list(ADS_STRUCT *ads,
250 TALLOC_CTX *mem_ctx,
251 const struct security_token *token,
252 struct GROUP_POLICY_OBJECT *gpo_list,
253 const char *extensions_guid_filter,
254 uint32_t flags);
255 NTSTATUS check_refresh_gpo(ADS_STRUCT *ads,
256 TALLOC_CTX *mem_ctx,
257 const char *cache_dir,
258 struct loadparm_context *lp_ctx,
259 uint32_t flags,
260 struct GROUP_POLICY_OBJECT *gpo);
261 NTSTATUS check_refresh_gpo_list(ADS_STRUCT *ads,
262 TALLOC_CTX *mem_ctx,
263 const char *cache_dir,
264 struct loadparm_context *lp_ctx,
265 uint32_t flags,
266 struct GROUP_POLICY_OBJECT *gpo_list);
267 NTSTATUS gpo_get_unix_path(TALLOC_CTX *mem_ctx,
268 const char *cache_dir,
269 struct GROUP_POLICY_OBJECT *gpo,
270 char **unix_path);
271 char *gpo_flag_str(TALLOC_CTX *mem_ctx, uint32_t flags);
272 NTSTATUS gp_find_file(TALLOC_CTX *mem_ctx,
273 uint32_t flags,
274 const char *filename,
275 const char *suffix,
276 const char **filename_out);
277 ADS_STATUS gp_get_machine_token(ADS_STRUCT *ads,
278 TALLOC_CTX *mem_ctx,
279 struct loadparm_context *lp_ctx,
280 const char *dn,
281 struct security_token **token);
284 #include "../libgpo/gpext/gpext.h"
286 #endif