Patch slapadd(8) to provide a structuralObjectClass if missing

from input.  This likely needs to be done by the frontend instead.
Add structuralObjectClass to the root and subschema dses.
This commit is contained in:
Kurt Zeilenga 2001-12-19 22:41:00 +00:00
parent 49d16c4dce
commit 948925a683
4 changed files with 71 additions and 14 deletions

View File

@ -39,14 +39,24 @@ root_dse_info(
int i, j;
char ** supportedSASLMechanisms;
AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
AttributeDescription *ad_namingContexts = slap_schema.si_ad_namingContexts;
AttributeDescription *ad_supportedControl = slap_schema.si_ad_supportedControl;
AttributeDescription *ad_supportedExtension = slap_schema.si_ad_supportedExtension;
AttributeDescription *ad_supportedLDAPVersion = slap_schema.si_ad_supportedLDAPVersion;
AttributeDescription *ad_supportedSASLMechanisms = slap_schema.si_ad_supportedSASLMechanisms;
AttributeDescription *ad_supportedFeatures = slap_schema.si_ad_supportedFeatures;
AttributeDescription *ad_ref = slap_schema.si_ad_ref;
AttributeDescription *ad_structuralObjectClass
= slap_schema.si_ad_structuralObjectClass;
AttributeDescription *ad_objectClass
= slap_schema.si_ad_objectClass;
AttributeDescription *ad_namingContexts
= slap_schema.si_ad_namingContexts;
AttributeDescription *ad_supportedControl
= slap_schema.si_ad_supportedControl;
AttributeDescription *ad_supportedExtension
= slap_schema.si_ad_supportedExtension;
AttributeDescription *ad_supportedLDAPVersion
= slap_schema.si_ad_supportedLDAPVersion;
AttributeDescription *ad_supportedSASLMechanisms
= slap_schema.si_ad_supportedSASLMechanisms;
AttributeDescription *ad_supportedFeatures
= slap_schema.si_ad_supportedFeatures;
AttributeDescription *ad_ref
= slap_schema.si_ad_ref;
Attribute *a;
@ -61,6 +71,10 @@ root_dse_info(
(void) dn_normalize( e->e_ndn );
e->e_private = NULL;
val.bv_val = "OpenLDAProotDSE";
val.bv_len = sizeof("OpenLDAProotDSE")-1;
attr_merge( e, ad_structuralObjectClass, vals );
val.bv_val = "top";
val.bv_len = sizeof("top")-1;
attr_merge( e, ad_objectClass, vals );

View File

@ -22,7 +22,10 @@
int
schema_info( Entry **entry, const char **text )
{
AttributeDescription *ad_objectClass = slap_schema.si_ad_objectClass;
AttributeDescription *ad_structuralObjectClass
= slap_schema.si_ad_structuralObjectClass;
AttributeDescription *ad_objectClass
= slap_schema.si_ad_objectClass;
Entry *e;
struct berval val;
@ -39,6 +42,10 @@ schema_info( Entry **entry, const char **text )
(void) dn_normalize( e->e_ndn );
e->e_private = NULL;
val.bv_val = "LDAPsubentry";
val.bv_len = sizeof("LDAPsubentry")-1;
attr_merge( e, ad_structuralObjectClass, vals );
val.bv_val = "top";
val.bv_len = sizeof("top")-1;
attr_merge( e, ad_objectClass, vals );

View File

@ -24,7 +24,7 @@ static char * oc_check_required(
/*
* Determine the structural object class from a set of OIDs
*/
static int structural_class(
int structural_class(
struct berval **ocs,
struct berval *scbv,
const char **text )
@ -157,7 +157,6 @@ entry_schema_check(
if( !global_schemacheck ) return LDAP_SUCCESS;
#if 1
/* find the object class attribute - could error out here */
asc = attr_find( e->e_attrs, ad_structuralObjectClass );
if ( asc == NULL ) {
@ -215,7 +214,6 @@ entry_schema_check(
return LDAP_OBJECT_CLASS_VIOLATION;
}
#endif
/* find the object class attribute */
aoc = attr_find( e->e_attrs, ad_objectClass );

View File

@ -81,8 +81,7 @@ main( int argc, char **argv )
}
/* check backend */
if( select_backend( e->e_ndn, is_entry_referral(e), nosubs ) != be )
{
if( select_backend( e->e_ndn, is_entry_referral(e), nosubs ) != be ) {
fprintf( stderr, "%s: database (%s) not configured to "
"hold dn=\"%s\" (line=%d)\n",
progname,
@ -94,6 +93,45 @@ main( int argc, char **argv )
break;
}
{
Attribute *sc = attr_find( e->e_attrs,
slap_schema.si_ad_structuralObjectClass );
Attribute *oc = attr_find( e->e_attrs,
slap_schema.si_ad_objectClass );
if( oc == NULL ) {
fprintf( stderr, "%s: dn=\"%s\" (line=%d): %s\n",
progname, e->e_dn, lineno,
"no objectClass attribute");
rc = EXIT_FAILURE;
entry_free( e );
if( continuemode ) continue;
break;
}
if( sc == NULL ) {
struct berval *vals[2];
struct berval scbv;
const char *text;
int ret = structural_class(
oc->a_vals, &scbv, &text );
if( scbv.bv_len == 0 ) {
fprintf( stderr, "%s: dn=\"%s\" (line=%d): %s\n",
progname, e->e_dn, lineno, text );
rc = EXIT_FAILURE;
entry_free( e );
if( continuemode ) continue;
break;
}
vals[0] = &scbv;
vals[1] = NULL;
attr_merge( e, slap_schema.si_ad_structuralObjectClass,
vals );
}
}
if( global_schemacheck ) {
/* check schema */
const char *text;