1 /* schema.c - routines to manage schema definitions */
4 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
5 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
13 #include <ac/string.h>
14 #include <ac/socket.h>
20 #if defined( SLAPD_SCHEMA_DN )
23 schema_info( Entry **entry, const char **text )
25 AttributeDescription *ad_structuralObjectClass
26 = slap_schema.si_ad_structuralObjectClass;
27 AttributeDescription *ad_objectClass
28 = slap_schema.si_ad_objectClass;
31 struct berval val, *ndn = NULL;
32 struct berval *vals[2];
37 e = (Entry *) ch_calloc( 1, sizeof(Entry) );
40 ber_str2bv( SLAPD_SCHEMA_DN, sizeof(SLAPD_SCHEMA_DN)-1, 1, &e->e_name);
41 (void) dnNormalize( NULL, &e->e_name, &ndn );
46 val.bv_val = "LDAPsubentry";
47 val.bv_len = sizeof("LDAPsubentry")-1;
48 attr_merge( e, ad_structuralObjectClass, vals );
51 val.bv_len = sizeof("top")-1;
52 attr_merge( e, ad_objectClass, vals );
54 val.bv_val = "LDAPsubentry";
55 val.bv_len = sizeof("LDAPsubentry")-1;
56 attr_merge( e, ad_objectClass, vals );
58 val.bv_val = "subschema";
59 val.bv_len = sizeof("subschema")-1;
60 attr_merge( e, ad_objectClass, vals );
62 val.bv_val = "extensibleObject";
63 val.bv_len = sizeof("extensibleObject")-1;
64 attr_merge( e, ad_objectClass, vals );
68 AttributeDescription *desc = NULL;
69 struct berval rdn = { sizeof(SLAPD_SCHEMA_DN)-1,
71 val.bv_val = strchr( rdn.bv_val, '=' );
73 if( val.bv_val == NULL ) {
74 *text = "improperly configured subschema subentry";
79 val.bv_len = rdn.bv_len - (val.bv_val - rdn.bv_val);
80 rdn.bv_len -= val.bv_len + 1;
82 rc = slap_bv2ad( &rdn, &desc, text );
84 if( rc != LDAP_SUCCESS ) {
86 *text = "improperly configured subschema subentry";
90 attr_merge( e, desc, vals );
93 if ( syn_schema_info( e )
94 || mr_schema_info( e )
95 || at_schema_info( e )
96 || oc_schema_info( e ) )
98 /* Out of memory, do something about it */
100 *text = "out of memory";