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
);
79 struct dsdb_attribute
{
80 struct dsdb_attribute
*prev
, *next
;
83 const char *lDAPDisplayName
;
84 const char *attributeID_oid
;
85 uint32_t attributeID_id
;
86 struct GUID schemaIDGUID
;
90 struct GUID attributeSecurityGUID
;
91 struct GUID objectGUID
;
95 bool isMemberOfPartialAttributeSet
;
98 const char *attributeSyntax_oid
;
99 uint32_t attributeSyntax_id
;
101 struct ldb_val oMObjectClass
;
104 uint32_t *rangeLower
;
105 uint32_t *rangeUpper
;
106 bool extendedCharsAllowed
;
108 uint32_t schemaFlagsEx
;
109 struct ldb_val msDs_Schema_Extensions
;
111 bool showInAdvancedViewOnly
;
112 const char *adminDisplayName
;
113 const char *adminDescription
;
114 const char *classDisplayName
;
120 enum dsdb_dn_format dn_format
;
123 const struct dsdb_syntax
*syntax
;
124 const struct ldb_schema_attribute
*ldb_schema_attribute
;
128 struct dsdb_class
*prev
, *next
;
131 const char *lDAPDisplayName
;
132 const char *governsID_oid
;
133 uint32_t governsID_id
;
134 struct GUID schemaIDGUID
;
135 struct GUID objectGUID
;
137 uint32_t objectClassCategory
;
138 const char *rDNAttID
;
139 const char *defaultObjectCategory
;
141 const char *subClassOf
;
143 const char **systemAuxiliaryClass
;
144 const char **systemPossSuperiors
;
145 const char **systemMustContain
;
146 const char **systemMayContain
;
148 const char **auxiliaryClass
;
149 const char **possSuperiors
;
150 const char **mustContain
;
151 const char **mayContain
;
152 const char **possibleInferiors
;
153 const char **systemPossibleInferiors
;
155 const char *defaultSecurityDescriptor
;
157 uint32_t schemaFlagsEx
;
158 uint32_t systemFlags
;
159 struct ldb_val msDs_Schema_Extensions
;
161 bool showInAdvancedViewOnly
;
162 const char *adminDisplayName
;
163 const char *adminDescription
;
164 const char *classDisplayName
;
165 bool defaultHidingValue
;
169 const char **supclasses
;
170 const char **subclasses
;
171 const char **subclasses_direct
;
172 const char **posssuperiors
;
173 uint32_t subClassOf_id
;
174 uint32_t *systemAuxiliaryClass_ids
;
175 uint32_t *auxiliaryClass_ids
;
176 uint32_t *systemMayContain_ids
;
177 uint32_t *systemMustContain_ids
;
178 uint32_t *possSuperiors_ids
;
179 uint32_t *mustContain_ids
;
180 uint32_t *mayContain_ids
;
181 uint32_t *systemPossSuperiors_ids
;
183 /* An ordered index showing how this subClass fits into the
184 * subClass tree. that is, an objectclass that is not
185 * subClassOf anything is 0 (just in case), and top is 1, and
186 * subClasses of top are 2, subclasses of those classes are
188 uint32_t subClass_order
;
192 * data stored in schemaInfo attribute
194 struct dsdb_schema_info
{
196 struct GUID invocation_id
;
201 struct ldb_dn
*base_dn
;
203 struct dsdb_schema_prefixmap
*prefixmap
;
206 * the last element of the prefix mapping table isn't a oid,
207 * it starts with 0xFF and has 21 bytes and is maybe a schema
210 * this is the content of the schemaInfo attribute of the
211 * Schema-Partition head object.
213 const char *schema_info
;
215 /* We can also tell the schema version from the USN on the partition */
218 struct dsdb_attribute
*attributes
;
219 struct dsdb_class
*classes
;
221 /* lists of classes sorted by various attributes, for faster
223 uint32_t num_classes
;
224 struct dsdb_class
**classes_by_lDAPDisplayName
;
225 struct dsdb_class
**classes_by_governsID_id
;
226 struct dsdb_class
**classes_by_governsID_oid
;
227 struct dsdb_class
**classes_by_cn
;
229 /* lists of attributes sorted by various fields */
230 uint32_t num_attributes
;
231 struct dsdb_attribute
**attributes_by_lDAPDisplayName
;
232 struct dsdb_attribute
**attributes_by_attributeID_id
;
233 struct dsdb_attribute
**attributes_by_attributeID_oid
;
234 struct dsdb_attribute
**attributes_by_linkID
;
235 uint32_t num_int_id_attr
;
236 struct dsdb_attribute
**attributes_by_msDS_IntId
;
241 struct ldb_dn
*master_dn
;
244 /* Was this schema loaded from ldb (if so, then we will reload it when we detect a change in ldb) */
245 struct ldb_module
*loaded_from_module
;
246 struct dsdb_schema
*(*refresh_fn
)(struct ldb_module
*module
, struct dsdb_schema
*schema
, bool is_global_schema
);
247 bool refresh_in_progress
;
248 time_t ts_last_change
;
250 /* This 'opaque' is stored in the metadata and is used to check if the currently
251 * loaded schema needs a reload because another process has signaled that it has been
252 * requested to reload the schema (either due through DRS or via the schemaUpdateNow).
254 uint64_t metadata_usn
;
255 /* an 'opaque' sequence number that corresponds to the highest USN of the schema
256 * partition it used in the reload to check if a reload
257 * should really be performed. As the schema is periodically reloaded this
258 * is still needed in order to avoid costly complete schema reload.
260 uint64_t reload_seq_number
;
262 /* Should the syntax handlers in this case handle all incoming OIDs automatically, assigning them as an OID if no text name is known? */
263 bool relax_OID_conversions
;
266 enum dsdb_attr_list_query
{
268 DSDB_SCHEMA_ALL_MUST
,
270 DSDB_SCHEMA_SYS_MUST
,
276 enum dsdb_schema_convert_target
{
279 TARGET_AD_SCHEMA_SUBENTRY
282 #include "dsdb/schema/proto.h"
284 #endif /* _DSDB_SCHEMA_H */