2 Unix SMB/CIFS mplementation.
5 Copyright (C) Stefan Metzmacher <metze@samba.org> 2006
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.
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.
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/>.
22 #ifndef _DSDB_SCHEMA_H
23 #define _DSDB_SCHEMA_H
25 #include "prefixmap.h"
35 struct dsdb_attribute
;
40 struct dsdb_syntax_ctx
{
41 struct ldb_context
*ldb
;
42 const struct dsdb_schema
*schema
;
44 /* set when converting objects under Schema NC */
47 /* remote prefixMap to be used for drsuapi_to_ldb conversions */
48 const struct dsdb_schema_prefixmap
*pfm_remote
;
56 struct ldb_val oMObjectClass
;
57 const char *attributeSyntax_oid
;
59 const char *substring
;
61 const char *ldb_syntax
;
63 WERROR (*drsuapi_to_ldb
)(const struct dsdb_syntax_ctx
*ctx
,
64 const struct dsdb_attribute
*attr
,
65 const struct drsuapi_DsReplicaAttribute
*in
,
67 struct ldb_message_element
*out
);
68 WERROR (*ldb_to_drsuapi
)(const struct dsdb_syntax_ctx
*ctx
,
69 const struct dsdb_attribute
*attr
,
70 const struct ldb_message_element
*in
,
72 struct drsuapi_DsReplicaAttribute
*out
);
73 WERROR (*validate_ldb
)(const struct dsdb_syntax_ctx
*ctx
,
74 const struct dsdb_attribute
*attr
,
75 const struct ldb_message_element
*in
);
77 bool userParameters
; /* Indicates the syntax userParameters should be forced to */
80 struct dsdb_attribute
{
81 struct dsdb_attribute
*prev
, *next
;
84 const char *lDAPDisplayName
;
85 const char *attributeID_oid
;
86 uint32_t attributeID_id
;
87 struct GUID schemaIDGUID
;
91 struct GUID attributeSecurityGUID
;
92 struct GUID objectGUID
;
96 bool isMemberOfPartialAttributeSet
;
99 const char *attributeSyntax_oid
;
100 uint32_t attributeSyntax_id
;
102 struct ldb_val oMObjectClass
;
105 uint32_t *rangeLower
;
106 uint32_t *rangeUpper
;
107 bool extendedCharsAllowed
;
109 uint32_t schemaFlagsEx
;
110 struct ldb_val msDs_Schema_Extensions
;
112 bool showInAdvancedViewOnly
;
113 const char *adminDisplayName
;
114 const char *adminDescription
;
115 const char *classDisplayName
;
121 enum dsdb_dn_format dn_format
;
124 const struct dsdb_syntax
*syntax
;
125 const struct ldb_schema_attribute
*ldb_schema_attribute
;
129 struct dsdb_class
*prev
, *next
;
132 const char *lDAPDisplayName
;
133 const char *governsID_oid
;
134 uint32_t governsID_id
;
135 struct GUID schemaIDGUID
;
136 struct GUID objectGUID
;
138 uint32_t objectClassCategory
;
139 const char *rDNAttID
;
140 const char *defaultObjectCategory
;
142 const char *subClassOf
;
144 const char **systemAuxiliaryClass
;
145 const char **systemPossSuperiors
;
146 const char **systemMustContain
;
147 const char **systemMayContain
;
149 const char **auxiliaryClass
;
150 const char **possSuperiors
;
151 const char **mustContain
;
152 const char **mayContain
;
153 const char **possibleInferiors
;
154 const char **systemPossibleInferiors
;
156 const char *defaultSecurityDescriptor
;
158 uint32_t schemaFlagsEx
;
159 uint32_t systemFlags
;
160 struct ldb_val msDs_Schema_Extensions
;
162 bool showInAdvancedViewOnly
;
163 const char *adminDisplayName
;
164 const char *adminDescription
;
165 const char *classDisplayName
;
166 bool defaultHidingValue
;
170 uint32_t subClassOf_id
;
171 uint32_t *systemAuxiliaryClass_ids
;
172 uint32_t *auxiliaryClass_ids
;
173 uint32_t *systemMayContain_ids
;
174 uint32_t *systemMustContain_ids
;
175 uint32_t *possSuperiors_ids
;
176 uint32_t *mustContain_ids
;
177 uint32_t *mayContain_ids
;
178 uint32_t *systemPossSuperiors_ids
;
180 /* An ordered index showing how this subClass fits into the
181 * subClass tree. that is, an objectclass that is not
182 * subClassOf anything is 0 (just in case), and top is 1, and
183 * subClasses of top are 2, subclasses of those classes are
185 uint32_t subClass_order
;
188 const char **supclasses
;
189 const char **subclasses
;
190 const char **subclasses_direct
;
191 const char **posssuperiors
;
195 enum schema_set_enum
{
196 SCHEMA_MEMORY_ONLY
= 0,
202 * data stored in schemaInfo attribute
204 struct dsdb_schema_info
{
206 struct GUID invocation_id
;
211 struct dsdb_schema_prefixmap
*prefixmap
;
214 * the last element of the prefix mapping table isn't a oid,
215 * it starts with 0xFF and has 21 bytes and is maybe a schema
218 * this is the content of the schemaInfo attribute of the
219 * Schema-Partition head object.
221 struct dsdb_schema_info
*schema_info
;
223 struct dsdb_attribute
*attributes
;
224 struct dsdb_class
*classes
;
226 struct dsdb_attribute
**attributes_to_remove
;
227 uint32_t attributes_to_remove_size
;
228 struct dsdb_class
**classes_to_remove
;
229 uint32_t classes_to_remove_size
;
231 /* lists of classes sorted by various attributes, for faster
233 uint32_t num_classes
;
234 struct dsdb_class
**classes_by_lDAPDisplayName
;
235 struct dsdb_class
**classes_by_governsID_id
;
236 struct dsdb_class
**classes_by_governsID_oid
;
237 struct dsdb_class
**classes_by_cn
;
239 /* lists of attributes sorted by various fields */
240 uint32_t num_attributes
;
241 struct dsdb_attribute
**attributes_by_lDAPDisplayName
;
242 struct dsdb_attribute
**attributes_by_attributeID_id
;
243 struct dsdb_attribute
**attributes_by_attributeID_oid
;
244 struct dsdb_attribute
**attributes_by_linkID
;
245 uint32_t num_int_id_attr
;
246 struct dsdb_attribute
**attributes_by_msDS_IntId
;
251 struct ldb_dn
*master_dn
;
254 /* Was this schema loaded from ldb (if so, then we will reload it when we detect a change in ldb) */
255 bool refresh_in_progress
;
256 time_t ts_last_change
;
257 /* This 'opaque' is stored in the metadata and is used to check if the currently
258 * loaded schema needs a reload because another process has signaled that it has been
259 * requested to reload the schema (either due through DRS or via the schemaUpdateNow).
261 uint64_t metadata_usn
;
263 /* Should the syntax handlers in this case handle all incoming OIDs automatically, assigning them as an OID if no text name is known? */
264 bool relax_OID_conversions
;
267 * we're currently trying to construct a working_schema
268 * in order to replicate the schema partition.
270 * We use this in order to avoid temporary failure DEBUG messages
272 bool resolving_in_progress
;
275 #define DSDB_SCHEMA_COMMON_ATTRS \
283 "msDs-Schema-Extensions", \
284 "showInAdvancedViewOnly", \
285 "adminDisplayName", \
286 "adminDescription", \
290 #define DSDB_SCHEMA_ATTR_ATTRS \
294 "attributeSecurityGUID", \
296 "isMemberOfPartialAttributeSet", \
304 "extendedCharsAllowed", \
305 "classDisplayName", \
308 #define DSDB_SCHEMA_CLASS_ATTRS \
310 "objectClassCategory", \
312 "defaultObjectCategory", \
314 "systemAuxiliaryClass", \
316 "systemMustContain", \
317 "systemMayContain", \
320 "systemPossSuperiors", \
322 "defaultSecurityDescriptor", \
323 "classDisplayName", \
326 enum dsdb_attr_list_query
{
328 DSDB_SCHEMA_ALL_MUST
,
330 DSDB_SCHEMA_SYS_MUST
,
336 enum dsdb_schema_convert_target
{
339 TARGET_AD_SCHEMA_SUBENTRY
344 typedef struct dsdb_schema
*(*dsdb_schema_refresh_fn
)(struct ldb_module
*module
,
345 struct tevent_context
*ev
,
346 struct dsdb_schema
*schema
, bool is_global_schema
);
347 #include "dsdb/schema/proto.h"
349 #endif /* _DSDB_SCHEMA_H */