]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/schema_prep.c
happy new year
[openldap] / servers / slapd / schema_prep.c
index 9380fd0583fcdfd3a218fe19ff0e28849836c083..ddd08327a3c220e11419387fe27174b2e2a955b8 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2003 The OpenLDAP Foundation.
+ * Copyright 1998-2007 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -23,8 +23,6 @@
 #include <ac/socket.h>
 
 #include "slap.h"
-#include "ldap_pvt.h"
-#include "ldap_pvt_uc.h"
 
 #define OCDEBUG 0
 
@@ -32,20 +30,173 @@ int schema_init_done = 0;
 
 struct slap_internal_schema slap_schema;
 
+static int
+oidValidate(
+       Syntax *syntax,
+       struct berval *in )
+{
+       struct berval val = *in;
+
+       if( val.bv_len == 0 ) {
+               /* disallow empty strings */
+               return LDAP_INVALID_SYNTAX;
+       }
+
+       if( DESC_LEADCHAR( val.bv_val[0] ) ) {
+               val.bv_val++;
+               val.bv_len--;
+               if ( val.bv_len == 0 ) return LDAP_SUCCESS;
+
+               while( DESC_CHAR( val.bv_val[0] ) ) {
+                       val.bv_val++;
+                       val.bv_len--;
+
+                       if ( val.bv_len == 0 ) return LDAP_SUCCESS;
+               }
+
+       } else {
+               int sep = 0;
+               while( OID_LEADCHAR( val.bv_val[0] ) ) {
+                       val.bv_val++;
+                       val.bv_len--;
+
+                       if ( val.bv_val[-1] != '0' ) {
+                               while ( OID_LEADCHAR( val.bv_val[0] )) {
+                                       val.bv_val++;
+                                       val.bv_len--;
+                               }
+                       }
+
+                       if( val.bv_len == 0 ) {
+                               if( sep == 0 ) break;
+                               return LDAP_SUCCESS;
+                       }
+
+                       if( !OID_SEPARATOR( val.bv_val[0] )) break;
+
+                       sep++;
+                       val.bv_val++;
+                       val.bv_len--;
+               }
+       }
+
+       return LDAP_INVALID_SYNTAX;
+}
+
+
 static int objectClassPretty(
        struct slap_syntax *syntax,
        struct berval * in,
        struct berval * out,
        void *ctx )
 {
-       ObjectClass *oc = oc_bvfind( in );
+       ObjectClass *oc;
 
-       if( oc != NULL ) {
-               ber_dupbv_x( out, &oc->soc_cname, ctx );
-       } else {
-               ber_dupbv_x( out, in, ctx );
+       if( oidValidate( NULL, in )) return LDAP_INVALID_SYNTAX;
+
+       oc = oc_bvfind( in );
+       if( oc == NULL ) return LDAP_INVALID_SYNTAX;
+
+       ber_dupbv_x( out, &oc->soc_cname, ctx );
+       return LDAP_SUCCESS;
+}
+
+static int
+attributeTypeMatch(
+       int *matchp,
+       slap_mask_t flags,
+       Syntax *syntax,
+       MatchingRule *mr,
+       struct berval *value,
+       void *assertedValue )
+{
+       struct berval *a = (struct berval *) assertedValue;
+       AttributeType *at = at_bvfind( value );
+       AttributeType *asserted = at_bvfind( a );
+
+       if( asserted == NULL ) {
+               if( OID_LEADCHAR( *a->bv_val ) ) {
+                       /* OID form, return FALSE */
+                       *matchp = 1;
+                       return LDAP_SUCCESS;
+               }
+
+               /* desc form, return undefined */
+               return LDAP_INVALID_SYNTAX;
+       }
+
+       if ( at == NULL ) {
+               /* unrecognized stored value */
+               return LDAP_INVALID_SYNTAX;
+       }
+
+       *matchp = ( asserted != at );
+       return LDAP_SUCCESS;
+}
+
+static int
+matchingRuleMatch(
+       int *matchp,
+       slap_mask_t flags,
+       Syntax *syntax,
+       MatchingRule *mr,
+       struct berval *value,
+       void *assertedValue )
+{
+       struct berval *a = (struct berval *) assertedValue;
+       MatchingRule *mrv = mr_bvfind( value );
+       MatchingRule *asserted = mr_bvfind( a );
+
+       if( asserted == NULL ) {
+               if( OID_LEADCHAR( *a->bv_val ) ) {
+                       /* OID form, return FALSE */
+                       *matchp = 1;
+                       return LDAP_SUCCESS;
+               }
+
+               /* desc form, return undefined */
+               return LDAP_INVALID_SYNTAX;
+       }
+
+       if ( mrv == NULL ) {
+               /* unrecognized stored value */
+               return LDAP_INVALID_SYNTAX;
+       }
+
+       *matchp = ( asserted != mrv );
+       return LDAP_SUCCESS;
+}
+
+static int
+objectClassMatch(
+       int *matchp,
+       slap_mask_t flags,
+       Syntax *syntax,
+       MatchingRule *mr,
+       struct berval *value,
+       void *assertedValue )
+{
+       struct berval *a = (struct berval *) assertedValue;
+       ObjectClass *oc = oc_bvfind( value );
+       ObjectClass *asserted = oc_bvfind( a );
+
+       if( asserted == NULL ) {
+               if( OID_LEADCHAR( *a->bv_val ) ) {
+                       /* OID form, return FALSE */
+                       *matchp = 1;
+                       return LDAP_SUCCESS;
+               }
+
+               /* desc form, return undefined */
+               return LDAP_INVALID_SYNTAX;
+       }
+
+       if ( oc == NULL ) {
+               /* unrecognized stored value */
+               return LDAP_INVALID_SYNTAX;
        }
 
+       *matchp = ( asserted != oc );
        return LDAP_SUCCESS;
 }
 
@@ -70,12 +221,12 @@ objectSubClassMatch(
                }
 
                /* desc form, return undefined */
-               return SLAPD_COMPARE_UNDEFINED;
+               return LDAP_INVALID_SYNTAX;
        }
 
        if ( oc == NULL ) {
                /* unrecognized stored value */
-               return SLAPD_COMPARE_UNDEFINED;
+               return LDAP_INVALID_SYNTAX;
        }
 
        if( SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX( flags ) ) {
@@ -99,31 +250,24 @@ static int objectSubClassIndexer(
 {
        int rc, noc, i;
        BerVarray ocvalues;
+       ObjectClass **socs;
        
        for( noc=0; values[noc].bv_val != NULL; noc++ ) {
                /* just count em */;
        }
 
        /* over allocate */
-       ocvalues = sl_malloc( sizeof( struct berval ) * (noc+16), ctx );
+       socs = slap_sl_malloc( (noc+16) * sizeof( ObjectClass * ), ctx );
 
-       /* copy listed values (and termination) */
+       /* initialize */
        for( i=0; i<noc; i++ ) {
-               ObjectClass *oc = oc_bvfind( &values[i] );
-               if( oc ) {
-                       ocvalues[i] = oc->soc_cname;
-               } else {
-                       ocvalues[i] = values[i];
-               }
+               socs[i] = oc_bvfind( &values[i] );
        }
 
-       ocvalues[i].bv_val = NULL;
-       ocvalues[i].bv_len = 0;
-
        /* expand values */
        for( i=0; i<noc; i++ ) {
                int j;
-               ObjectClass *oc = oc_bvfind( &ocvalues[i] );
+               ObjectClass *oc = socs[i];
                if( oc == NULL || oc->soc_sups == NULL ) continue;
                
                for( j=0; oc->soc_sups[j] != NULL; j++ ) {
@@ -132,35 +276,37 @@ static int objectSubClassIndexer(
                        int k;
 
                        for( k=0; k<noc; k++ ) {
-                               if( bvmatch( &ocvalues[k], &sup->soc_cname ) ) {
+                               if( sup == socs[k] ) {
                                        found++;
                                        break;
                                }
                        }
 
                        if( !found ) {
-                               ocvalues = sl_realloc( ocvalues,
-                                       sizeof( struct berval ) * (noc+2), ctx );
+                               socs = slap_sl_realloc( socs,
+                                       sizeof( ObjectClass * ) * (noc+2), ctx );
 
                                assert( k == noc );
-
-                               ocvalues[noc] = sup->soc_cname;
-
-                               assert( ocvalues[noc].bv_val );
-                               assert( ocvalues[noc].bv_len );
-
-                               noc++;
-
-                               ocvalues[noc].bv_len = 0;
-                               ocvalues[noc].bv_val = NULL;
+                               socs[noc++] = sup;
                        }
                }
        }
 
+       ocvalues = slap_sl_malloc( sizeof( struct berval ) * (noc+1), ctx );
+       /* copy values */
+       for( i=0; i<noc; i++ ) {
+               if ( socs[i] )
+                       ocvalues[i] = socs[i]->soc_cname;
+               else
+                       ocvalues[i] = values[i];
+       }
+       BER_BVZERO( &ocvalues[i] );
+
        rc = octetStringIndexer( use, mask, syntax, mr,
                prefix, ocvalues, keysp, ctx );
 
-       sl_free( ocvalues, ctx );
+       slap_sl_free( ocvalues, ctx );
+       slap_sl_free( socs, ctx );
        return rc;
 }
 
@@ -170,7 +316,9 @@ static ObjectClassSchemaCheckFN rootDseObjectClass;
 static ObjectClassSchemaCheckFN aliasObjectClass;
 static ObjectClassSchemaCheckFN referralObjectClass;
 static ObjectClassSchemaCheckFN subentryObjectClass;
+#ifdef LDAP_DYNAMIC_OBJECTS
 static ObjectClassSchemaCheckFN dynamicObjectClass;
+#endif
 
 static struct slap_schema_oc_map {
        char *ssom_name;
@@ -185,12 +333,12 @@ static struct slap_schema_oc_map {
                0, 0, offsetof(struct slap_internal_schema, si_oc_top) },
        { "extensibleObject", "( 1.3.6.1.4.1.1466.101.120.111 "
                        "NAME 'extensibleObject' "
-                       "DESC 'RFC2252: extensible object' "
+                       "DESC 'RFC4512: extensible object' "
                        "SUP top AUXILIARY )",
                0, SLAP_OC_OPERATIONAL,
                offsetof(struct slap_internal_schema, si_oc_extensibleObject) },
        { "alias", "( 2.5.6.1 NAME 'alias' "
-                       "DESC 'RFC2256: an alias' "
+                       "DESC 'RFC4512: an alias' "
                        "SUP top STRUCTURAL "
                        "MUST aliasedObjectName )",
                aliasObjectClass, SLAP_OC_ALIAS|SLAP_OC_OPERATIONAL,
@@ -207,25 +355,30 @@ static struct slap_schema_oc_map {
                rootDseObjectClass, SLAP_OC_OPERATIONAL,
                offsetof(struct slap_internal_schema, si_oc_rootdse) },
        { "subentry", "( 2.5.17.0 NAME 'subentry' "
+                       "DESC 'RFC3672: subentry' "
                        "SUP top STRUCTURAL "
                        "MUST ( cn $ subtreeSpecification ) )",
                subentryObjectClass, SLAP_OC_SUBENTRY|SLAP_OC_OPERATIONAL,
                offsetof(struct slap_internal_schema, si_oc_subentry) },
        { "subschema", "( 2.5.20.1 NAME 'subschema' "
-               "DESC 'RFC2252: controlling subschema (sub)entry' "
+               "DESC 'RFC4512: controlling subschema (sub)entry' "
                "AUXILIARY "
-               "MAY ( dITStructureRules $ nameForms $ ditContentRules $ "
+               "MAY ( dITStructureRules $ nameForms $ dITContentRules $ "
                        "objectClasses $ attributeTypes $ matchingRules $ "
                        "matchingRuleUse ) )",
                subentryObjectClass, SLAP_OC_OPERATIONAL,
                offsetof(struct slap_internal_schema, si_oc_subschema) },
-#ifdef LDAP_DEVEL
+#ifdef LDAP_COLLECTIVE_ATTRIBUTES
        { "collectiveAttributeSubentry", "( 2.5.17.2 "
                        "NAME 'collectiveAttributeSubentry' "
+                       "DESC 'RFC3671: collective attribute subentry' "
                        "AUXILIARY )",
                subentryObjectClass,
                SLAP_OC_COLLECTIVEATTRIBUTESUBENTRY|SLAP_OC_OPERATIONAL|SLAP_OC_HIDE,
-               offsetof(struct slap_internal_schema, si_oc_collectiveAttributeSubentry) },
+               offsetof( struct slap_internal_schema,
+                       si_oc_collectiveAttributeSubentry) },
+#endif
+#ifdef LDAP_DYNAMIC_OBJECTS
        { "dynamicObject", "( 1.3.6.1.4.1.1466.101.119.2 "
                        "NAME 'dynamicObject' "
                        "DESC 'RFC2589: Dynamic Object' "
@@ -262,7 +415,9 @@ static AttributeTypeSchemaCheckFN aliasAttribute;
 static AttributeTypeSchemaCheckFN referralAttribute;
 static AttributeTypeSchemaCheckFN subentryAttribute;
 static AttributeTypeSchemaCheckFN administrativeRoleAttribute;
+#ifdef LDAP_DYNAMIC_OBJECTS
 static AttributeTypeSchemaCheckFN dynamicAttribute;
+#endif
 
 static struct slap_schema_ad_map {
        char *ssam_name;
@@ -279,61 +434,61 @@ static struct slap_schema_ad_map {
        size_t ssam_offset;
 } ad_map[] = {
        { "objectClass", "( 2.5.4.0 NAME 'objectClass' "
-                       "DESC 'RFC2256: object classes of the entity' "
+                       "DESC 'RFC4512: object classes of the entity' "
                        "EQUALITY objectIdentifierMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
                NULL, SLAP_AT_FINAL,
-               NULL, objectClassPretty,
+               oidValidate, objectClassPretty,
                NULL, NULL, objectSubClassMatch,
                        objectSubClassIndexer, objectSubClassFilter,
                offsetof(struct slap_internal_schema, si_ad_objectClass) },
 
        /* user entry operational attributes */
        { "structuralObjectClass", "( 2.5.21.9 NAME 'structuralObjectClass' "
-                       "DESC 'X.500(93): structural object class of entry' "
+                       "DESC 'RFC4512: structural object class of entry' "
                        "EQUALITY objectIdentifierMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
-               NULL, 0,
-               NULL, objectClassPretty,
+               NULL, SLAP_AT_MANAGEABLE,
+               oidValidate, objectClassPretty,
                NULL, NULL, objectSubClassMatch,
                        objectSubClassIndexer, objectSubClassFilter,
                offsetof(struct slap_internal_schema, si_ad_structuralObjectClass) },
        { "createTimestamp", "( 2.5.18.1 NAME 'createTimestamp' "
-                       "DESC 'RFC2252: time which object was created' "
+                       "DESC 'RFC4512: time which object was created' "
                        "EQUALITY generalizedTimeMatch "
                        "ORDERING generalizedTimeOrderingMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
-               NULL, 0,
+               NULL, SLAP_AT_MANAGEABLE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_createTimestamp) },
        { "modifyTimestamp", "( 2.5.18.2 NAME 'modifyTimestamp' "
-                       "DESC 'RFC2252: time which object was last modified' "
+                       "DESC 'RFC4512: time which object was last modified' "
                        "EQUALITY generalizedTimeMatch "
                        "ORDERING generalizedTimeOrderingMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
-               NULL, 0,
+               NULL, SLAP_AT_MANAGEABLE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_modifyTimestamp) },
        { "creatorsName", "( 2.5.18.3 NAME 'creatorsName' "
-                       "DESC 'RFC2252: name of creator' "
+                       "DESC 'RFC4512: name of creator' "
                        "EQUALITY distinguishedNameMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
-               NULL, 0,
+               NULL, SLAP_AT_MANAGEABLE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_creatorsName) },
        { "modifiersName", "( 2.5.18.4 NAME 'modifiersName' "
-                       "DESC 'RFC2252: name of last modifier' "
+                       "DESC 'RFC4512: name of last modifier' "
                        "EQUALITY distinguishedNameMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
-               NULL, 0,
+               NULL, SLAP_AT_MANAGEABLE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_modifiersName) },
@@ -342,22 +497,23 @@ static struct slap_schema_ad_map {
                        "EQUALITY booleanMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
-               NULL, 0,
+               NULL, SLAP_AT_DYNAMIC,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_hasSubordinates) },
        { "subschemaSubentry", "( 2.5.18.10 NAME 'subschemaSubentry' "
-                       "DESC 'RFC2252: name of controlling subschema entry' "
+                       "DESC 'RFC4512: name of controlling subschema entry' "
                        "EQUALITY distinguishedNameMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE "
                        "NO-USER-MODIFICATION USAGE directoryOperation )",
-               NULL, 0,
+               NULL, SLAP_AT_DYNAMIC,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_subschemaSubentry) },
-#ifdef LDAP_DEVEL
+#ifdef LDAP_COLLECTIVE_ATTRIBUTES
        { "collectiveAttributeSubentries", "( 2.5.18.12 "
                        "NAME 'collectiveAttributeSubentries' "
+                       "DESC 'RFC3671: collective attribute subentries' "
                        "EQUALITY distinguishedNameMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
                        "NO-USER-MODIFICATION USAGE directoryOperation )",
@@ -366,6 +522,7 @@ static struct slap_schema_ad_map {
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_collectiveSubentries) },
        { "collectiveExclusions", "( 2.5.18.7 NAME 'collectiveExclusions' "
+                       "DESC 'RFC3671: collective attribute exclusions' "
                        "EQUALITY objectIdentifierMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
                        "USAGE directoryOperation )",
@@ -375,21 +532,30 @@ static struct slap_schema_ad_map {
                offsetof(struct slap_internal_schema, si_ad_collectiveExclusions) },
 #endif
 
-       { "entryUUID", "( 1.3.6.1.4.1.4203.666.1.6 NAME 'entryUUID' "   
+       { "entryDN", "( 1.3.6.1.4.1.4203.666.1.33 NAME 'entryDN' "   
+                       "DESC 'DN of the entry' "
+                       "EQUALITY distinguishedNameMatch "
+                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
+                       "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
+               NULL, SLAP_AT_HIDE|SLAP_AT_DYNAMIC,
+               NULL, NULL,
+               NULL, NULL, NULL, NULL, NULL,
+               offsetof(struct slap_internal_schema, si_ad_entryDN) },
+       { "entryUUID", "( 1.3.6.1.1.16.4 NAME 'entryUUID' "   
                        "DESC 'UUID of the entry' "
                        "EQUALITY UUIDMatch "
                        "ORDERING UUIDOrderingMatch "
-                       "SYNTAX 1.3.6.1.4.1.4203.666.2.6 "
+                       "SYNTAX 1.3.6.1.1.16.1 "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
-               NULL, SLAP_AT_HIDE,
+               NULL, SLAP_AT_MANAGEABLE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_entryUUID) },
        { "entryCSN", "( 1.3.6.1.4.1.4203.666.1.7 NAME 'entryCSN' "
                        "DESC 'change sequence number of the entry content' "
-                       "EQUALITY octetStringMatch "
-                       "ORDERING octetStringOrderingMatch "
-                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
+                       "EQUALITY CSNMatch "
+                       "ORDERING CSNOrderingMatch "
+                       "SYNTAX 1.3.6.1.4.1.4203.666.11.2.1{64} "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
                NULL, SLAP_AT_HIDE,
                NULL, NULL,
@@ -397,24 +563,27 @@ static struct slap_schema_ad_map {
                offsetof(struct slap_internal_schema, si_ad_entryCSN) },
        { "namingCSN", "( 1.3.6.1.4.1.4203.666.1.13 NAME 'namingCSN' "
                        "DESC 'change sequence number of the entry naming (RDN)' "
-                       "EQUALITY octetStringMatch "
-                       "ORDERING octetStringOrderingMatch "
-                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
+                       "EQUALITY CSNMatch "
+                       "ORDERING CSNOrderingMatch "
+                       "SYNTAX 1.3.6.1.4.1.4203.666.11.2.1{64} "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
                NULL, SLAP_AT_HIDE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_namingCSN) },
 
+#ifdef LDAP_SUPERIOR_UUID
        { "superiorUUID", "( 1.3.6.1.4.1.4203.666.1.11 NAME 'superiorUUID' "   
                        "DESC 'UUID of the superior entry' "
-                       "EQUALITY octetStringMatch "
-                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64} "
+                       "EQUALITY UUIDMatch "
+                       "ORDERING UUIDOrderingMatch "
+                       "SYNTAX 1.3.6.1.1.16.1 "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE directoryOperation )",
                NULL, SLAP_AT_HIDE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_superiorUUID) },
+#endif
 
        { "syncreplCookie", "( 1.3.6.1.4.1.4203.666.1.23 "
                        "NAME 'syncreplCookie' "
@@ -431,16 +600,16 @@ static struct slap_schema_ad_map {
        { "contextCSN", "( 1.3.6.1.4.1.4203.666.1.25 "
                        "NAME 'contextCSN' "
                        "DESC 'the largest committed CSN of a context' "
-                       "EQUALITY octetStringMatch "
-                       "ORDERING octetStringOrderingMatch "
-                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 "
+                       "EQUALITY CSNMatch "
+                       "ORDERING CSNOrderingMatch "
+                       "SYNTAX 1.3.6.1.4.1.4203.666.11.2.1{64} "
                        "SINGLE-VALUE NO-USER-MODIFICATION USAGE dSAOperation )",
                NULL, SLAP_AT_HIDE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_contextCSN) },
 
-#ifdef LDAP_DEVEL
+#ifdef LDAP_SYNC_TIMESTAMP
        { "syncTimestamp", "( 1.3.6.1.4.1.4203.666.1.26 NAME 'syncTimestamp' "
                        "DESC 'Time which object was replicated' "
                        "EQUALITY generalizedTimeMatch "
@@ -455,7 +624,7 @@ static struct slap_schema_ad_map {
 
        /* root DSE attributes */
        { "altServer", "( 1.3.6.1.4.1.1466.101.120.6 NAME 'altServer' "
-                       "DESC 'RFC2252: alternative servers' "
+                       "DESC 'RFC4512: alternative servers' "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 USAGE dSAOperation )",
                rootDseAttribute, 0,
                NULL, NULL,
@@ -463,7 +632,7 @@ static struct slap_schema_ad_map {
                offsetof(struct slap_internal_schema, si_ad_altServer) },
        { "namingContexts", "( 1.3.6.1.4.1.1466.101.120.5 "
                        "NAME 'namingContexts' "
-                       "DESC 'RFC2252: naming contexts' "
+                       "DESC 'RFC4512: naming contexts' "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 USAGE dSAOperation )",
                rootDseAttribute, 0,
                NULL, NULL,
@@ -471,7 +640,7 @@ static struct slap_schema_ad_map {
                offsetof(struct slap_internal_schema, si_ad_namingContexts) },
        { "supportedControl", "( 1.3.6.1.4.1.1466.101.120.13 "
                        "NAME 'supportedControl' "
-                       "DESC 'RFC2252: supported controls' "
+                       "DESC 'RFC4512: supported controls' "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 USAGE dSAOperation )",
                rootDseAttribute, 0,
                NULL, NULL,
@@ -479,7 +648,7 @@ static struct slap_schema_ad_map {
                offsetof(struct slap_internal_schema, si_ad_supportedControl) },
        { "supportedExtension", "( 1.3.6.1.4.1.1466.101.120.7 "
                        "NAME 'supportedExtension' "
-                       "DESC 'RFC2252: supported extended operations' "
+                       "DESC 'RFC4512: supported extended operations' "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 USAGE dSAOperation )",
                rootDseAttribute, 0,
                NULL, NULL,
@@ -487,7 +656,7 @@ static struct slap_schema_ad_map {
                offsetof(struct slap_internal_schema, si_ad_supportedExtension) },
        { "supportedLDAPVersion", "( 1.3.6.1.4.1.1466.101.120.15 "
                        "NAME 'supportedLDAPVersion' "
-                       "DESC 'RFC2252: supported LDAP versions' "
+                       "DESC 'RFC4512: supported LDAP versions' "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 USAGE dSAOperation )",
                rootDseAttribute, 0,
                NULL, NULL,
@@ -495,7 +664,7 @@ static struct slap_schema_ad_map {
                offsetof(struct slap_internal_schema, si_ad_supportedLDAPVersion) },
        { "supportedSASLMechanisms", "( 1.3.6.1.4.1.1466.101.120.14 "
                        "NAME 'supportedSASLMechanisms' "
-                       "DESC 'RFC2252: supported SASL mechanisms'"
+                       "DESC 'RFC4512: supported SASL mechanisms'"
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 USAGE dSAOperation )",
                rootDseAttribute, 0,
                NULL, NULL,
@@ -503,7 +672,7 @@ static struct slap_schema_ad_map {
                offsetof(struct slap_internal_schema, si_ad_supportedSASLMechanisms) },
        { "supportedFeatures", "( 1.3.6.1.4.1.4203.1.3.5 "
                        "NAME 'supportedFeatures' "
-                       "DESC 'features supported by the server' "
+                       "DESC 'RFC4512: features supported by the server' "
                        "EQUALITY objectIdentifierMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 "
                        "USAGE dSAOperation )",
@@ -521,6 +690,16 @@ static struct slap_schema_ad_map {
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_monitorContext) },
+       { "configContext", "( 1.3.6.1.4.1.4203.666.11.1.1 "
+                       "NAME 'configContext' "
+                       "DESC 'config context' "
+                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 "
+                       "SINGLE-VALUE NO-USER-MODIFICATION "
+                       "USAGE dSAOperation )",
+               rootDseAttribute, SLAP_AT_HIDE,
+               NULL, NULL,
+               NULL, NULL, NULL, NULL, NULL,
+               offsetof(struct slap_internal_schema, si_ad_configContext) },
        { "vendorName", "( 1.3.6.1.1.4 NAME 'vendorName' "
                        "DESC 'RFC3045: name of implementation vendor' "
                        "EQUALITY caseExactMatch "
@@ -544,6 +723,7 @@ static struct slap_schema_ad_map {
 
        /* subentry attributes */
        { "administrativeRole", "( 2.5.18.5 NAME 'administrativeRole' "
+                       "DESC 'RFC3672: administrative role' "
                        "EQUALITY objectIdentifierMatch "
                        "USAGE directoryOperation "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.38 )",
@@ -552,6 +732,7 @@ static struct slap_schema_ad_map {
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_administrativeRole) },
        { "subtreeSpecification", "( 2.5.18.6 NAME 'subtreeSpecification' "
+                       "DESC 'RFC3672: subtree specification' "
                        "SINGLE-VALUE "
                        "USAGE directoryOperation "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.45 )",
@@ -561,8 +742,8 @@ static struct slap_schema_ad_map {
                offsetof(struct slap_internal_schema, si_ad_subtreeSpecification) },
 
        /* subschema subentry attributes */
-       { "ditStructureRules", "( 2.5.21.1 NAME 'dITStructureRules' "
-                       "DESC 'RFC2252: DIT structure rules' "
+       { "dITStructureRules", "( 2.5.21.1 NAME 'dITStructureRules' "
+                       "DESC 'RFC4512: DIT structure rules' "
                        "EQUALITY integerFirstComponentMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.17 "
                        "USAGE directoryOperation ) ",
@@ -570,40 +751,40 @@ static struct slap_schema_ad_map {
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_ditStructureRules) },
-       { "ditContentRules", "( 2.5.21.2 NAME 'dITContentRules' "
-                       "DESC 'RFC2252: DIT content rules' "
+       { "dITContentRules", "( 2.5.21.2 NAME 'dITContentRules' "
+                       "DESC 'RFC4512: DIT content rules' "
                        "EQUALITY objectIdentifierFirstComponentMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.16 USAGE directoryOperation )",
                subentryAttribute, SLAP_AT_HIDE,
-               NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL,
+               oidValidate, NULL,
+               NULL, NULL, objectClassMatch, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_ditContentRules) },
        { "matchingRules", "( 2.5.21.4 NAME 'matchingRules' "
-                       "DESC 'RFC2252: matching rules' "
+                       "DESC 'RFC4512: matching rules' "
                        "EQUALITY objectIdentifierFirstComponentMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.30 USAGE directoryOperation )",
                subentryAttribute, 0,
-               NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL,
+               oidValidate, NULL,
+               NULL, NULL, matchingRuleMatch, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_matchingRules) },
        { "attributeTypes", "( 2.5.21.5 NAME 'attributeTypes' "
-                       "DESC 'RFC2252: attribute types' "
+                       "DESC 'RFC4512: attribute types' "
                        "EQUALITY objectIdentifierFirstComponentMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.3 USAGE directoryOperation )",
                subentryAttribute, 0,
-               NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL,
+               oidValidate, NULL,
+               NULL, NULL, attributeTypeMatch, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_attributeTypes) },
        { "objectClasses", "( 2.5.21.6 NAME 'objectClasses' "
-                       "DESC 'RFC2252: object classes' "
+                       "DESC 'RFC4512: object classes' "
                        "EQUALITY objectIdentifierFirstComponentMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.37 USAGE directoryOperation )",
                subentryAttribute, 0,
-               NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL,
+               oidValidate, NULL,
+               NULL, NULL, objectClassMatch, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_objectClasses) },
        { "nameForms", "( 2.5.21.7 NAME 'nameForms' "
-                       "DESC 'RFC2252: name forms ' "
+                       "DESC 'RFC4512: name forms ' "
                        "EQUALITY objectIdentifierFirstComponentMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.35 USAGE directoryOperation )",
                subentryAttribute, SLAP_AT_HIDE,
@@ -611,16 +792,16 @@ static struct slap_schema_ad_map {
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_nameForms) },
        { "matchingRuleUse", "( 2.5.21.8 NAME 'matchingRuleUse' "
-                       "DESC 'RFC2252: matching rule uses' "
+                       "DESC 'RFC4512: matching rule uses' "
                        "EQUALITY objectIdentifierFirstComponentMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.31 USAGE directoryOperation )",
                subentryAttribute, 0,
-               NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL,
+               oidValidate, NULL,
+               NULL, NULL, matchingRuleMatch, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_matchingRuleUse) },
 
        { "ldapSyntaxes", "( 1.3.6.1.4.1.1466.101.120.16 NAME 'ldapSyntaxes' "
-                       "DESC 'RFC2252: LDAP syntaxes' "
+                       "DESC 'RFC4512: LDAP syntaxes' "
                        "EQUALITY objectIdentifierFirstComponentMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.54 USAGE directoryOperation )",
                subentryAttribute, 0,
@@ -631,7 +812,7 @@ static struct slap_schema_ad_map {
        /* knowledge information */
        { "aliasedObjectName", "( 2.5.4.1 "
                        "NAME ( 'aliasedObjectName' 'aliasedEntryName' ) "
-                       "DESC 'RFC2256: name of aliased object' "
+                       "DESC 'RFC4512: name of aliased object' "
                        "EQUALITY distinguishedNameMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )",
                aliasAttribute, SLAP_AT_FINAL,
@@ -639,7 +820,7 @@ static struct slap_schema_ad_map {
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_aliasedObjectName) },
        { "ref", "( 2.16.840.1.113730.3.1.34 NAME 'ref' "
-                       "DESC 'namedref: subordinate referral URL' "
+                       "DESC 'RFC3296: subordinate referral URL' "
                        "EQUALITY caseExactMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
                        "USAGE distributedOperation )",
@@ -667,45 +848,37 @@ static struct slap_schema_ad_map {
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_children) },
-       { "saslAuthzTo", "( 1.3.6.1.4.1.4203.666.1.8 "
-                       "NAME 'saslAuthzTo' "
-                       "DESC 'SASL proxy authorization targets' "
-                       "EQUALITY caseExactMatch "
-                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
+
+       /* access control externals */
+       { "authzTo", "( 1.3.6.1.4.1.4203.666.1.8 "
+                       "NAME ( 'authzTo' 'saslAuthzTo' ) "
+                       "DESC 'proxy authorization targets' "
+                       "EQUALITY authzMatch "
+                       "SYNTAX 1.3.6.1.4.1.4203.666.2.7 "
+                       "X-ORDERED 'VALUES' "
                        "USAGE distributedOperation )",
                NULL, SLAP_AT_HIDE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_saslAuthzTo) },
-       { "saslAuthzFrom", "( 1.3.6.1.4.1.4203.666.1.9 "
-                       "NAME 'saslAuthzFrom' "
-                       "DESC 'SASL proxy authorization sources' "
-                       "EQUALITY caseExactMatch "
-                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 "
+       { "authzFrom", "( 1.3.6.1.4.1.4203.666.1.9 "
+                       "NAME ( 'authzFrom' 'saslAuthzFrom' ) "
+                       "DESC 'proxy authorization sources' "
+                       "EQUALITY authzMatch "
+                       "SYNTAX 1.3.6.1.4.1.4203.666.2.7 "
+                       "X-ORDERED 'VALUES' "
                        "USAGE distributedOperation )",
                NULL, SLAP_AT_HIDE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_saslAuthzFrom) },
-#ifdef SLAPD_ACI_ENABLED
-       { "OpenLDAPaci", "( 1.3.6.1.4.1.4203.666.1.5 "
-                       "NAME 'OpenLDAPaci' "
-                       "DESC 'OpenLDAP access control information (experimental)' "
-                       "EQUALITY OpenLDAPaciMatch "
-                       "SYNTAX 1.3.6.1.4.1.4203.666.2.1 "
-                       "USAGE directoryOperation )",
-               NULL, SLAP_AT_HIDE,
-               NULL, NULL,
-               NULL, NULL, NULL, NULL, NULL,
-               offsetof(struct slap_internal_schema, si_ad_aci) },
-#endif
 
-#ifdef LDAP_DEVEL
+#ifdef LDAP_DYNAMIC_OBJECTS
        { "entryTtl", "( 1.3.6.1.4.1.1466.101.119.3 NAME 'entryTtl' "
                        "DESC 'RFC2589: entry time-to-live' "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE "
                        "NO-USER-MODIFICATION USAGE dSAOperation )",
-               dynamicAttribute, 0,
+               dynamicAttribute, SLAP_AT_MANAGEABLE,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_entryTtl) },
@@ -722,7 +895,7 @@ static struct slap_schema_ad_map {
 
        /* userApplication attributes (which system schema depends upon) */
        { "distinguishedName", "( 2.5.4.49 NAME 'distinguishedName' "
-                       "DESC 'RFC2256: common supertype of DN attributes' "
+                       "DESC 'RFC4519: common supertype of DN attributes' "
                        "EQUALITY distinguishedNameMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 )",
                NULL, SLAP_AT_ABSTRACT,
@@ -730,7 +903,7 @@ static struct slap_schema_ad_map {
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_distinguishedName) },
        { "name", "( 2.5.4.41 NAME 'name' "
-                       "DESC 'RFC2256: common supertype of name attributes' "
+                       "DESC 'RFC4519: common supertype of name attributes' "
                        "EQUALITY caseIgnoreMatch "
                        "SUBSTR caseIgnoreSubstringsMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )",
@@ -739,14 +912,43 @@ static struct slap_schema_ad_map {
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_name) },
        { "cn", "( 2.5.4.3 NAME ( 'cn' 'commonName' ) "
-                       "DESC 'RFC2256: common name(s) for which the entity is known by' "
+                       "DESC 'RFC4519: common name(s) for which the entity is known by' "
                        "SUP name )",
                NULL, 0,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_cn) },
+       { "uid", "( 0.9.2342.19200300.100.1.1 NAME ( 'uid' 'userid' ) "
+                       "DESC 'RFC4519: user identifier' "
+                       "EQUALITY caseIgnoreMatch "
+                       "SUBSTR caseIgnoreSubstringsMatch "
+                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} )",
+               NULL, 0,
+               NULL, NULL,
+               NULL, NULL, NULL, NULL, NULL,
+               offsetof(struct slap_internal_schema, si_ad_uid) },
+       { "uidNumber", /* for ldapi:// */
+               "( 1.3.6.1.1.1.1.0 NAME 'uidNumber' "
+               "DESC 'RFC2307: An integer uniquely identifying a user "
+                               "in an administrative domain' "
+               "EQUALITY integerMatch "
+               "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )",
+               NULL, 0,
+               NULL, NULL,
+               NULL, NULL, NULL, NULL, NULL,
+               offsetof(struct slap_internal_schema, si_ad_uidNumber) },
+       { "gidNumber", /* for ldapi:// */
+               "( 1.3.6.1.1.1.1.1 NAME 'gidNumber' "
+               "DESC 'RFC2307: An integer uniquely identifying a group "
+                               "in an administrative domain' "
+               "EQUALITY integerMatch "
+               "SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )",
+               NULL, 0,
+               NULL, NULL,
+               NULL, NULL, NULL, NULL, NULL,
+               offsetof(struct slap_internal_schema, si_ad_gidNumber) },
        { "userPassword", "( 2.5.4.35 NAME 'userPassword' "
-                       "DESC 'RFC2256/2307: password of user' "
+                       "DESC 'RFC4519/2307: password of user' "
                        "EQUALITY octetStringMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{128} )",
                NULL, 0,
@@ -754,7 +956,7 @@ static struct slap_schema_ad_map {
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_userPassword) },
 
-       { "labeledURI", "(  1.3.6.1.4.1.250.1.57 NAME 'labeledURI' "
+       { "labeledURI", "( 1.3.6.1.4.1.250.1.57 NAME 'labeledURI' "
                        "DESC 'RFC2079: Uniform Resource Identifier with optional label' "
                        "EQUALITY caseExactMatch "
                        "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )",
@@ -782,7 +984,7 @@ static struct slap_schema_ad_map {
                subschemaAttribute, 0,
                NULL, NULL,
                NULL, NULL, NULL, NULL, NULL,
-               offsetof(struct slap_internal_schema, si_ad_authPassword) },
+               offsetof(struct slap_internal_schema, si_ad_authPasswordSchemes) },
 #endif
 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
        { "krbName", "( 1.3.6.1.4.1.250.1.32 "
@@ -796,19 +998,56 @@ static struct slap_schema_ad_map {
                NULL, NULL, NULL, NULL, NULL,
                offsetof(struct slap_internal_schema, si_ad_krbName) },
 #endif
+
+       { "description", "( 2.5.4.13 NAME 'description' "
+                       "DESC 'RFC4519: descriptive information' "
+                       "EQUALITY caseIgnoreMatch "
+                       "SUBSTR caseIgnoreSubstringsMatch "
+                       "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} )",
+               NULL, 0,
+               NULL, NULL,
+               NULL, NULL, NULL, NULL, NULL,
+               offsetof(struct slap_internal_schema, si_ad_description) },
+
+       { "seeAlso", "( 2.5.4.34 NAME 'seeAlso' "
+                       "DESC 'RFC4519: DN of related object' "
+                       "SUP distinguishedName )",
+               NULL, 0,
+               NULL, NULL,
+               NULL, NULL, NULL, NULL, NULL,
+               offsetof(struct slap_internal_schema, si_ad_seeAlso) },
+
        { NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0 }
 };
 
 static AttributeType slap_at_undefined = {
-       { "1.1.1", NULL, NULL, 1, NULL,
+       { "1.1.1", NULL, "Catchall for undefined attribute types", 1, NULL,
                NULL, NULL, NULL, NULL,
-               0, 0, 0, 1, 3, NULL }, /* LDAPAttributeType */
-       { sizeof("UNDEFINED")-1, "UNDEFINED" }, /* cname */
+               0, 0, 0, 1, LDAP_SCHEMA_DSA_OPERATION, NULL }, /* LDAPAttributeType */
+       BER_BVC("UNDEFINED"), /* cname */
        NULL, /* sup */
        NULL, /* subtypes */
        NULL, NULL, NULL, NULL, /* matching rules routines */
-       NULL, /* syntax (this may need to be defined) */
-       (AttributeTypeSchemaCheckFN *) 0, /* schema check function */
+       NULL, /* syntax (will be set later to "octetString") */
+       NULL, /* schema check function */
+       NULL, /* oidmacro */
+       SLAP_AT_ABSTRACT|SLAP_AT_FINAL, /* mask */
+       { NULL }, /* next */
+       NULL /* attribute description */
+       /* mutex (don't know how to initialize it :) */
+};
+
+static AttributeType slap_at_proxied = {
+       { "1.1.1", NULL, "Catchall for undefined proxied attribute types", 1, NULL,
+               NULL, NULL, NULL, NULL,
+               0, 0, 0, 0, LDAP_SCHEMA_USER_APPLICATIONS, NULL }, /* LDAPAttributeType */
+       BER_BVC("PROXIED"), /* cname */
+       NULL, /* sup */
+       NULL, /* subtypes */
+       NULL, NULL, NULL, NULL, /* matching rules routines (will be set later) */
+       NULL, /* syntax (will be set later to "octetString") */
+       NULL, /* schema check function */
+       NULL, /* oidmacro */
        SLAP_AT_ABSTRACT|SLAP_AT_FINAL, /* mask */
        { NULL }, /* next */
        NULL /* attribute description */
@@ -827,6 +1066,14 @@ static struct slap_schema_mr_map {
                offsetof(struct slap_internal_schema, si_mr_caseExactSubstringsMatch) },
        { "distinguishedNameMatch",
                offsetof(struct slap_internal_schema, si_mr_distinguishedNameMatch) },
+       { "dnSubtreeMatch",
+               offsetof(struct slap_internal_schema, si_mr_dnSubtreeMatch) },
+       { "dnOneLevelMatch",
+               offsetof(struct slap_internal_schema, si_mr_dnOneLevelMatch) },
+       { "dnSubordinateMatch",
+               offsetof(struct slap_internal_schema, si_mr_dnSubordinateMatch) },
+       { "dnSuperiorMatch",
+               offsetof(struct slap_internal_schema, si_mr_dnSuperiorMatch) },
        { "integerMatch",
                offsetof(struct slap_internal_schema, si_mr_integerMatch) },
        { "integerFirstComponentMatch",
@@ -850,6 +1097,22 @@ static struct slap_schema_syn_map {
                offsetof(struct slap_internal_schema, si_syn_integer) },
        { "1.3.6.1.4.1.1466.115.121.1.40",
                offsetof(struct slap_internal_schema, si_syn_octetString) },
+       { "1.3.6.1.4.1.1466.115.121.1.3",
+               offsetof(struct slap_internal_schema, si_syn_attributeTypeDesc) },
+       { "1.3.6.1.4.1.1466.115.121.1.16",
+               offsetof(struct slap_internal_schema, si_syn_ditContentRuleDesc) },
+       { "1.3.6.1.4.1.1466.115.121.1.54",
+               offsetof(struct slap_internal_schema, si_syn_ldapSyntaxDesc) },
+       { "1.3.6.1.4.1.1466.115.121.1.30",
+               offsetof(struct slap_internal_schema, si_syn_matchingRuleDesc) },
+       { "1.3.6.1.4.1.1466.115.121.1.31",
+               offsetof(struct slap_internal_schema, si_syn_matchingRuleUseDesc) },
+       { "1.3.6.1.4.1.1466.115.121.1.35",
+               offsetof(struct slap_internal_schema, si_syn_nameFormDesc) },
+       { "1.3.6.1.4.1.1466.115.121.1.37",
+               offsetof(struct slap_internal_schema, si_syn_objectClassDesc) },
+       { "1.3.6.1.4.1.1466.115.121.1.17",
+               offsetof(struct slap_internal_schema, si_syn_ditStructureRuleDesc) },
        { NULL, 0 }
 };
 
@@ -890,6 +1153,19 @@ slap_schema_load( void )
                }
        }
 
+       slap_at_undefined.sat_syntax = slap_schema.si_syn_octetString;
+       slap_schema.si_at_undefined = &slap_at_undefined;
+
+       slap_at_proxied.sat_equality = mr_find( "octetStringMatch" );
+       slap_at_proxied.sat_approx = mr_find( "octetStringMatch" );
+       slap_at_proxied.sat_ordering = mr_find( "octetStringOrderingMatch" );
+       slap_at_proxied.sat_substr = mr_find( "octetStringSubstringsMatch" );
+       slap_at_proxied.sat_syntax = slap_schema.si_syn_octetString;
+       slap_schema.si_at_proxied = &slap_at_proxied;
+
+       ldap_pvt_thread_mutex_init( &ad_undef_mutex );
+       ldap_pvt_thread_mutex_init( &oc_undef_mutex );
+
        for( i=0; ad_map[i].ssam_name; i++ ) {
                assert( ad_map[i].ssam_defn != NULL );
                {
@@ -910,11 +1186,13 @@ slap_schema_load( void )
                                fprintf( stderr, "slap_schema_load: "
                                        "AttributeType \"%s\": no OID\n",
                                        ad_map[i].ssam_name );
+                               ldap_attributetype_free( at );
                                return LDAP_OTHER;
                        }
 
-                       code = at_add( at, &err );
+                       code = at_add( at, 0, NULL, NULL, &err );
                        if ( code ) {
+                               ldap_attributetype_free( at );
                                fprintf( stderr, "slap_schema_load: AttributeType "
                                        "\"%s\": %s: \"%s\"\n",
                                         ad_map[i].ssam_name, scherr2str(code), err );
@@ -969,8 +1247,7 @@ slap_schema_load( void )
                        }
 
                        /* install custom rule routines */
-                       if( ( (*adp)->ad_type->sat_equality != NULL &&
-                                       syntax == (*adp)->ad_type->sat_equality->smr_syntax ) ||
+                       if( syntax != NULL ||
                                ad_map[i].ssam_mr_convert ||
                                ad_map[i].ssam_mr_normalize ||
                                ad_map[i].ssam_mr_match ||
@@ -980,7 +1257,7 @@ slap_schema_load( void )
                                MatchingRule *mr = ch_malloc( sizeof( MatchingRule ) );
                                *mr = *(*adp)->ad_type->sat_equality;
 
-                               if ( syntax == mr->smr_syntax ) {
+                               if ( syntax != NULL ) {
                                        mr->smr_syntax = (*adp)->ad_type->sat_syntax;
                                }
                                if ( ad_map[i].ssam_mr_convert ) {
@@ -999,6 +1276,7 @@ slap_schema_load( void )
                                        mr->smr_filter = ad_map[i].ssam_mr_filter;
                                }
 
+                               /* FIXME: no-one will free this at exit */
                                (*adp)->ad_type->sat_equality = mr;
                        }
                }
@@ -1024,18 +1302,20 @@ slap_schema_load( void )
                                fprintf( stderr, "slap_schema_load: ObjectClass "
                                        "\"%s\": no OID\n",
                                        oc_map[i].ssom_name );
+                               ldap_objectclass_free( oc );
                                return LDAP_OTHER;
                        }
 
-                       code = oc_add(oc,0,&err);
+                       code = oc_add(oc,0,NULL,NULL,&err);
                        if ( code ) {
+                               ldap_objectclass_free( oc );
                                fprintf( stderr, "slap_schema_load: ObjectClass "
                                        "\"%s\": %s: \"%s\"\n",
                                        oc_map[i].ssom_name, scherr2str(code), err);
                                return code;
                        }
-
                        ldap_memfree(oc);
+
                }
                {
                        ObjectClass ** ocp = (ObjectClass **)
@@ -1060,9 +1340,6 @@ slap_schema_load( void )
                }
        }
 
-       slap_at_undefined.sat_syntax = slap_schema.si_syn_distinguishedName;
-       slap_schema.si_at_undefined = &slap_at_undefined;
-
        return LDAP_SUCCESS;
 }
 
@@ -1168,6 +1445,7 @@ static int subentryObjectClass (
        return LDAP_SUCCESS;
 }
 
+#ifdef LDAP_DYNAMIC_OBJECTS
 static int dynamicObjectClass (
        Backend *be,
        Entry *e,
@@ -1186,6 +1464,7 @@ static int dynamicObjectClass (
 
        return LDAP_SUCCESS;
 }
+#endif /* LDAP_DYNAMIC_OBJECTS */
 
 static int rootDseAttribute (
        Backend *be,
@@ -1308,6 +1587,7 @@ static int administrativeRoleAttribute (
        return LDAP_OBJECT_CLASS_VIOLATION;
 }
 
+#ifdef LDAP_DYNAMIC_OBJECTS
 static int dynamicAttribute (
        Backend *be,
        Entry *e,
@@ -1333,3 +1613,4 @@ static int dynamicAttribute (
 
        return LDAP_SUCCESS;
 }
+#endif /* LDAP_DYNAMIC_OBJECTS */