1 /* schema.c - routines to manage schema definitions */
4 * Copyright 1998-2002 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 vals[5];
33 e = (Entry *) ch_calloc( 1, sizeof(Entry) );
36 /* backend-specific schema info should be created by the
39 ber_dupbv( &e->e_name, &global_schemadn );
40 ber_dupbv( &e->e_nname, &global_schemandn );
43 vals[0].bv_val = "subentry";
44 vals[0].bv_len = sizeof("subentry")-1;
45 attr_merge_one( e, ad_structuralObjectClass, vals );
47 vals[0].bv_val = "top";
48 vals[0].bv_len = sizeof("top")-1;
49 vals[1].bv_val = "subentry";
50 vals[1].bv_len = sizeof("subentry")-1;
51 vals[2].bv_val = "subschema";
52 vals[2].bv_len = sizeof("subschema")-1;
53 vals[3].bv_val = "extensibleObject";
54 vals[3].bv_len = sizeof("extensibleObject")-1;
55 vals[4].bv_val = NULL;
56 attr_merge( e, ad_objectClass, vals );
60 AttributeDescription *desc = NULL;
61 struct berval rdn = global_schemadn;
62 vals[0].bv_val = strchr( rdn.bv_val, '=' );
64 if( vals[0].bv_val == NULL ) {
65 *text = "improperly configured subschema subentry";
70 vals[0].bv_len = rdn.bv_len - (vals[0].bv_val - rdn.bv_val);
71 rdn.bv_len -= vals[0].bv_len + 1;
73 rc = slap_bv2ad( &rdn, &desc, text );
75 if( rc != LDAP_SUCCESS ) {
77 *text = "improperly configured subschema subentry";
81 attr_merge_one( e, desc, vals );
84 if ( syn_schema_info( e )
85 || mr_schema_info( e )
86 || mru_schema_info( e )
87 || at_schema_info( e )
88 || oc_schema_info( e ) )
90 /* Out of memory, do something about it */
92 *text = "out of memory";