2000-06-14 03:56:15 +08:00
|
|
|
/* schema.c - routines to manage schema definitions */
|
1999-09-11 06:25:02 +08:00
|
|
|
/* $OpenLDAP$ */
|
1999-08-20 05:32:17 +08:00
|
|
|
/*
|
2000-06-14 03:56:15 +08:00
|
|
|
* Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
|
1999-08-20 05:32:17 +08:00
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "portable.h"
|
1998-08-09 08:43:13 +08:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
1999-08-20 05:32:17 +08:00
|
|
|
#include <ac/ctype.h>
|
|
|
|
#include <ac/string.h>
|
|
|
|
#include <ac/socket.h>
|
|
|
|
|
|
|
|
#include "slap.h"
|
2000-06-14 03:56:15 +08:00
|
|
|
#include "ldap_pvt.h"
|
1998-08-09 08:43:13 +08:00
|
|
|
|
1999-08-20 05:32:17 +08:00
|
|
|
|
|
|
|
#if defined( SLAPD_SCHEMA_DN )
|
|
|
|
|
2000-06-14 03:56:15 +08:00
|
|
|
int
|
|
|
|
schema_info( Entry **entry, const char **text )
|
1999-08-20 05:32:17 +08:00
|
|
|
{
|
2000-06-14 03:56:15 +08:00
|
|
|
AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
|
1999-08-20 05:32:17 +08:00
|
|
|
|
|
|
|
Entry *e;
|
|
|
|
struct berval val;
|
|
|
|
struct berval *vals[2];
|
|
|
|
|
|
|
|
vals[0] = &val;
|
|
|
|
vals[1] = NULL;
|
|
|
|
|
|
|
|
e = (Entry *) ch_calloc( 1, sizeof(Entry) );
|
|
|
|
|
|
|
|
e->e_attrs = NULL;
|
|
|
|
e->e_dn = ch_strdup( SLAPD_SCHEMA_DN );
|
|
|
|
e->e_ndn = ch_strdup( SLAPD_SCHEMA_DN );
|
2000-06-14 03:56:15 +08:00
|
|
|
(void) dn_normalize( e->e_ndn );
|
1999-08-20 05:32:17 +08:00
|
|
|
e->e_private = NULL;
|
|
|
|
|
|
|
|
val.bv_val = "top";
|
|
|
|
val.bv_len = sizeof("top")-1;
|
2000-06-14 03:56:15 +08:00
|
|
|
attr_merge( e, ad_objectClass, vals );
|
1999-08-20 05:32:17 +08:00
|
|
|
|
|
|
|
val.bv_val = "LDAPsubentry";
|
|
|
|
val.bv_len = sizeof("LDAPsubentry")-1;
|
2000-06-14 03:56:15 +08:00
|
|
|
attr_merge( e, ad_objectClass, vals );
|
1999-08-20 05:32:17 +08:00
|
|
|
|
|
|
|
val.bv_val = "subschema";
|
|
|
|
val.bv_len = sizeof("subschema")-1;
|
2000-06-14 03:56:15 +08:00
|
|
|
attr_merge( e, ad_objectClass, vals );
|
1999-08-20 05:32:17 +08:00
|
|
|
|
|
|
|
val.bv_val = "extensibleObject";
|
|
|
|
val.bv_len = sizeof("extensibleObject")-1;
|
2000-06-14 03:56:15 +08:00
|
|
|
attr_merge( e, ad_objectClass, vals );
|
1998-08-09 08:43:13 +08:00
|
|
|
|
2000-06-14 03:56:15 +08:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
AttributeDescription *desc = NULL;
|
|
|
|
char *rdn = ch_strdup( SLAPD_SCHEMA_DN );
|
|
|
|
val.bv_val = strchr( rdn, '=' );
|
1999-08-20 05:32:17 +08:00
|
|
|
|
2000-06-14 03:56:15 +08:00
|
|
|
if( val.bv_val == NULL ) {
|
|
|
|
free( rdn );
|
|
|
|
*text = "improperly configured subschema subentry";
|
|
|
|
return LDAP_OTHER;
|
|
|
|
}
|
1999-08-20 05:32:17 +08:00
|
|
|
|
2000-06-14 03:56:15 +08:00
|
|
|
*val.bv_val = '\0';
|
|
|
|
val.bv_len = strlen( ++val.bv_val );
|
1999-08-20 05:32:17 +08:00
|
|
|
|
2000-06-14 03:56:15 +08:00
|
|
|
rc = slap_str2ad( rdn, &desc, text );
|
1999-08-20 05:32:17 +08:00
|
|
|
|
2000-06-14 03:56:15 +08:00
|
|
|
if( rc != LDAP_SUCCESS ) {
|
|
|
|
free( rdn );
|
|
|
|
entry_free( e );
|
|
|
|
*text = "improperly configured subschema subentry";
|
|
|
|
return LDAP_OTHER;
|
|
|
|
}
|
1999-08-20 05:32:17 +08:00
|
|
|
|
2000-06-14 03:56:15 +08:00
|
|
|
attr_merge( e, desc, vals );
|
|
|
|
free( rdn );
|
1999-08-20 05:32:17 +08:00
|
|
|
}
|
|
|
|
|
2000-06-14 03:56:15 +08:00
|
|
|
if ( syn_schema_info( e )
|
|
|
|
|| mr_schema_info( e )
|
|
|
|
|| at_schema_info( e )
|
|
|
|
|| oc_schema_info( e ) )
|
|
|
|
{
|
|
|
|
/* Out of memory, do something about it */
|
|
|
|
entry_free( e );
|
|
|
|
*text = "out of memory";
|
|
|
|
return LDAP_OTHER;
|
1999-08-20 05:32:17 +08:00
|
|
|
}
|
2000-06-14 03:56:15 +08:00
|
|
|
|
|
|
|
*entry = e;
|
|
|
|
return LDAP_SUCCESS;
|
1999-08-20 05:32:17 +08:00
|
|
|
}
|
2000-06-14 03:56:15 +08:00
|
|
|
#endif
|
|
|
|
|