]> git.sur5r.net Git - openldap/blob - servers/slapd/schema_prep.c
happy belated new year
[openldap] / servers / slapd / schema_prep.c
1 /* schema_prep.c - load builtin schema */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 1998-2010 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
12  * A copy of this license is available in the file LICENSE in the
13  * top-level directory of the distribution or, alternatively, at
14  * <http://www.OpenLDAP.org/license.html>.
15  */
16
17 #include "portable.h"
18
19 #include <stdio.h>
20
21 #include <ac/ctype.h>
22 #include <ac/string.h>
23 #include <ac/socket.h>
24
25 #include "slap.h"
26
27 #define OCDEBUG 0
28
29 int schema_init_done = 0;
30
31 struct slap_internal_schema slap_schema;
32
33 static int
34 oidValidate(
35         Syntax *syntax,
36         struct berval *in )
37 {
38         struct berval val = *in;
39
40         if( val.bv_len == 0 ) {
41                 /* disallow empty strings */
42                 return LDAP_INVALID_SYNTAX;
43         }
44
45         if( DESC_LEADCHAR( val.bv_val[0] ) ) {
46                 val.bv_val++;
47                 val.bv_len--;
48                 if ( val.bv_len == 0 ) return LDAP_SUCCESS;
49
50                 while( DESC_CHAR( val.bv_val[0] ) ) {
51                         val.bv_val++;
52                         val.bv_len--;
53
54                         if ( val.bv_len == 0 ) return LDAP_SUCCESS;
55                 }
56
57         } else {
58                 int sep = 0;
59                 while( OID_LEADCHAR( val.bv_val[0] ) ) {
60                         val.bv_val++;
61                         val.bv_len--;
62
63                         if ( val.bv_val[-1] != '0' ) {
64                                 while ( OID_LEADCHAR( val.bv_val[0] )) {
65                                         val.bv_val++;
66                                         val.bv_len--;
67                                 }
68                         }
69
70                         if( val.bv_len == 0 ) {
71                                 if( sep == 0 ) break;
72                                 return LDAP_SUCCESS;
73                         }
74
75                         if( !OID_SEPARATOR( val.bv_val[0] )) break;
76
77                         sep++;
78                         val.bv_val++;
79                         val.bv_len--;
80                 }
81         }
82
83         return LDAP_INVALID_SYNTAX;
84 }
85
86
87 static int objectClassPretty(
88         Syntax *syntax,
89         struct berval *in,
90         struct berval *out,
91         void *ctx )
92 {
93         ObjectClass *oc;
94
95         if( oidValidate( NULL, in )) return LDAP_INVALID_SYNTAX;
96
97         oc = oc_bvfind( in );
98         if( oc == NULL ) return LDAP_INVALID_SYNTAX;
99
100         ber_dupbv_x( out, &oc->soc_cname, ctx );
101         return LDAP_SUCCESS;
102 }
103
104 static int
105 attributeTypeMatch(
106         int *matchp,
107         slap_mask_t flags,
108         Syntax *syntax,
109         MatchingRule *mr,
110         struct berval *value,
111         void *assertedValue )
112 {
113         struct berval *a = (struct berval *) assertedValue;
114         AttributeType *at = at_bvfind( value );
115         AttributeType *asserted = at_bvfind( a );
116
117         if( asserted == NULL ) {
118                 if( OID_LEADCHAR( *a->bv_val ) ) {
119                         /* OID form, return FALSE */
120                         *matchp = 1;
121                         return LDAP_SUCCESS;
122                 }
123
124                 /* desc form, return undefined */
125                 return LDAP_INVALID_SYNTAX;
126         }
127
128         if ( at == NULL ) {
129                 /* unrecognized stored value */
130                 return LDAP_INVALID_SYNTAX;
131         }
132
133         *matchp = ( asserted != at );
134         return LDAP_SUCCESS;
135 }
136
137 static int
138 matchingRuleMatch(
139         int *matchp,
140         slap_mask_t flags,
141         Syntax *syntax,
142         MatchingRule *mr,
143         struct berval *value,
144         void *assertedValue )
145 {
146         struct berval *a = (struct berval *) assertedValue;
147         MatchingRule *mrv = mr_bvfind( value );
148         MatchingRule *asserted = mr_bvfind( a );
149
150         if( asserted == NULL ) {
151                 if( OID_LEADCHAR( *a->bv_val ) ) {
152                         /* OID form, return FALSE */
153                         *matchp = 1;
154                         return LDAP_SUCCESS;
155                 }
156
157                 /* desc form, return undefined */
158                 return LDAP_INVALID_SYNTAX;
159         }
160
161         if ( mrv == NULL ) {
162                 /* unrecognized stored value */
163                 return LDAP_INVALID_SYNTAX;
164         }
165
166         *matchp = ( asserted != mrv );
167         return LDAP_SUCCESS;
168 }
169
170 static int
171 objectClassMatch(
172         int *matchp,
173         slap_mask_t flags,
174         Syntax *syntax,
175         MatchingRule *mr,
176         struct berval *value,
177         void *assertedValue )
178 {
179         struct berval *a = (struct berval *) assertedValue;
180         ObjectClass *oc = oc_bvfind( value );
181         ObjectClass *asserted = oc_bvfind( a );
182
183         if( asserted == NULL ) {
184                 if( OID_LEADCHAR( *a->bv_val ) ) {
185                         /* OID form, return FALSE */
186                         *matchp = 1;
187                         return LDAP_SUCCESS;
188                 }
189
190                 /* desc form, return undefined */
191                 return LDAP_INVALID_SYNTAX;
192         }
193
194         if ( oc == NULL ) {
195                 /* unrecognized stored value */
196                 return LDAP_INVALID_SYNTAX;
197         }
198
199         *matchp = ( asserted != oc );
200         return LDAP_SUCCESS;
201 }
202
203 static int
204 objectSubClassMatch(
205         int *matchp,
206         slap_mask_t flags,
207         Syntax *syntax,
208         MatchingRule *mr,
209         struct berval *value,
210         void *assertedValue )
211 {
212         struct berval *a = (struct berval *) assertedValue;
213         ObjectClass *oc = oc_bvfind( value );
214         ObjectClass *asserted = oc_bvfind( a );
215
216         if( asserted == NULL ) {
217                 if( OID_LEADCHAR( *a->bv_val ) ) {
218                         /* OID form, return FALSE */
219                         *matchp = 1;
220                         return LDAP_SUCCESS;
221                 }
222
223                 /* desc form, return undefined */
224                 return LDAP_INVALID_SYNTAX;
225         }
226
227         if ( oc == NULL ) {
228                 /* unrecognized stored value */
229                 return LDAP_INVALID_SYNTAX;
230         }
231
232         if( SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX( flags ) ) {
233                 *matchp = ( asserted != oc );
234         } else {
235                 *matchp = !is_object_subclass( asserted, oc );
236         }
237
238         return LDAP_SUCCESS;
239 }
240
241 static int objectSubClassIndexer( 
242         slap_mask_t use,
243         slap_mask_t mask,
244         Syntax *syntax,
245         MatchingRule *mr,
246         struct berval *prefix,
247         BerVarray values,
248         BerVarray *keysp,
249         void *ctx )
250 {
251         int rc, noc, i;
252         BerVarray ocvalues;
253         ObjectClass **socs;
254         
255         for( noc=0; values[noc].bv_val != NULL; noc++ ) {
256                 /* just count em */;
257         }
258
259         /* over allocate */
260         socs = slap_sl_malloc( (noc+16) * sizeof( ObjectClass * ), ctx );
261
262         /* initialize */
263         for( i=0; i<noc; i++ ) {
264                 socs[i] = oc_bvfind( &values[i] );
265         }
266
267         /* expand values */
268         for( i=0; i<noc; i++ ) {
269                 int j;
270                 ObjectClass *oc = socs[i];
271                 if( oc == NULL || oc->soc_sups == NULL ) continue;
272                 
273                 for( j=0; oc->soc_sups[j] != NULL; j++ ) {
274                         int found = 0;
275                         ObjectClass *sup = oc->soc_sups[j];
276                         int k;
277
278                         for( k=0; k<noc; k++ ) {
279                                 if( sup == socs[k] ) {
280                                         found++;
281                                         break;
282                                 }
283                         }
284
285                         if( !found ) {
286                                 socs = slap_sl_realloc( socs,
287                                         sizeof( ObjectClass * ) * (noc+2), ctx );
288
289                                 assert( k == noc );
290                                 socs[noc++] = sup;
291                         }
292                 }
293         }
294
295         ocvalues = slap_sl_malloc( sizeof( struct berval ) * (noc+1), ctx );
296         /* copy values */
297         for( i=0; i<noc; i++ ) {
298                 if ( socs[i] )
299                         ocvalues[i] = socs[i]->soc_cname;
300                 else
301                         ocvalues[i] = values[i];
302         }
303         BER_BVZERO( &ocvalues[i] );
304
305         rc = octetStringIndexer( use, mask, syntax, mr,
306                 prefix, ocvalues, keysp, ctx );
307
308         slap_sl_free( ocvalues, ctx );
309         slap_sl_free( socs, ctx );
310         return rc;
311 }
312
313 #define objectSubClassFilter octetStringFilter
314
315 static ObjectClassSchemaCheckFN rootDseObjectClass;
316 static ObjectClassSchemaCheckFN aliasObjectClass;
317 static ObjectClassSchemaCheckFN referralObjectClass;
318 static ObjectClassSchemaCheckFN subentryObjectClass;
319 #ifdef LDAP_DYNAMIC_OBJECTS
320 static ObjectClassSchemaCheckFN dynamicObjectClass;
321 #endif
322
323 static struct slap_schema_oc_map {
324         char *ssom_name;
325         char *ssom_defn;
326         ObjectClassSchemaCheckFN *ssom_check;
327         slap_mask_t ssom_flags;
328         size_t ssom_offset;
329 } oc_map[] = {
330         { "top", "( 2.5.6.0 NAME 'top' "
331                         "DESC 'top of the superclass chain' "
332                         "ABSTRACT MUST objectClass )",
333                 0, 0, offsetof(struct slap_internal_schema, si_oc_top) },
334         { "extensibleObject", "( 1.3.6.1.4.1.1466.101.120.111 "
335                         "NAME 'extensibleObject' "
336                         "DESC 'RFC4512: extensible object' "
337                         "SUP top AUXILIARY )",
338                 0, SLAP_OC_OPERATIONAL,
339                 offsetof(struct slap_internal_schema, si_oc_extensibleObject) },
340         { "alias", "( 2.5.6.1 NAME 'alias' "
341                         "DESC 'RFC4512: an alias' "
342                         "SUP top STRUCTURAL "
343                         "MUST aliasedObjectName )",
344                 aliasObjectClass, SLAP_OC_ALIAS|SLAP_OC_OPERATIONAL,
345                 offsetof(struct slap_internal_schema, si_oc_alias) },
346         { "referral", "( 2.16.840.1.113730.3.2.6 NAME 'referral' "
347                         "DESC 'namedref: named subordinate referral' "
348                         "SUP top STRUCTURAL MUST ref )",
349                 referralObjectClass, SLAP_OC_REFERRAL|SLAP_OC_OPERATIONAL,
350                 offsetof(struct slap_internal_schema, si_oc_referral) },
351         { "LDAProotDSE", "( 1.3.6.1.4.1.4203.1.4.1 "
352                         "NAME ( 'OpenLDAProotDSE' 'LDAProotDSE' ) "
353                         "DESC 'OpenLDAP Root DSE object' "
354                         "SUP top STRUCTURAL MAY cn )",
355                 rootDseObjectClass, SLAP_OC_OPERATIONAL,
356                 offsetof(struct slap_internal_schema, si_oc_rootdse) },
357         { "subentry", "( 2.5.17.0 NAME 'subentry' "
358                         "DESC 'RFC3672: subentry' "
359                         "SUP top STRUCTURAL "
360                         "MUST ( cn $ subtreeSpecification ) )",
361                 subentryObjectClass, SLAP_OC_SUBENTRY|SLAP_OC_OPERATIONAL,
362                 offsetof(struct slap_internal_schema, si_oc_subentry) },
363         { "subschema", "( 2.5.20.1 NAME 'subschema' "
364                 "DESC 'RFC4512: controlling subschema (sub)entry' "
365                 "AUXILIARY "
366                 "MAY ( dITStructureRules $ nameForms $ dITContentRules $ "
367                         "objectClasses $ attributeTypes $ matchingRules $ "
368                         "matchingRuleUse ) )",
369                 subentryObjectClass, SLAP_OC_OPERATIONAL,
370                 offsetof(struct slap_internal_schema, si_oc_subschema) },
371 #ifdef LDAP_COLLECTIVE_ATTRIBUTES
372         { "collectiveAttributeSubentry", "( 2.5.17.2 "
373                         "NAME 'collectiveAttributeSubentry' "
374                         "DESC 'RFC3671: collective attribute subentry' "
375                         "AUXILIARY )",
376                 subentryObjectClass,
377                 SLAP_OC_COLLECTIVEATTRIBUTESUBENTRY|SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
378                 offsetof( struct slap_internal_schema,
379                         si_oc_collectiveAttributeSubentry) },
380 #endif
381 #ifdef LDAP_DYNAMIC_OBJECTS
382         { "dynamicObject", "( 1.3.6.1.4.1.1466.101.119.2 "
383                         "NAME 'dynamicObject' "
384                         "DESC 'RFC2589: Dynamic Object' "
385                         "SUP top AUXILIARY )",
386                 dynamicObjectClass, SLAP_OC_DYNAMICOBJECT,
387                 offsetof(struct slap_internal_schema, si_oc_dynamicObject) },
388 #endif
389         { "glue", "( 1.3.6.1.4.1.4203.666.3.4 "
390                         "NAME 'glue' "
391                         "DESC 'Glue Entry' "
392                         "SUP top STRUCTURAL )",
393                 0, SLAP_OC_GLUE|SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
394                 offsetof(struct slap_internal_schema, si_oc_glue) },
395         { "syncConsumerSubentry", "( 1.3.6.1.4.1.4203.666.3.5 "
396                         "NAME 'syncConsumerSubentry' "
397                         "DESC 'Persistent Info for SyncRepl Consumer' "
398                         "AUXILIARY "
399                         "MAY syncreplCookie )",
400                 0, SLAP_OC_SYNCCONSUMERSUBENTRY|SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
401                 offsetof(struct slap_internal_schema, si_oc_syncConsumerSubentry) },
402         { "syncProviderSubentry", "( 1.3.6.1.4.1.4203.666.3.6 "
403                         "NAME 'syncProviderSubentry' "
404                         "DESC 'Persistent Info for SyncRepl Producer' "
405                         "AUXILIARY "
406                         "MAY contextCSN )",
407                 0, SLAP_OC_SYNCPROVIDERSUBENTRY|SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
408                 offsetof(struct slap_internal_schema, si_oc_syncProviderSubentry) },
409
410         { NULL, NULL, NULL, 0, 0 }
411 };
412
413 static AttributeTypeSchemaCheckFN rootDseAttribute;
414 static AttributeTypeSchemaCheckFN aliasAttribute;
415 static AttributeTypeSchemaCheckFN referralAttribute;
416 static AttributeTypeSchemaCheckFN subentryAttribute;
417 static AttributeTypeSchemaCheckFN administrativeRoleAttribute;
418 #ifdef LDAP_DYNAMIC_OBJECTS
419 static AttributeTypeSchemaCheckFN dynamicAttribute;
420 #endif
421
422 static struct slap_schema_ad_map {
423         char *ssam_name;
424         char *ssam_defn;
425         AttributeTypeSchemaCheckFN *ssam_check;
426         slap_mask_t ssam_flags;
427         slap_syntax_validate_func *ssam_syn_validate;
428         slap_syntax_transform_func *ssam_syn_pretty;
429         slap_mr_convert_func *ssam_mr_convert;
430         slap_mr_normalize_func *ssam_mr_normalize;
431         slap_mr_match_func *ssam_mr_match;
432         slap_mr_indexer_func *ssam_mr_indexer;
433         slap_mr_filter_func *ssam_mr_filter;
434         size_t ssam_offset;
435 } ad_map[] = {
436         { "objectClass", "( 2.5.4.0 NAME 'objectClass' "
437                         "DESC 'RFC4512: object classes of the entity' "
438                         "EQUALITY objectIdentifierMatch "
439                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
440                 NULL, SLAP_AT_FINAL,
441                 oidValidate, objectClassPretty,
442                 NULL, NULL, objectSubClassMatch,
443                         objectSubClassIndexer, objectSubClassFilter,
444                 offsetof(struct slap_internal_schema, si_ad_objectClass) },
445
446         /* user entry operational attributes */
447         { "structuralObjectClass", "( 2.5.21.9 NAME 'structuralObjectClass' "
448                         "DESC 'RFC4512: structural object class of entry' "
449                         "EQUALITY objectIdentifierMatch "
450                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
451                         "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
452                 NULL, 0,
453                 oidValidate, objectClassPretty,
454                 NULL, NULL, objectSubClassMatch,
455                         objectSubClassIndexer, objectSubClassFilter,
456                 offsetof(struct slap_internal_schema, si_ad_structuralObjectClass) },
457         { "createTimestamp", "( 2.5.18.1 NAME 'createTimestamp' "
458                         "DESC 'RFC4512: time which object was created' "
459                         "EQUALITY generalizedTimeMatch "
460                         "ORDERING generalizedTimeOrderingMatch "
461                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
462                         "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
463                 NULL, SLAP_AT_MANAGEABLE,
464                 NULL, NULL,
465                 NULL, NULL, NULL, NULL, NULL,
466                 offsetof(struct slap_internal_schema, si_ad_createTimestamp) },
467         { "modifyTimestamp", "( 2.5.18.2 NAME 'modifyTimestamp' "
468                         "DESC 'RFC4512: time which object was last modified' "
469                         "EQUALITY generalizedTimeMatch "
470                         "ORDERING generalizedTimeOrderingMatch "
471                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
472                         "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
473                 NULL, SLAP_AT_MANAGEABLE,
474                 NULL, NULL,
475                 NULL, NULL, NULL, NULL, NULL,
476                 offsetof(struct slap_internal_schema, si_ad_modifyTimestamp) },
477         { "creatorsName", "( 2.5.18.3 NAME 'creatorsName' "
478                         "DESC 'RFC4512: name of creator' "
479                         "EQUALITY distinguishedNameMatch "
480                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
481                         "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
482                 NULL, SLAP_AT_MANAGEABLE,
483                 NULL, NULL,
484                 NULL, NULL, NULL, NULL, NULL,
485                 offsetof(struct slap_internal_schema, si_ad_creatorsName) },
486         { "modifiersName", "( 2.5.18.4 NAME 'modifiersName' "
487                         "DESC 'RFC4512: name of last modifier' "
488                         "EQUALITY distinguishedNameMatch "
489                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
490                         "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
491                 NULL, SLAP_AT_MANAGEABLE,
492                 NULL, NULL,
493                 NULL, NULL, NULL, NULL, NULL,
494                 offsetof(struct slap_internal_schema, si_ad_modifiersName) },
495         { "hasSubordinates", "( 2.5.18.9 NAME 'hasSubordinates' "
496                         "DESC 'X.501: entry has children' "
497                         "EQUALITY booleanMatch "
498                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
499                         "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
500                 NULL, SLAP_AT_DYNAMIC,
501                 NULL, NULL,
502                 NULL, NULL, NULL, NULL, NULL,
503                 offsetof(struct slap_internal_schema, si_ad_hasSubordinates) },
504         { "subschemaSubentry", "( 2.5.18.10 NAME 'subschemaSubentry' "
505                         "DESC 'RFC4512: name of controlling subschema entry' "
506                         "EQUALITY distinguishedNameMatch "
507                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE "
508                         "NO-USER-MODIFICATION USAGE directoryOperation )",
509                 NULL, SLAP_AT_DYNAMIC,
510                 NULL, NULL,
511                 NULL, NULL, NULL, NULL, NULL,
512                 offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) },
513 #ifdef LDAP_COLLECTIVE_ATTRIBUTES
514         { "collectiveAttributeSubentries", "( 2.5.18.12 "
515                         "NAME 'collectiveAttributeSubentries' "
516                         "DESC 'RFC3671: collective attribute subentries' "
517                         "EQUALITY distinguishedNameMatch "
518                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
519                         "NO-USER-MODIFICATION USAGE directoryOperation )",
520                 NULL, SLAP_AT_HIDE,
521                 NULL, NULL,
522                 NULL, NULL, NULL, NULL, NULL,
523                 offsetof(struct slap_internal_schema, si_ad_collectiveSubentries) },
524         { "collectiveExclusions", "( 2.5.18.7 NAME 'collectiveExclusions' "
525                         "DESC 'RFC3671: collective attribute exclusions' "
526                         "EQUALITY objectIdentifierMatch "
527                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
528                         "USAGE directoryOperation )",
529                 NULL, SLAP_AT_HIDE,
530                 NULL, NULL,
531                 NULL, NULL, NULL, NULL, NULL,
532                 offsetof(struct slap_internal_schema, si_ad_collectiveExclusions) },
533 #endif
534
535         { "entryDN", "( 1.3.6.1.1.20 NAME 'entryDN' "   
536                         "DESC 'DN of the entry' "
537                         "EQUALITY distinguishedNameMatch "
538                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
539                         "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
540                 NULL, SLAP_AT_DYNAMIC,
541                 NULL, NULL,
542                 NULL, NULL, NULL, NULL, NULL,
543                 offsetof(struct slap_internal_schema, si_ad_entryDN) },
544         { "entryUUID", "( 1.3.6.1.1.16.4 NAME 'entryUUID' "   
545                         "DESC 'UUID of the entry' "
546                         "EQUALITY UUIDMatch "
547                         "ORDERING UUIDOrderingMatch "
548                         "SYNTAX 1.3.6.1.1.16.1 "
549                         "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
550                 NULL, SLAP_AT_MANAGEABLE,
551                 NULL, NULL,
552                 NULL, NULL, NULL, NULL, NULL,
553                 offsetof(struct slap_internal_schema, si_ad_entryUUID) },
554         { "entryCSN", "( 1.3.6.1.4.1.4203.666.1.7 NAME 'entryCSN' "
555                         "DESC 'change sequence number of the entry content' "
556                         "EQUALITY CSNMatch "
557                         "ORDERING CSNOrderingMatch "
558                         "SYNTAX 1.3.6.1.4.1.4203.666.11.2.1{64} "
559                         "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
560                 NULL, SLAP_AT_HIDE,
561                 NULL, NULL,
562                 NULL, NULL, NULL, NULL, NULL,
563                 offsetof(struct slap_internal_schema, si_ad_entryCSN) },
564         { "namingCSN", "( 1.3.6.1.4.1.4203.666.1.13 NAME 'namingCSN' "
565                         "DESC 'change sequence number of the entry naming (RDN)' "
566                         "EQUALITY CSNMatch "
567                         "ORDERING CSNOrderingMatch "
568                         "SYNTAX 1.3.6.1.4.1.4203.666.11.2.1{64} "
569                         "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
570                 NULL, SLAP_AT_HIDE,
571                 NULL, NULL,
572                 NULL, NULL, NULL, NULL, NULL,
573                 offsetof(struct slap_internal_schema, si_ad_namingCSN) },
574
575 #ifdef LDAP_SUPERIOR_UUID
576         { "superiorUUID", "( 1.3.6.1.4.1.4203.666.1.11 NAME 'superiorUUID' "   
577                         "DESC 'UUID of the superior entry' "
578                         "EQUALITY UUIDMatch "
579                         "ORDERING UUIDOrderingMatch "
580                         "SYNTAX 1.3.6.1.1.16.1 "
581                         "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
582                 NULL, SLAP_AT_HIDE,
583                 NULL, NULL,
584                 NULL, NULL, NULL, NULL, NULL,
585                 offsetof(struct slap_internal_schema, si_ad_superiorUUID) },
586 #endif
587
588         { "syncreplCookie", "( 1.3.6.1.4.1.4203.666.1.23 "
589                         "NAME 'syncreplCookie' "
590                         "DESC 'syncrepl Cookie for shadow copy' "
591                         "EQUALITY octetStringMatch "
592                         "ORDERING octetStringOrderingMatch "
593                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 "
594                         "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
595                 NULL, SLAP_AT_HIDE,
596                 NULL, NULL,
597                 NULL, NULL, NULL, NULL, NULL,
598                 offsetof(struct slap_internal_schema, si_ad_syncreplCookie) },
599
600         { "contextCSN", "( 1.3.6.1.4.1.4203.666.1.25 "
601                         "NAME 'contextCSN' "
602                         "DESC 'the largest committed CSN of a context' "
603                         "EQUALITY CSNMatch "
604                         "ORDERING CSNOrderingMatch "
605                         "SYNTAX 1.3.6.1.4.1.4203.666.11.2.1{64} "
606                         "NO-USER-MODIFICATION USAGE dSAOperation )",
607                 NULL, SLAP_AT_HIDE,
608                 NULL, NULL,
609                 NULL, NULL, NULL, NULL, NULL,
610                 offsetof(struct slap_internal_schema, si_ad_contextCSN) },
611
612 #ifdef LDAP_SYNC_TIMESTAMP
613         { "syncTimestamp", "( 1.3.6.1.4.1.4203.666.1.26 NAME 'syncTimestamp' "
614                         "DESC 'Time which object was replicated' "
615                         "EQUALITY generalizedTimeMatch "
616                         "ORDERING generalizedTimeOrderingMatch "
617                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
618                         "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
619                 NULL, 0,
620                 NULL, NULL,
621                 NULL, NULL, NULL, NULL, NULL,
622                 offsetof(struct slap_internal_schema, si_ad_syncTimestamp) },
623 #endif
624
625         /* root DSE attributes */
626         { "altServer", "( 1.3.6.1.4.1.1466.101.120.6 NAME 'altServer' "
627                         "DESC 'RFC4512: alternative servers' "
628                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 USAGE dSAOperation )",
629                 rootDseAttribute, 0,
630                 NULL, NULL,
631                 NULL, NULL, NULL, NULL, NULL,
632                 offsetof(struct slap_internal_schema, si_ad_altServer) },
633         { "namingContexts", "( 1.3.6.1.4.1.1466.101.120.5 "
634                         "NAME 'namingContexts' "
635                         "DESC 'RFC4512: naming contexts' "
636                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 USAGE dSAOperation )",
637                 rootDseAttribute, 0,
638                 NULL, NULL,
639                 NULL, NULL, NULL, NULL, NULL,
640                 offsetof(struct slap_internal_schema, si_ad_namingContexts) },
641         { "supportedControl", "( 1.3.6.1.4.1.1466.101.120.13 "
642                         "NAME 'supportedControl' "
643                         "DESC 'RFC4512: supported controls' "
644                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 USAGE dSAOperation )",
645                 rootDseAttribute, 0,
646                 NULL, NULL,
647                 NULL, NULL, NULL, NULL, NULL,
648                 offsetof(struct slap_internal_schema, si_ad_supportedControl) },
649         { "supportedExtension", "( 1.3.6.1.4.1.1466.101.120.7 "
650                         "NAME 'supportedExtension' "
651                         "DESC 'RFC4512: supported extended operations' "
652                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 USAGE dSAOperation )",
653                 rootDseAttribute, 0,
654                 NULL, NULL,
655                 NULL, NULL, NULL, NULL, NULL,
656                 offsetof(struct slap_internal_schema, si_ad_supportedExtension) },
657         { "supportedLDAPVersion", "( 1.3.6.1.4.1.1466.101.120.15 "
658                         "NAME 'supportedLDAPVersion' "
659                         "DESC 'RFC4512: supported LDAP versions' "
660                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 USAGE dSAOperation )",
661                 rootDseAttribute, 0,
662                 NULL, NULL,
663                 NULL, NULL, NULL, NULL, NULL,
664                 offsetof(struct slap_internal_schema, si_ad_supportedLDAPVersion) },
665         { "supportedSASLMechanisms", "( 1.3.6.1.4.1.1466.101.120.14 "
666                         "NAME 'supportedSASLMechanisms' "
667                         "DESC 'RFC4512: supported SASL mechanisms'"
668                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 USAGE dSAOperation )",
669                 rootDseAttribute, 0,
670                 NULL, NULL,
671                 NULL, NULL, NULL, NULL, NULL,
672                 offsetof(struct slap_internal_schema, si_ad_supportedSASLMechanisms) },
673         { "supportedFeatures", "( 1.3.6.1.4.1.4203.1.3.5 "
674                         "NAME 'supportedFeatures' "
675                         "DESC 'RFC4512: features supported by the server' "
676                         "EQUALITY objectIdentifierMatch "
677                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
678                         "USAGE dSAOperation )",
679                 rootDseAttribute, 0,
680                 NULL, NULL,
681                 NULL, NULL, NULL, NULL, NULL,
682                 offsetof(struct slap_internal_schema, si_ad_supportedFeatures) },
683         { "monitorContext", "( 1.3.6.1.4.1.4203.666.1.10 "
684                         "NAME 'monitorContext' "
685                         "DESC 'monitor context' "
686                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
687                         "EQUALITY distinguishedNameMatch "
688                         "SINGLE-VALUE NO-USER-MODIFICATION "
689                         "USAGE dSAOperation )",
690                 rootDseAttribute, SLAP_AT_HIDE,
691                 NULL, NULL,
692                 NULL, NULL, NULL, NULL, NULL,
693                 offsetof(struct slap_internal_schema, si_ad_monitorContext) },
694         { "configContext", "( 1.3.6.1.4.1.4203.1.12.2.1 "
695                         "NAME 'configContext' "
696                         "DESC 'config context' "
697                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
698                         "EQUALITY distinguishedNameMatch "
699                         "SINGLE-VALUE NO-USER-MODIFICATION "
700                         "USAGE dSAOperation )",
701                 rootDseAttribute, SLAP_AT_HIDE,
702                 NULL, NULL,
703                 NULL, NULL, NULL, NULL, NULL,
704                 offsetof(struct slap_internal_schema, si_ad_configContext) },
705         { "vendorName", "( 1.3.6.1.1.4 NAME 'vendorName' "
706                         "DESC 'RFC3045: name of implementation vendor' "
707                         "EQUALITY caseExactMatch "
708                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
709                         "SINGLE-VALUE NO-USER-MODIFICATION "
710                         "USAGE dSAOperation )",
711                 rootDseAttribute, 0,
712                 NULL, NULL,
713                 NULL, NULL, NULL, NULL, NULL,
714                 offsetof(struct slap_internal_schema, si_ad_vendorName) },
715         { "vendorVersion", "( 1.3.6.1.1.5 NAME 'vendorVersion' "
716                         "DESC 'RFC3045: version of implementation' "
717                         "EQUALITY caseExactMatch "
718                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
719                         "SINGLE-VALUE NO-USER-MODIFICATION "
720                         "USAGE dSAOperation )",
721                 rootDseAttribute, 0,
722                 NULL, NULL,
723                 NULL, NULL, NULL, NULL, NULL,
724                 offsetof(struct slap_internal_schema, si_ad_vendorVersion) },
725
726         /* subentry attributes */
727         { "administrativeRole", "( 2.5.18.5 NAME 'administrativeRole' "
728                         "DESC 'RFC3672: administrative role' "
729                         "EQUALITY objectIdentifierMatch "
730                         "USAGE directoryOperation "
731                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
732                 administrativeRoleAttribute, SLAP_AT_HIDE,
733                 NULL, NULL,
734                 NULL, NULL, NULL, NULL, NULL,
735                 offsetof(struct slap_internal_schema, si_ad_administrativeRole) },
736         { "subtreeSpecification", "( 2.5.18.6 NAME 'subtreeSpecification' "
737                         "DESC 'RFC3672: subtree specification' "
738                         "SINGLE-VALUE "
739                         "USAGE directoryOperation "
740                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.45 )",
741                 subentryAttribute, SLAP_AT_HIDE,
742                 NULL, NULL,
743                 NULL, NULL, NULL, NULL, NULL,
744                 offsetof(struct slap_internal_schema, si_ad_subtreeSpecification) },
745
746         /* subschema subentry attributes */
747         { "dITStructureRules", "( 2.5.21.1 NAME 'dITStructureRules' "
748                         "DESC 'RFC4512: DIT structure rules' "
749                         "EQUALITY integerFirstComponentMatch "
750                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 "
751                         "USAGE directoryOperation ) ",
752                 subentryAttribute, SLAP_AT_HIDE,
753                 NULL, NULL,
754                 NULL, NULL, NULL, NULL, NULL,
755                 offsetof(struct slap_internal_schema, si_ad_ditStructureRules) },
756         { "dITContentRules", "( 2.5.21.2 NAME 'dITContentRules' "
757                         "DESC 'RFC4512: DIT content rules' "
758                         "EQUALITY objectIdentifierFirstComponentMatch "
759                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.16 USAGE directoryOperation )",
760                 subentryAttribute, SLAP_AT_HIDE,
761                 oidValidate, NULL,
762                 NULL, NULL, objectClassMatch, NULL, NULL,
763                 offsetof(struct slap_internal_schema, si_ad_ditContentRules) },
764         { "matchingRules", "( 2.5.21.4 NAME 'matchingRules' "
765                         "DESC 'RFC4512: matching rules' "
766                         "EQUALITY objectIdentifierFirstComponentMatch "
767                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.30 USAGE directoryOperation )",
768                 subentryAttribute, 0,
769                 oidValidate, NULL,
770                 NULL, NULL, matchingRuleMatch, NULL, NULL,
771                 offsetof(struct slap_internal_schema, si_ad_matchingRules) },
772         { "attributeTypes", "( 2.5.21.5 NAME 'attributeTypes' "
773                         "DESC 'RFC4512: attribute types' "
774                         "EQUALITY objectIdentifierFirstComponentMatch "
775                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.3 USAGE directoryOperation )",
776                 subentryAttribute, 0,
777                 oidValidate, NULL,
778                 NULL, NULL, attributeTypeMatch, NULL, NULL,
779                 offsetof(struct slap_internal_schema, si_ad_attributeTypes) },
780         { "objectClasses", "( 2.5.21.6 NAME 'objectClasses' "
781                         "DESC 'RFC4512: object classes' "
782                         "EQUALITY objectIdentifierFirstComponentMatch "
783                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.37 USAGE directoryOperation )",
784                 subentryAttribute, 0,
785                 oidValidate, NULL,
786                 NULL, NULL, objectClassMatch, NULL, NULL,
787                 offsetof(struct slap_internal_schema, si_ad_objectClasses) },
788         { "nameForms", "( 2.5.21.7 NAME 'nameForms' "
789                         "DESC 'RFC4512: name forms ' "
790                         "EQUALITY objectIdentifierFirstComponentMatch "
791                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.35 USAGE directoryOperation )",
792                 subentryAttribute, SLAP_AT_HIDE,
793                 NULL, NULL,
794                 NULL, NULL, NULL, NULL, NULL,
795                 offsetof(struct slap_internal_schema, si_ad_nameForms) },
796         { "matchingRuleUse", "( 2.5.21.8 NAME 'matchingRuleUse' "
797                         "DESC 'RFC4512: matching rule uses' "
798                         "EQUALITY objectIdentifierFirstComponentMatch "
799                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.31 USAGE directoryOperation )",
800                 subentryAttribute, 0,
801                 oidValidate, NULL,
802                 NULL, NULL, matchingRuleMatch, NULL, NULL,
803                 offsetof(struct slap_internal_schema, si_ad_matchingRuleUse) },
804
805         { "ldapSyntaxes", "( 1.3.6.1.4.1.1466.101.120.16 NAME 'ldapSyntaxes' "
806                         "DESC 'RFC4512: LDAP syntaxes' "
807                         "EQUALITY objectIdentifierFirstComponentMatch "
808                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.54 USAGE directoryOperation )",
809                 subentryAttribute, 0,
810                 NULL, NULL,
811                 NULL, NULL, NULL, NULL, NULL,
812                 offsetof(struct slap_internal_schema, si_ad_ldapSyntaxes) },
813
814         /* knowledge information */
815         { "aliasedObjectName", "( 2.5.4.1 "
816                         "NAME ( 'aliasedObjectName' 'aliasedEntryName' ) "
817                         "DESC 'RFC4512: name of aliased object' "
818                         "EQUALITY distinguishedNameMatch "
819                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )",
820                 aliasAttribute, SLAP_AT_FINAL,
821                 NULL, NULL,
822                 NULL, NULL, NULL, NULL, NULL,
823                 offsetof(struct slap_internal_schema, si_ad_aliasedObjectName) },
824         { "ref", "( 2.16.840.1.113730.3.1.34 NAME 'ref' "
825                         "DESC 'RFC3296: subordinate referral URL' "
826                         "EQUALITY caseExactMatch "
827                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
828                         "USAGE distributedOperation )",
829                 referralAttribute, 0,
830                 NULL, NULL,
831                 NULL, NULL, NULL, NULL, NULL,
832                 offsetof(struct slap_internal_schema, si_ad_ref) },
833
834         /* access control internals */
835         { "entry", "( 1.3.6.1.4.1.4203.1.3.1 "
836                         "NAME 'entry' "
837                         "DESC 'OpenLDAP ACL entry pseudo-attribute' "
838                         "SYNTAX 1.3.6.1.4.1.4203.1.1.1 "
839                         "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
840                 NULL, SLAP_AT_HIDE,
841                 NULL, NULL,
842                 NULL, NULL, NULL, NULL, NULL,
843                 offsetof(struct slap_internal_schema, si_ad_entry) },
844         { "children", "( 1.3.6.1.4.1.4203.1.3.2 "
845                         "NAME 'children' "
846                         "DESC 'OpenLDAP ACL children pseudo-attribute' "
847                         "SYNTAX 1.3.6.1.4.1.4203.1.1.1 "
848                         "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
849                 NULL, SLAP_AT_HIDE,
850                 NULL, NULL,
851                 NULL, NULL, NULL, NULL, NULL,
852                 offsetof(struct slap_internal_schema, si_ad_children) },
853
854         /* access control externals */
855         { "authzTo", "( 1.3.6.1.4.1.4203.666.1.8 "
856                         "NAME ( 'authzTo' 'saslAuthzTo' ) "
857                         "DESC 'proxy authorization targets' "
858                         "EQUALITY authzMatch "
859                         "SYNTAX 1.3.6.1.4.1.4203.666.2.7 "
860                         "X-ORDERED 'VALUES' "
861                         "USAGE distributedOperation )",
862                 NULL, SLAP_AT_HIDE,
863                 NULL, NULL,
864                 NULL, NULL, NULL, NULL, NULL,
865                 offsetof(struct slap_internal_schema, si_ad_saslAuthzTo) },
866         { "authzFrom", "( 1.3.6.1.4.1.4203.666.1.9 "
867                         "NAME ( 'authzFrom' 'saslAuthzFrom' ) "
868                         "DESC 'proxy authorization sources' "
869                         "EQUALITY authzMatch "
870                         "SYNTAX 1.3.6.1.4.1.4203.666.2.7 "
871                         "X-ORDERED 'VALUES' "
872                         "USAGE distributedOperation )",
873                 NULL, SLAP_AT_HIDE,
874                 NULL, NULL,
875                 NULL, NULL, NULL, NULL, NULL,
876                 offsetof(struct slap_internal_schema, si_ad_saslAuthzFrom) },
877
878 #ifdef LDAP_DYNAMIC_OBJECTS
879         { "entryTtl", "( 1.3.6.1.4.1.1466.101.119.3 NAME 'entryTtl' "
880                         "DESC 'RFC2589: entry time-to-live' "
881                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE "
882                         "NO-USER-MODIFICATION USAGE dSAOperation )",
883                 dynamicAttribute, SLAP_AT_MANAGEABLE,
884                 NULL, NULL,
885                 NULL, NULL, NULL, NULL, NULL,
886                 offsetof(struct slap_internal_schema, si_ad_entryTtl) },
887         { "dynamicSubtrees", "( 1.3.6.1.4.1.1466.101.119.4 "
888                         "NAME 'dynamicSubtrees' "
889                         "DESC 'RFC2589: dynamic subtrees' "
890                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 NO-USER-MODIFICATION "
891                         "USAGE dSAOperation )",
892                 rootDseAttribute, 0,
893                 NULL, NULL,
894                 NULL, NULL, NULL, NULL, NULL,
895                 offsetof(struct slap_internal_schema, si_ad_dynamicSubtrees) },
896 #endif
897
898         /* userApplication attributes (which system schema depends upon) */
899         { "distinguishedName", "( 2.5.4.49 NAME 'distinguishedName' "
900                         "DESC 'RFC4519: common supertype of DN attributes' "
901                         "EQUALITY distinguishedNameMatch "
902                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
903                 NULL, SLAP_AT_ABSTRACT,
904                 NULL, NULL,
905                 NULL, NULL, NULL, NULL, NULL,
906                 offsetof(struct slap_internal_schema, si_ad_distinguishedName) },
907         { "name", "( 2.5.4.41 NAME 'name' "
908                         "DESC 'RFC4519: common supertype of name attributes' "
909                         "EQUALITY caseIgnoreMatch "
910                         "SUBSTR caseIgnoreSubstringsMatch "
911                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )",
912                 NULL, SLAP_AT_ABSTRACT,
913                 NULL, NULL,
914                 NULL, NULL, NULL, NULL, NULL,
915                 offsetof(struct slap_internal_schema, si_ad_name) },
916         { "cn", "( 2.5.4.3 NAME ( 'cn' 'commonName' ) "
917                         "DESC 'RFC4519: common name(s) for which the entity is known by' "
918                         "SUP name )",
919                 NULL, 0,
920                 NULL, NULL,
921                 NULL, NULL, NULL, NULL, NULL,
922                 offsetof(struct slap_internal_schema, si_ad_cn) },
923         { "uid", "( 0.9.2342.19200300.100.1.1 NAME ( 'uid' 'userid' ) "
924                         "DESC 'RFC4519: user identifier' "
925                         "EQUALITY caseIgnoreMatch "
926                         "SUBSTR caseIgnoreSubstringsMatch "
927                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} )",
928                 NULL, 0,
929                 NULL, NULL,
930                 NULL, NULL, NULL, NULL, NULL,
931                 offsetof(struct slap_internal_schema, si_ad_uid) },
932         { "uidNumber", /* for ldapi:// */
933                 "( 1.3.6.1.1.1.1.0 NAME 'uidNumber' "
934                 "DESC 'RFC2307: An integer uniquely identifying a user "
935                                 "in an administrative domain' "
936                 "EQUALITY integerMatch "
937                 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )",
938                 NULL, 0,
939                 NULL, NULL,
940                 NULL, NULL, NULL, NULL, NULL,
941                 offsetof(struct slap_internal_schema, si_ad_uidNumber) },
942         { "gidNumber", /* for ldapi:// */
943                 "( 1.3.6.1.1.1.1.1 NAME 'gidNumber' "
944                 "DESC 'RFC2307: An integer uniquely identifying a group "
945                                 "in an administrative domain' "
946                 "EQUALITY integerMatch "
947                 "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )",
948                 NULL, 0,
949                 NULL, NULL,
950                 NULL, NULL, NULL, NULL, NULL,
951                 offsetof(struct slap_internal_schema, si_ad_gidNumber) },
952         { "userPassword", "( 2.5.4.35 NAME 'userPassword' "
953                         "DESC 'RFC4519/2307: password of user' "
954                         "EQUALITY octetStringMatch "
955                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{128} )",
956                 NULL, 0,
957                 NULL, NULL,
958                 NULL, NULL, NULL, NULL, NULL,
959                 offsetof(struct slap_internal_schema, si_ad_userPassword) },
960
961         { "labeledURI", "( 1.3.6.1.4.1.250.1.57 NAME 'labeledURI' "
962                         "DESC 'RFC2079: Uniform Resource Identifier with optional label' "
963                         "EQUALITY caseExactMatch "
964                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
965                 NULL, 0,
966                 NULL, NULL,
967                 NULL, NULL, NULL, NULL, NULL,
968                 offsetof(struct slap_internal_schema, si_ad_labeledURI) },
969
970 #ifdef SLAPD_AUTHPASSWD
971         { "authPassword", "( 1.3.6.1.4.1.4203.1.3.4 "
972                         "NAME 'authPassword' "
973                         "DESC 'RFC3112: authentication password attribute' "
974                         "EQUALITY 1.3.6.1.4.1.4203.1.2.2 "
975                         "SYNTAX 1.3.6.1.4.1.4203.1.1.2 )",
976                 NULL, 0,
977                 NULL, NULL,
978                 NULL, NULL, NULL, NULL, NULL,
979                 offsetof(struct slap_internal_schema, si_ad_authPassword) },
980         { "supportedAuthPasswordSchemes", "( 1.3.6.1.4.1.4203.1.3.3 "
981                         "NAME 'supportedAuthPasswordSchemes' "
982                         "DESC 'RFC3112: supported authPassword schemes' "
983                         "EQUALITY caseExactIA5Match "
984                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{32} "
985                         "USAGE dSAOperation )",
986                 subschemaAttribute, 0,
987                 NULL, NULL,
988                 NULL, NULL, NULL, NULL, NULL,
989                 offsetof(struct slap_internal_schema, si_ad_authPasswordSchemes) },
990 #endif
991
992         { "description", "( 2.5.4.13 NAME 'description' "
993                         "DESC 'RFC4519: descriptive information' "
994                         "EQUALITY caseIgnoreMatch "
995                         "SUBSTR caseIgnoreSubstringsMatch "
996                         "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )",
997                 NULL, 0,
998                 NULL, NULL,
999                 NULL, NULL, NULL, NULL, NULL,
1000                 offsetof(struct slap_internal_schema, si_ad_description) },
1001
1002         { "seeAlso", "( 2.5.4.34 NAME 'seeAlso' "
1003                         "DESC 'RFC4519: DN of related object' "
1004                         "SUP distinguishedName )",
1005                 NULL, 0,
1006                 NULL, NULL,
1007                 NULL, NULL, NULL, NULL, NULL,
1008                 offsetof(struct slap_internal_schema, si_ad_seeAlso) },
1009
1010         { NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 }
1011 };
1012
1013 static AttributeType slap_at_undefined = {
1014         { "1.1.1", NULL, "Catchall for undefined attribute types", 1, NULL,
1015                 NULL, NULL, NULL, NULL,
1016                 0, 0, 0, 1, LDAP_SCHEMA_DSA_OPERATION, NULL }, /* LDAPAttributeType */
1017         BER_BVC("UNDEFINED"), /* cname */
1018         NULL, /* sup */
1019         NULL, /* subtypes */
1020         NULL, NULL, NULL, NULL, /* matching rules routines */
1021         NULL, /* syntax (will be set later to "octetString") */
1022         NULL, /* schema check function */
1023         NULL, /* oidmacro */
1024         NULL, /* soidmacro */
1025         SLAP_AT_ABSTRACT|SLAP_AT_FINAL, /* mask */
1026         { NULL }, /* next */
1027         NULL /* attribute description */
1028         /* mutex (don't know how to initialize it :) */
1029 };
1030
1031 static AttributeType slap_at_proxied = {
1032         { "1.1.1", NULL, "Catchall for undefined proxied attribute types", 1, NULL,
1033                 NULL, NULL, NULL, NULL,
1034                 0, 0, 0, 0, LDAP_SCHEMA_USER_APPLICATIONS, NULL }, /* LDAPAttributeType */
1035         BER_BVC("PROXIED"), /* cname */
1036         NULL, /* sup */
1037         NULL, /* subtypes */
1038         NULL, NULL, NULL, NULL, /* matching rules routines (will be set later) */
1039         NULL, /* syntax (will be set later to "octetString") */
1040         NULL, /* schema check function */
1041         NULL, /* oidmacro */
1042         NULL, /* soidmacro */
1043         SLAP_AT_ABSTRACT|SLAP_AT_FINAL, /* mask */
1044         { NULL }, /* next */
1045         NULL /* attribute description */
1046         /* mutex (don't know how to initialize it :) */
1047 };
1048
1049 static struct slap_schema_mr_map {
1050         char *ssmm_name;
1051         size_t ssmm_offset;
1052 } mr_map[] = {
1053         { "caseExactIA5Match",
1054                 offsetof(struct slap_internal_schema, si_mr_caseExactIA5Match) },
1055         { "caseExactMatch",
1056                 offsetof(struct slap_internal_schema, si_mr_caseExactMatch) },
1057         { "caseExactSubstringsMatch",
1058                 offsetof(struct slap_internal_schema, si_mr_caseExactSubstringsMatch) },
1059         { "distinguishedNameMatch",
1060                 offsetof(struct slap_internal_schema, si_mr_distinguishedNameMatch) },
1061         { "dnSubtreeMatch",
1062                 offsetof(struct slap_internal_schema, si_mr_dnSubtreeMatch) },
1063         { "dnOneLevelMatch",
1064                 offsetof(struct slap_internal_schema, si_mr_dnOneLevelMatch) },
1065         { "dnSubordinateMatch",
1066                 offsetof(struct slap_internal_schema, si_mr_dnSubordinateMatch) },
1067         { "dnSuperiorMatch",
1068                 offsetof(struct slap_internal_schema, si_mr_dnSuperiorMatch) },
1069         { "integerMatch",
1070                 offsetof(struct slap_internal_schema, si_mr_integerMatch) },
1071         { "integerFirstComponentMatch",
1072                 offsetof(struct slap_internal_schema,
1073                         si_mr_integerFirstComponentMatch) },
1074         { "objectIdentifierFirstComponentMatch",
1075                 offsetof(struct slap_internal_schema,
1076                         si_mr_objectIdentifierFirstComponentMatch) },
1077         { "caseIgnoreMatch",
1078                 offsetof(struct slap_internal_schema, si_mr_caseIgnoreMatch) },
1079         { "caseIgnoreListMatch",
1080                 offsetof(struct slap_internal_schema, si_mr_caseIgnoreListMatch) },
1081         { NULL, 0 }
1082 };
1083
1084 static struct slap_schema_syn_map {
1085         char *sssm_name;
1086         size_t sssm_offset;
1087 } syn_map[] = {
1088         { "1.3.6.1.4.1.1466.115.121.1.15",
1089                 offsetof(struct slap_internal_schema, si_syn_directoryString) },
1090         { "1.3.6.1.4.1.1466.115.121.1.12",
1091                 offsetof(struct slap_internal_schema, si_syn_distinguishedName) },
1092         { "1.3.6.1.4.1.1466.115.121.1.27",
1093                 offsetof(struct slap_internal_schema, si_syn_integer) },
1094         { "1.3.6.1.4.1.1466.115.121.1.40",
1095                 offsetof(struct slap_internal_schema, si_syn_octetString) },
1096         { "1.3.6.1.4.1.1466.115.121.1.3",
1097                 offsetof(struct slap_internal_schema, si_syn_attributeTypeDesc) },
1098         { "1.3.6.1.4.1.1466.115.121.1.16",
1099                 offsetof(struct slap_internal_schema, si_syn_ditContentRuleDesc) },
1100         { "1.3.6.1.4.1.1466.115.121.1.54",
1101                 offsetof(struct slap_internal_schema, si_syn_ldapSyntaxDesc) },
1102         { "1.3.6.1.4.1.1466.115.121.1.30",
1103                 offsetof(struct slap_internal_schema, si_syn_matchingRuleDesc) },
1104         { "1.3.6.1.4.1.1466.115.121.1.31",
1105                 offsetof(struct slap_internal_schema, si_syn_matchingRuleUseDesc) },
1106         { "1.3.6.1.4.1.1466.115.121.1.35",
1107                 offsetof(struct slap_internal_schema, si_syn_nameFormDesc) },
1108         { "1.3.6.1.4.1.1466.115.121.1.37",
1109                 offsetof(struct slap_internal_schema, si_syn_objectClassDesc) },
1110         { "1.3.6.1.4.1.1466.115.121.1.17",
1111                 offsetof(struct slap_internal_schema, si_syn_ditStructureRuleDesc) },
1112         { NULL, 0 }
1113 };
1114
1115 int
1116 slap_schema_load( void )
1117 {
1118         int i;
1119
1120         for( i=0; syn_map[i].sssm_name; i++ ) {
1121                 Syntax ** synp = (Syntax **)
1122                         &(((char *) &slap_schema)[syn_map[i].sssm_offset]);
1123
1124                 assert( *synp == NULL );
1125
1126                 *synp = syn_find( syn_map[i].sssm_name );
1127
1128                 if( *synp == NULL ) {
1129                         fprintf( stderr, "slap_schema_load: Syntax: "
1130                                 "No syntax \"%s\" defined in schema\n",
1131                                 syn_map[i].sssm_name );
1132                         return LDAP_INVALID_SYNTAX;
1133                 }
1134         }
1135
1136         for( i=0; mr_map[i].ssmm_name; i++ ) {
1137                 MatchingRule ** mrp = (MatchingRule **)
1138                         &(((char *) &slap_schema)[mr_map[i].ssmm_offset]);
1139
1140                 assert( *mrp == NULL );
1141
1142                 *mrp = mr_find( mr_map[i].ssmm_name );
1143
1144                 if( *mrp == NULL ) {
1145                         fprintf( stderr, "slap_schema_load: MatchingRule: "
1146                                 "No matching rule \"%s\" defined in schema\n",
1147                                 mr_map[i].ssmm_name );
1148                         return LDAP_INAPPROPRIATE_MATCHING;
1149                 }
1150         }
1151
1152         slap_at_undefined.sat_syntax = slap_schema.si_syn_octetString;
1153         slap_schema.si_at_undefined = &slap_at_undefined;
1154
1155         slap_at_proxied.sat_equality = mr_find( "octetStringMatch" );
1156         slap_at_proxied.sat_approx = mr_find( "octetStringMatch" );
1157         slap_at_proxied.sat_ordering = mr_find( "octetStringOrderingMatch" );
1158         slap_at_proxied.sat_substr = mr_find( "octetStringSubstringsMatch" );
1159         slap_at_proxied.sat_syntax = slap_schema.si_syn_octetString;
1160         slap_schema.si_at_proxied = &slap_at_proxied;
1161
1162         ldap_pvt_thread_mutex_init( &ad_undef_mutex );
1163         ldap_pvt_thread_mutex_init( &oc_undef_mutex );
1164
1165         for( i=0; ad_map[i].ssam_name; i++ ) {
1166                 assert( ad_map[i].ssam_defn != NULL );
1167                 {
1168                         LDAPAttributeType *at;
1169                         int             code;
1170                         const char      *err;
1171
1172                         at = ldap_str2attributetype( ad_map[i].ssam_defn,
1173                                 &code, &err, LDAP_SCHEMA_ALLOW_ALL );
1174                         if ( !at ) {
1175                                 fprintf( stderr,
1176                                         "slap_schema_load: AttributeType \"%s\": %s before %s\n",
1177                                          ad_map[i].ssam_name, ldap_scherr2str(code), err );
1178                                 return code;
1179                         }
1180
1181                         if ( at->at_oid == NULL ) {
1182                                 fprintf( stderr, "slap_schema_load: "
1183                                         "AttributeType \"%s\": no OID\n",
1184                                         ad_map[i].ssam_name );
1185                                 ldap_attributetype_free( at );
1186                                 return LDAP_OTHER;
1187                         }
1188
1189                         code = at_add( at, 0, NULL, NULL, &err );
1190                         if ( code ) {
1191                                 ldap_attributetype_free( at );
1192                                 fprintf( stderr, "slap_schema_load: AttributeType "
1193                                         "\"%s\": %s: \"%s\"\n",
1194                                          ad_map[i].ssam_name, scherr2str(code), err );
1195                                 return code;
1196                         }
1197                         ldap_memfree( at );
1198                 }
1199                 {
1200                         int rc;
1201                         const char *text;
1202                         Syntax *syntax = NULL;
1203
1204                         AttributeDescription ** adp = (AttributeDescription **)
1205                                 &(((char *) &slap_schema)[ad_map[i].ssam_offset]);
1206
1207                         assert( *adp == NULL );
1208
1209                         rc = slap_str2ad( ad_map[i].ssam_name, adp, &text );
1210                         if( rc != LDAP_SUCCESS ) {
1211                                 fprintf( stderr, "slap_schema_load: AttributeType \"%s\": "
1212                                         "not defined in schema\n",
1213                                         ad_map[i].ssam_name );
1214                                 return rc;
1215                         }
1216
1217                         if( ad_map[i].ssam_check ) {
1218                                 /* install check routine */
1219                                 (*adp)->ad_type->sat_check = ad_map[i].ssam_check;
1220                         }
1221                         /* install flags */
1222                         (*adp)->ad_type->sat_flags |= ad_map[i].ssam_flags;
1223
1224                         /* install custom syntax routines */
1225                         if( ad_map[i].ssam_syn_validate ||
1226                                 ad_map[i].ssam_syn_pretty )
1227                         {
1228                                 Syntax *syn;
1229
1230                                 syntax = (*adp)->ad_type->sat_syntax;
1231
1232                                 syn = ch_malloc( sizeof( Syntax ) );
1233                                 *syn = *syntax;
1234
1235                                 if( ad_map[i].ssam_syn_validate ) {
1236                                         syn->ssyn_validate = ad_map[i].ssam_syn_validate;
1237                                 }
1238                                 if( ad_map[i].ssam_syn_pretty ) {
1239                                         syn->ssyn_pretty = ad_map[i].ssam_syn_pretty;
1240                                 }
1241
1242                                 (*adp)->ad_type->sat_syntax = syn;
1243                         }
1244
1245                         /* install custom rule routines */
1246                         if( syntax != NULL ||
1247                                 ad_map[i].ssam_mr_convert ||
1248                                 ad_map[i].ssam_mr_normalize ||
1249                                 ad_map[i].ssam_mr_match ||
1250                                 ad_map[i].ssam_mr_indexer ||
1251                                 ad_map[i].ssam_mr_filter )
1252                         {
1253                                 MatchingRule *mr = ch_malloc( sizeof( MatchingRule ) );
1254                                 *mr = *(*adp)->ad_type->sat_equality;
1255
1256                                 if ( syntax != NULL ) {
1257                                         mr->smr_syntax = (*adp)->ad_type->sat_syntax;
1258                                 }
1259                                 if ( ad_map[i].ssam_mr_convert ) {
1260                                         mr->smr_convert = ad_map[i].ssam_mr_convert;
1261                                 }
1262                                 if ( ad_map[i].ssam_mr_normalize ) {
1263                                         mr->smr_normalize = ad_map[i].ssam_mr_normalize;
1264                                 }
1265                                 if ( ad_map[i].ssam_mr_match ) {
1266                                         mr->smr_match = ad_map[i].ssam_mr_match;
1267                                 }
1268                                 if ( ad_map[i].ssam_mr_indexer ) {
1269                                         mr->smr_indexer = ad_map[i].ssam_mr_indexer;
1270                                 }
1271                                 if ( ad_map[i].ssam_mr_filter ) {
1272                                         mr->smr_filter = ad_map[i].ssam_mr_filter;
1273                                 }
1274
1275                                 (*adp)->ad_type->sat_equality = mr;
1276                         }
1277                 }
1278         }
1279
1280         for( i=0; oc_map[i].ssom_name; i++ ) {
1281                 assert( oc_map[i].ssom_defn != NULL );
1282                 {
1283                         LDAPObjectClass *oc;
1284                         int             code;
1285                         const char      *err;
1286
1287                         oc = ldap_str2objectclass( oc_map[i].ssom_defn, &code, &err,
1288                                 LDAP_SCHEMA_ALLOW_ALL );
1289                         if ( !oc ) {
1290                                 fprintf( stderr, "slap_schema_load: ObjectClass "
1291                                         "\"%s\": %s before %s\n",
1292                                         oc_map[i].ssom_name, ldap_scherr2str(code), err );
1293                                 return code;
1294                         }
1295
1296                         if ( oc->oc_oid == NULL ) {
1297                                 fprintf( stderr, "slap_schema_load: ObjectClass "
1298                                         "\"%s\": no OID\n",
1299                                         oc_map[i].ssom_name );
1300                                 ldap_objectclass_free( oc );
1301                                 return LDAP_OTHER;
1302                         }
1303
1304                         code = oc_add(oc,0,NULL,NULL,&err);
1305                         if ( code ) {
1306                                 ldap_objectclass_free( oc );
1307                                 fprintf( stderr, "slap_schema_load: ObjectClass "
1308                                         "\"%s\": %s: \"%s\"\n",
1309                                         oc_map[i].ssom_name, scherr2str(code), err);
1310                                 return code;
1311                         }
1312                         ldap_memfree(oc);
1313
1314                 }
1315                 {
1316                         ObjectClass ** ocp = (ObjectClass **)
1317                                 &(((char *) &slap_schema)[oc_map[i].ssom_offset]);
1318
1319                         assert( *ocp == NULL );
1320
1321                         *ocp = oc_find( oc_map[i].ssom_name );
1322                         if( *ocp == NULL ) {
1323                                 fprintf( stderr, "slap_schema_load: "
1324                                         "ObjectClass \"%s\": not defined in schema\n",
1325                                         oc_map[i].ssom_name );
1326                                 return LDAP_OBJECT_CLASS_VIOLATION;
1327                         }
1328
1329                         if( oc_map[i].ssom_check ) {
1330                                 /* install check routine */
1331                                 (*ocp)->soc_check = oc_map[i].ssom_check;
1332                         }
1333                         /* install flags */
1334                         (*ocp)->soc_flags |= oc_map[i].ssom_flags;
1335                 }
1336         }
1337
1338         return LDAP_SUCCESS;
1339 }
1340
1341 int
1342 slap_schema_check( void )
1343 {
1344         /* we should only be called once after schema_init() was called */
1345         assert( schema_init_done == 1 );
1346
1347         /*
1348          * cycle thru attributeTypes to build matchingRuleUse
1349          */
1350         if ( matching_rule_use_init() ) {
1351                 return LDAP_OTHER;
1352         }
1353
1354         ++schema_init_done;
1355         return LDAP_SUCCESS;
1356 }
1357
1358 static int rootDseObjectClass (
1359         Backend *be,
1360         Entry *e,
1361         ObjectClass *oc,
1362         const char** text,
1363         char *textbuf, size_t textlen )
1364 {
1365         *text = textbuf;
1366
1367         if( e->e_nname.bv_len ) {
1368                 snprintf( textbuf, textlen,
1369                         "objectClass \"%s\" only allowed in the root DSE",
1370                         oc->soc_oid );
1371                 return LDAP_OBJECT_CLASS_VIOLATION;
1372         }
1373
1374         /* we should not be called for the root DSE */
1375         assert( 0 );
1376         return LDAP_SUCCESS;
1377 }
1378
1379 static int aliasObjectClass (
1380         Backend *be,
1381         Entry *e,
1382         ObjectClass *oc,
1383         const char** text,
1384         char *textbuf, size_t textlen )
1385 {
1386         *text = textbuf;
1387
1388         if( !SLAP_ALIASES(be) ) {
1389                 snprintf( textbuf, textlen,
1390                         "objectClass \"%s\" not supported in context",
1391                         oc->soc_oid );
1392                 return LDAP_OBJECT_CLASS_VIOLATION;
1393         }
1394
1395         return LDAP_SUCCESS;
1396 }
1397
1398 static int referralObjectClass (
1399         Backend *be,
1400         Entry *e,
1401         ObjectClass *oc,
1402         const char** text,
1403         char *textbuf, size_t textlen )
1404 {
1405         *text = textbuf;
1406
1407         if( !SLAP_REFERRALS(be) ) {
1408                 snprintf( textbuf, textlen,
1409                         "objectClass \"%s\" not supported in context",
1410                         oc->soc_oid );
1411                 return LDAP_OBJECT_CLASS_VIOLATION;
1412         }
1413
1414         return LDAP_SUCCESS;
1415 }
1416
1417 static int subentryObjectClass (
1418         Backend *be,
1419         Entry *e,
1420         ObjectClass *oc,
1421         const char** text,
1422         char *textbuf, size_t textlen )
1423 {
1424         *text = textbuf;
1425
1426         if( !SLAP_SUBENTRIES(be) ) {
1427                 snprintf( textbuf, textlen,
1428                         "objectClass \"%s\" not supported in context",
1429                         oc->soc_oid );
1430                 return LDAP_OBJECT_CLASS_VIOLATION;
1431         }
1432
1433         if( oc != slap_schema.si_oc_subentry && !is_entry_subentry( e ) ) {
1434                 snprintf( textbuf, textlen,
1435                         "objectClass \"%s\" only allowed in subentries",
1436                         oc->soc_oid );
1437                 return LDAP_OBJECT_CLASS_VIOLATION;
1438         }
1439
1440         return LDAP_SUCCESS;
1441 }
1442
1443 #ifdef LDAP_DYNAMIC_OBJECTS
1444 static int dynamicObjectClass (
1445         Backend *be,
1446         Entry *e,
1447         ObjectClass *oc,
1448         const char** text,
1449         char *textbuf, size_t textlen )
1450 {
1451         *text = textbuf;
1452
1453         if( !SLAP_DYNAMIC(be) ) {
1454                 snprintf( textbuf, textlen,
1455                         "objectClass \"%s\" not supported in context",
1456                         oc->soc_oid );
1457                 return LDAP_OBJECT_CLASS_VIOLATION;
1458         }
1459
1460         return LDAP_SUCCESS;
1461 }
1462 #endif /* LDAP_DYNAMIC_OBJECTS */
1463
1464 static int rootDseAttribute (
1465         Backend *be,
1466         Entry *e,
1467         Attribute *attr,
1468         const char** text,
1469         char *textbuf, size_t textlen )
1470 {
1471         *text = textbuf;
1472
1473         if( e->e_nname.bv_len ) {
1474                 snprintf( textbuf, textlen,
1475                         "attribute \"%s\" only allowed in the root DSE",
1476                         attr->a_desc->ad_cname.bv_val );
1477                 return LDAP_OBJECT_CLASS_VIOLATION;
1478         }
1479
1480         /* we should not be called for the root DSE */
1481         assert( 0 );
1482         return LDAP_SUCCESS;
1483 }
1484
1485 static int aliasAttribute (
1486         Backend *be,
1487         Entry *e,
1488         Attribute *attr,
1489         const char** text,
1490         char *textbuf, size_t textlen )
1491 {
1492         *text = textbuf;
1493
1494         if( !SLAP_ALIASES(be) ) {
1495                 snprintf( textbuf, textlen,
1496                         "attribute \"%s\" not supported in context",
1497                         attr->a_desc->ad_cname.bv_val );
1498                 return LDAP_OBJECT_CLASS_VIOLATION;
1499         }
1500
1501         if( !is_entry_alias( e ) ) {
1502                 snprintf( textbuf, textlen,
1503                         "attribute \"%s\" only allowed in the alias",
1504                         attr->a_desc->ad_cname.bv_val );
1505                 return LDAP_OBJECT_CLASS_VIOLATION;
1506         }
1507
1508         return LDAP_SUCCESS;
1509 }
1510
1511 static int referralAttribute (
1512         Backend *be,
1513         Entry *e,
1514         Attribute *attr,
1515         const char** text,
1516         char *textbuf, size_t textlen )
1517 {
1518         *text = textbuf;
1519
1520         if( !SLAP_REFERRALS(be) ) {
1521                 snprintf( textbuf, textlen,
1522                         "attribute \"%s\" not supported in context",
1523                         attr->a_desc->ad_cname.bv_val );
1524                 return LDAP_OBJECT_CLASS_VIOLATION;
1525         }
1526
1527         if( !is_entry_referral( e ) ) {
1528                 snprintf( textbuf, textlen,
1529                         "attribute \"%s\" only allowed in the referral",
1530                         attr->a_desc->ad_cname.bv_val );
1531                 return LDAP_OBJECT_CLASS_VIOLATION;
1532         }
1533
1534         return LDAP_SUCCESS;
1535 }
1536
1537 static int subentryAttribute (
1538         Backend *be,
1539         Entry *e,
1540         Attribute *attr,
1541         const char** text,
1542         char *textbuf, size_t textlen )
1543 {
1544         *text = textbuf;
1545
1546         if( !SLAP_SUBENTRIES(be) ) {
1547                 snprintf( textbuf, textlen,
1548                         "attribute \"%s\" not supported in context",
1549                         attr->a_desc->ad_cname.bv_val );
1550                 return LDAP_OBJECT_CLASS_VIOLATION;
1551         }
1552
1553         if( !is_entry_subentry( e ) ) {
1554                 snprintf( textbuf, textlen,
1555                         "attribute \"%s\" only allowed in the subentry",
1556                         attr->a_desc->ad_cname.bv_val );
1557                 return LDAP_OBJECT_CLASS_VIOLATION;
1558         }
1559
1560         return LDAP_SUCCESS;
1561 }
1562
1563 static int administrativeRoleAttribute (
1564         Backend *be,
1565         Entry *e,
1566         Attribute *attr,
1567         const char** text,
1568         char *textbuf, size_t textlen )
1569 {
1570         *text = textbuf;
1571
1572         if( !SLAP_SUBENTRIES(be) ) {
1573                 snprintf( textbuf, textlen,
1574                         "attribute \"%s\" not supported in context",
1575                         attr->a_desc->ad_cname.bv_val );
1576                 return LDAP_OBJECT_CLASS_VIOLATION;
1577         }
1578
1579         snprintf( textbuf, textlen,
1580                 "attribute \"%s\" not supported!",
1581                 attr->a_desc->ad_cname.bv_val );
1582         return LDAP_OBJECT_CLASS_VIOLATION;
1583 }
1584
1585 #ifdef LDAP_DYNAMIC_OBJECTS
1586 static int dynamicAttribute (
1587         Backend *be,
1588         Entry *e,
1589         Attribute *attr,
1590         const char** text,
1591         char *textbuf, size_t textlen )
1592 {
1593         *text = textbuf;
1594
1595         if( !SLAP_DYNAMIC(be) ) {
1596                 snprintf( textbuf, textlen,
1597                         "attribute \"%s\" not supported in context",
1598                         attr->a_desc->ad_cname.bv_val );
1599                 return LDAP_OBJECT_CLASS_VIOLATION;
1600         }
1601
1602         if( !is_entry_dynamicObject( e ) ) {
1603                 snprintf( textbuf, textlen,
1604                         "attribute \"%s\" only allowed in dynamic object",
1605                         attr->a_desc->ad_cname.bv_val );
1606                 return LDAP_OBJECT_CLASS_VIOLATION;
1607         }
1608
1609         return LDAP_SUCCESS;
1610 }
1611 #endif /* LDAP_DYNAMIC_OBJECTS */