mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 16:49:39 -05:00
allow objectClass checking including sups
This commit is contained in:
parent
15d1b4d5dd
commit
00b5d8c1bc
3 changed files with 38 additions and 20 deletions
|
|
@ -57,7 +57,7 @@ int is_object_subclass(
|
|||
int is_entry_objectclass(
|
||||
Entry* e,
|
||||
ObjectClass *oc,
|
||||
int set_flags )
|
||||
unsigned flags )
|
||||
{
|
||||
/*
|
||||
* set_flags should only be true if oc is one of operational
|
||||
|
|
@ -67,15 +67,16 @@ int is_entry_objectclass(
|
|||
|
||||
Attribute *attr;
|
||||
struct berval *bv;
|
||||
AttributeDescription *objectClass = slap_schema.si_ad_objectClass;
|
||||
|
||||
assert(!( e == NULL || oc == NULL ));
|
||||
assert( !( e == NULL || oc == NULL ) );
|
||||
assert( ( flags & SLAP_OCF_MASK ) != SLAP_OCF_MASK );
|
||||
|
||||
if( e == NULL || oc == NULL ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( set_flags && ( e->e_ocflags & SLAP_OC__END )) {
|
||||
if( flags == SLAP_OCF_SET_FLAGS && ( e->e_ocflags & SLAP_OC__END ) )
|
||||
{
|
||||
/* flags are set, use them */
|
||||
return (e->e_ocflags & oc->soc_flags & SLAP_OC__MASK) != 0;
|
||||
}
|
||||
|
|
@ -83,7 +84,7 @@ int is_entry_objectclass(
|
|||
/*
|
||||
* find objectClass attribute
|
||||
*/
|
||||
attr = attr_find(e->e_attrs, objectClass);
|
||||
attr = attr_find( e->e_attrs, slap_schema.si_ad_objectClass );
|
||||
if( attr == NULL ) {
|
||||
/* no objectClass attribute */
|
||||
Debug( LDAP_DEBUG_ANY, "is_entry_objectclass(\"%s\", \"%s\") "
|
||||
|
|
@ -97,19 +98,30 @@ int is_entry_objectclass(
|
|||
for( bv=attr->a_vals; bv->bv_val; bv++ ) {
|
||||
ObjectClass *objectClass = oc_bvfind( bv );
|
||||
|
||||
if ( !set_flags && objectClass == oc ) {
|
||||
return 1;
|
||||
if ( objectClass == NULL ) {
|
||||
/* FIXME: is this acceptable? */
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !( flags & SLAP_OCF_SET_FLAGS ) ) {
|
||||
if ( objectClass == oc ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( ( flags & SLAP_OCF_CHECK_SUP )
|
||||
&& is_object_subclass( oc, objectClass ) )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( objectClass != NULL ) {
|
||||
e->e_ocflags |= objectClass->soc_flags;
|
||||
}
|
||||
e->e_ocflags |= objectClass->soc_flags;
|
||||
}
|
||||
|
||||
/* mark flags as set */
|
||||
e->e_ocflags |= SLAP_OC__END;
|
||||
|
||||
return (e->e_ocflags & oc->soc_flags & SLAP_OC__MASK) != 0;
|
||||
return ( e->e_ocflags & oc->soc_flags & SLAP_OC__MASK ) != 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1131,39 +1131,41 @@ LDAP_SLAPD_F (int) is_object_subclass LDAP_P((
|
|||
ObjectClass *sub ));
|
||||
|
||||
LDAP_SLAPD_F (int) is_entry_objectclass LDAP_P((
|
||||
Entry *, ObjectClass *oc, int set_flags ));
|
||||
Entry *, ObjectClass *oc, unsigned flags ));
|
||||
#define is_entry_objectclass_or_sub(e,oc) \
|
||||
(is_entry_objectclass((e),(oc),SLAP_OCF_CHECK_SUP))
|
||||
#define is_entry_alias(e) \
|
||||
(((e)->e_ocflags & SLAP_OC__END) \
|
||||
? (((e)->e_ocflags & SLAP_OC_ALIAS) != 0) \
|
||||
: is_entry_objectclass((e), slap_schema.si_oc_alias, 1))
|
||||
: is_entry_objectclass((e), slap_schema.si_oc_alias, SLAP_OCF_SET_FLAGS))
|
||||
#define is_entry_referral(e) \
|
||||
(((e)->e_ocflags & SLAP_OC__END) \
|
||||
? (((e)->e_ocflags & SLAP_OC_REFERRAL) != 0) \
|
||||
: is_entry_objectclass((e), slap_schema.si_oc_referral, 1))
|
||||
: is_entry_objectclass((e), slap_schema.si_oc_referral, SLAP_OCF_SET_FLAGS))
|
||||
#define is_entry_subentry(e) \
|
||||
(((e)->e_ocflags & SLAP_OC__END) \
|
||||
? (((e)->e_ocflags & SLAP_OC_SUBENTRY) != 0) \
|
||||
: is_entry_objectclass((e), slap_schema.si_oc_subentry, 1))
|
||||
: is_entry_objectclass((e), slap_schema.si_oc_subentry, SLAP_OCF_SET_FLAGS))
|
||||
#define is_entry_collectiveAttributeSubentry(e) \
|
||||
(((e)->e_ocflags & SLAP_OC__END) \
|
||||
? (((e)->e_ocflags & SLAP_OC_COLLECTIVEATTRIBUTESUBENTRY) != 0) \
|
||||
: is_entry_objectclass((e), slap_schema.si_oc_collectiveAttributeSubentry, 1))
|
||||
: is_entry_objectclass((e), slap_schema.si_oc_collectiveAttributeSubentry, SLAP_OCF_SET_FLAGS))
|
||||
#define is_entry_dynamicObject(e) \
|
||||
(((e)->e_ocflags & SLAP_OC__END) \
|
||||
? (((e)->e_ocflags & SLAP_OC_DYNAMICOBJECT) != 0) \
|
||||
: is_entry_objectclass((e), slap_schema.si_oc_dynamicObject, 1))
|
||||
: is_entry_objectclass((e), slap_schema.si_oc_dynamicObject, SLAP_OCF_SET_FLAGS))
|
||||
#define is_entry_glue(e) \
|
||||
(((e)->e_ocflags & SLAP_OC__END) \
|
||||
? (((e)->e_ocflags & SLAP_OC_GLUE) != 0) \
|
||||
: is_entry_objectclass((e), slap_schema.si_oc_glue, 1))
|
||||
: is_entry_objectclass((e), slap_schema.si_oc_glue, SLAP_OCF_SET_FLAGS))
|
||||
#define is_entry_syncProviderSubentry(e) \
|
||||
(((e)->e_ocflags & SLAP_OC__END) \
|
||||
? (((e)->e_ocflags & SLAP_OC_SYNCPROVIDERSUBENTRY) != 0) \
|
||||
: is_entry_objectclass((e), slap_schema.si_oc_syncProviderSubentry, 1))
|
||||
: is_entry_objectclass((e), slap_schema.si_oc_syncProviderSubentry, SLAP_OCF_SET_FLAGS))
|
||||
#define is_entry_syncConsumerSubentry(e) \
|
||||
(((e)->e_ocflags & SLAP_OC__END) \
|
||||
? (((e)->e_ocflags & SLAP_OC_SYNCCONSUMERSUBENTRY) != 0) \
|
||||
: is_entry_objectclass((e), slap_schema.si_oc_syncConsumerSubentry, 1))
|
||||
: is_entry_objectclass((e), slap_schema.si_oc_syncConsumerSubentry, SLAP_OCF_SET_FLAGS))
|
||||
|
||||
LDAP_SLAPD_F (int) oc_schema_info( Entry *e );
|
||||
LDAP_SLAPD_F (void) oc_unparse LDAP_P((
|
||||
|
|
|
|||
|
|
@ -743,6 +743,10 @@ typedef struct slap_object_class {
|
|||
LDAP_STAILQ_ENTRY(slap_object_class) soc_next;
|
||||
} ObjectClass;
|
||||
|
||||
#define SLAP_OCF_SET_FLAGS 0x1
|
||||
#define SLAP_OCF_CHECK_SUP 0x2
|
||||
#define SLAP_OCF_MASK (SLAP_OCF_SET_FLAGS|SLAP_OCF_CHECK_SUP)
|
||||
|
||||
#define SLAP_OC_ALIAS 0x0001
|
||||
#define SLAP_OC_REFERRAL 0x0002
|
||||
#define SLAP_OC_SUBENTRY 0x0004
|
||||
|
|
|
|||
Loading…
Reference in a new issue