Merge branch 'master' of ssh://git.samba.org/data/git/samba
[amitay/samba.git] / source4 / dsdb / schema / schema.h
1 /* 
2    Unix SMB/CIFS mplementation.
3    DSDB schema header
4    
5    Copyright (C) Stefan Metzmacher <metze@samba.org> 2006
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
22 #ifndef _DSDB_SCHEMA_H
23 #define _DSDB_SCHEMA_H
24
25 struct dsdb_attribute;
26 struct dsdb_class;
27 struct dsdb_schema;
28
29 struct dsdb_syntax {
30         const char *name;
31         const char *ldap_oid;
32         uint32_t oMSyntax;
33         struct ldb_val oMObjectClass;
34         const char *attributeSyntax_oid;
35         const char *equality;
36         const char *substring;
37         const char *comment;
38         const char *ldb_syntax;
39
40         WERROR (*drsuapi_to_ldb)(const struct dsdb_schema *schema,
41                                  const struct dsdb_attribute *attr,
42                                  const struct drsuapi_DsReplicaAttribute *in,
43                                  TALLOC_CTX *mem_ctx,
44                                  struct ldb_message_element *out);
45         WERROR (*ldb_to_drsuapi)(const struct dsdb_schema *schema,
46                                  const struct dsdb_attribute *attr,
47                                  const struct ldb_message_element *in,
48                                  TALLOC_CTX *mem_ctx,
49                                  struct drsuapi_DsReplicaAttribute *out);
50 };
51
52 struct dsdb_attribute {
53         struct dsdb_attribute *prev, *next;
54
55         const char *cn;
56         const char *lDAPDisplayName;
57         const char *attributeID_oid;
58         uint32_t attributeID_id;
59         struct GUID schemaIDGUID;
60         uint32_t mAPIID;
61
62         struct GUID attributeSecurityGUID;
63
64         uint32_t searchFlags;
65         uint32_t systemFlags;
66         bool isMemberOfPartialAttributeSet;
67         uint32_t linkID;
68
69         const char *attributeSyntax_oid;
70         uint32_t attributeSyntax_id;
71         uint32_t oMSyntax;
72         struct ldb_val oMObjectClass;
73
74         bool isSingleValued;
75         uint32_t *rangeLower;
76         uint32_t *rangeUpper;
77         bool extendedCharsAllowed;
78
79         uint32_t schemaFlagsEx;
80         struct ldb_val msDs_Schema_Extensions;
81
82         bool showInAdvancedViewOnly;
83         const char *adminDisplayName;
84         const char *adminDescription;
85         const char *classDisplayName;
86         bool isEphemeral;
87         bool isDefunct;
88         bool systemOnly;
89
90         /* internal stuff */
91         const struct dsdb_syntax *syntax;
92 };
93
94 struct dsdb_class {
95         struct dsdb_class *prev, *next;
96
97         const char *cn;
98         const char *lDAPDisplayName;
99         const char *governsID_oid;
100         uint32_t governsID_id;
101         struct GUID schemaIDGUID;
102
103         uint32_t objectClassCategory;
104         const char *rDNAttID;
105         const char *defaultObjectCategory;
106
107         const char *subClassOf;
108
109         const char **systemAuxiliaryClass;
110         const char **systemPossSuperiors;
111         const char **systemMustContain;
112         const char **systemMayContain;
113
114         const char **auxiliaryClass;
115         const char **possSuperiors;
116         const char **mustContain;
117         const char **mayContain;
118         const char **possibleInferiors;
119
120         const char *defaultSecurityDescriptor;
121
122         uint32_t schemaFlagsEx;
123         struct ldb_val msDs_Schema_Extensions;
124
125         bool showInAdvancedViewOnly;
126         const char *adminDisplayName;
127         const char *adminDescription;
128         const char *classDisplayName;
129         bool defaultHidingValue;
130         bool isDefunct;
131         bool systemOnly;
132 };
133
134 struct dsdb_schema_oid_prefix {
135         uint32_t id;
136         const char *oid;
137         size_t oid_len;
138 };
139
140 struct dsdb_schema {
141         uint32_t num_prefixes;
142         struct dsdb_schema_oid_prefix *prefixes;
143
144         /* 
145          * the last element of the prefix mapping table isn't a oid,
146          * it starts with 0xFF and has 21 bytes and is maybe a schema
147          * version number
148          *
149          * this is the content of the schemaInfo attribute of the
150          * Schema-Partition head object.
151          */
152         const char *schema_info;
153
154         struct dsdb_attribute *attributes;
155         struct dsdb_class *classes;
156
157         struct {
158                 bool we_are_master;
159                 struct ldb_dn *master_dn;
160         } fsmo;
161
162         struct smb_iconv_convenience *iconv_convenience;
163 };
164
165 enum dsdb_attr_list_query {
166         DSDB_SCHEMA_ALL_MAY,
167         DSDB_SCHEMA_ALL_MUST,
168         DSDB_SCHEMA_SYS_MAY,
169         DSDB_SCHEMA_SYS_MUST,
170         DSDB_SCHEMA_MAY,
171         DSDB_SCHEMA_MUST,
172         DSDB_SCHEMA_ALL
173 };
174
175 enum dsdb_schema_convert_target {
176         TARGET_OPENLDAP,
177         TARGET_FEDORA_DS,
178         TARGET_AD_SCHEMA_SUBENTRY
179 };
180
181 #include "dsdb/schema/proto.h"
182
183 #endif /* _DSDB_SCHEMA_H */