ITS#6132: Fix slapi_entry_has_children()

This commit is contained in:
Hallvard Furuseth 2009-05-20 21:23:48 +00:00
parent 69caa925ea
commit aa9399db03

View File

@ -475,21 +475,30 @@ int
slapi_entry_has_children( const Slapi_Entry *e ) slapi_entry_has_children( const Slapi_Entry *e )
{ {
Slapi_PBlock *pb; Slapi_PBlock *pb;
int hasSubordinates = 0; Backend *be = select_backend( (struct berval *)&e->e_nname, 0 );
int rc, hasSubordinates = 0;
if ( be == NULL || be->be_has_subordinates == 0 ) {
return 0;
}
pb = slapi_pblock_new(); pb = slapi_pblock_new();
if ( pb == NULL ) {
return 0;
}
slapi_int_connection_init_pb( pb, LDAP_REQ_SEARCH ); slapi_int_connection_init_pb( pb, LDAP_REQ_SEARCH );
slapi_pblock_set( pb, SLAPI_TARGET_DN, slapi_entry_get_dn( (Entry *)e ) ); rc = slapi_pblock_set( pb, SLAPI_TARGET_DN, slapi_entry_get_dn(
(Entry *) e ));
pb->pb_op->o_bd = select_backend( (struct berval *)&e->e_nname, 0 ); if ( rc == LDAP_SUCCESS ) {
if ( pb->pb_op->o_bd != NULL ) { pb->pb_op->o_bd = be;
pb->pb_op->o_bd->be_has_subordinates( pb->pb_op, (Entry *)e, &hasSubordinates ); rc = be->be_has_subordinates( pb->pb_op, (Entry *) e,
&hasSubordinates );
} }
slapi_pblock_destroy( pb ); slapi_pblock_destroy( pb );
return ( hasSubordinates == LDAP_COMPARE_TRUE ); return ( rc == LDAP_SUCCESS && hasSubordinates == LDAP_COMPARE_TRUE );
} }
/* /*