9f45b965e4aff114cc9a9f78d08350f5fcb2fc6b
[kai/samba-autobuild/.git] / source4 / lib / policy / policy.h
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  Group Policy Object Support
4  *  Copyright (C) Guenther Deschner 2005-2008 (from samba 3 gpo.h)
5  *  Copyright (C) Wilco Baan Hofman 2010
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #ifndef __GPO_H__
22 #define __GPO_H__
23 #include "libcli/libcli.h"
24
25 #define GPLINK_OPT_DISABLE              (1 << 0)
26 #define GPLINK_OPT_ENFORCE              (1 << 1)
27
28
29 #define GPO_FLAG_USER_DISABLE           (1 << 0)
30 #define GPO_FLAG_MACHINE_DISABLE        (1 << 1)
31
32 struct security_token;
33
34 enum gpo_inheritance {
35         GPO_INHERIT = 0,
36         GPO_BLOCK_INHERITANCE = 1,
37 };
38
39 struct gp_context {
40         struct ldb_context *ldb_ctx;
41         struct loadparm_context *lp_ctx;
42         struct cli_credentials *credentials;
43         struct tevent_context *ev_ctx;
44         struct smbcli_state *cli;
45         struct nbt_dc_name active_dc;
46 };
47
48 struct gp_object {
49         uint32_t version;
50         uint32_t flags;
51         const char *display_name;
52         const char *name;
53         const char *dn;
54         const char *file_sys_path;
55         struct security_descriptor *security_descriptor;
56 };
57
58
59 struct gp_link {
60         uint32_t options;
61         const char *dn;
62 };
63
64
65 NTSTATUS gp_init(TALLOC_CTX *mem_ctx,
66                                 struct loadparm_context *lp_ctx,
67                                 struct cli_credentials *creds,
68                                 struct tevent_context *ev_ctx,
69                                 struct gp_context **gp_ctx);
70
71
72 /* LDAP functions */
73 NTSTATUS gp_list_all_gpos(struct gp_context *gp_ctx, struct gp_object ***ret);
74 NTSTATUS gp_get_gplinks(struct gp_context *gp_ctx, const char *req_dn, struct gp_link ***ret);
75 NTSTATUS gp_list_gpos(struct gp_context *gp_ctx, struct security_token *token, const char ***ret);
76
77 NTSTATUS gp_get_gpo_info(struct gp_context *gp_ctx, const char *dn_str, struct gp_object **ret);
78 NTSTATUS gp_set_gpo_info(struct gp_context *gp_ctx, const char *dn_str, struct gp_object *gpo);
79 NTSTATUS gp_del_gpo(struct gp_context *gp_ctx, const char *dn_str);
80
81
82 NTSTATUS gp_get_gplink_options(TALLOC_CTX *mem_ctx, uint32_t flags, const char ***ret);
83 NTSTATUS gp_get_gpo_flags(TALLOC_CTX *mem_ctx, uint32_t flags, const char ***ret);
84
85 NTSTATUS gp_set_gplink(struct gp_context *gp_ctx, const char *dn_str, struct gp_link *gplink);
86 NTSTATUS gp_del_gplink(struct gp_context *gp_ctx, const char *dn_str, const char *gp_dn);
87 NTSTATUS gp_get_inheritance(struct gp_context *gp_ctx, const char *dn_str, enum gpo_inheritance *inheritance);
88 NTSTATUS gp_set_inheritance(struct gp_context *gp_ctx, const char *dn_str, enum gpo_inheritance inheritance);
89
90 NTSTATUS gp_create_ldap_gpo(struct gp_context *gp_ctx, struct gp_object *gpo);
91
92 /* File system functions */
93 NTSTATUS gp_fetch_gpt (struct gp_context *gp_ctx, struct gp_object *gpo, const char **path);
94 NTSTATUS gp_create_gpt(struct gp_context *gp_ctx, const char *name, const char *file_sys_path);
95
96 /* Managing functions */
97 NTSTATUS gp_create_gpo (struct gp_context *gp_ctx, const char *display_name, struct gp_object **ret);
98
99 #endif