From 13e657ffa8ac8f9ad2e5885243702efb33b126ee Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Sun, 23 May 2004 12:06:47 +0000 Subject: [PATCH] Implement slapi_entry_has_children() --- servers/slapd/slapi/proto-slapi.h | 3 +++ servers/slapd/slapi/slapi_ops.c | 2 +- servers/slapd/slapi/slapi_utils.c | 31 ++++++++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/servers/slapd/slapi/proto-slapi.h b/servers/slapd/slapi/proto-slapi.h index 5036d02299..a4412be146 100644 --- a/servers/slapd/slapi/proto-slapi.h +++ b/servers/slapd/slapi/proto-slapi.h @@ -48,6 +48,8 @@ extern void slapi_entry_attr_set_uint( Slapi_Entry* e, const char *type, unsigne extern void slapi_entry_attr_set_long(Slapi_Entry* e, const char *type, long l); extern void slapi_entry_attr_set_ulong(Slapi_Entry* e, const char *type, unsigned long l); extern int slapi_is_rootdse( const char *dn ); +extern int slapi_entry_has_children(const Slapi_Entry *e); + extern int slapi_entry_attr_merge_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ); extern int slapi_entry_add_values_sv( Slapi_Entry *e, const char *type, Slapi_Value **vals ); extern int slapi_entry_add_valueset(Slapi_Entry *e, const char *type, Slapi_ValueSet *vs); @@ -297,6 +299,7 @@ extern Slapi_PBlock *slapi_modrdn_internal( char * olddn, char * newrdn, int deloldrdn, LDAPControl **controls, int log_change); extern char **slapi_get_supported_extended_ops(void); extern struct berval *slapi_int_get_supported_extop( int ); +Connection *slapi_int_init_connection(char *DN, int OpType); /* * Was: slapi_cl.h diff --git a/servers/slapd/slapi/slapi_ops.c b/servers/slapd/slapi/slapi_ops.c index c001f0bbc3..0640c72045 100644 --- a/servers/slapd/slapi/slapi_ops.c +++ b/servers/slapd/slapi/slapi_ops.c @@ -119,7 +119,7 @@ internal_search_reference( return LDAP_SUCCESS; } -static Connection * +Connection * slapi_int_init_connection( char *DN, int OpType ) diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index d9ceeb43db..735f81a651 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -109,7 +109,7 @@ bvptr2obj( Slapi_Entry * slapi_str2entry( char *s, - int check_dup ) + int flags ) { #ifdef LDAP_SLAPI Slapi_Entry *e = NULL; @@ -529,6 +529,35 @@ slapi_is_rootdse( const char *dn ) #endif } +int +slapi_entry_has_children(const Slapi_Entry *e) +{ +#ifdef LDAP_SLAPI + Connection *pConn; + Operation *op; + int hasSubordinates = 0; + + pConn = slapi_int_init_connection( NULL, LDAP_REQ_SEARCH ); + if ( pConn == NULL ) { + return 0; + } + + op = (Operation *)pConn->c_pending_ops.stqh_first; + op->o_bd = select_backend( (struct berval *)&e->e_nname, 0, 0 ); + if ( op->o_bd == NULL ) { + return 0; + } + + op->o_bd->be_has_subordinates( op, (Entry *)e, &hasSubordinates ); + + slapi_int_connection_destroy( &pConn ); + + return ( hasSubordinates == LDAP_COMPARE_TRUE ); +#else + return 0; +#endif +} + /* * Add values to entry. * -- 2.39.5