From: Luke Howard Date: Sun, 31 Jul 2005 06:45:39 +0000 (+0000) Subject: Fix slapi_dn_beparent() logic X-Git-Tag: OPENLDAP_AC_BP~131 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f0101fe5a75ebd7bdd9f79277841b00014d7fff9;p=openldap Fix slapi_dn_beparent() logic --- diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index e12d8ab900..1b65c54d8f 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -946,11 +946,15 @@ char *slapi_dn_beparent( Slapi_PBlock *pb, const char *_dn ) Backend *be; struct berval dn, prettyDN; struct berval normalizedDN, parentDN; + char *parent = NULL; - if ( pb == NULL || pb->pb_op == NULL ) + if ( pb == NULL ) { return NULL; + } - be = pb->pb_op->o_bd; + if ( slapi_is_rootdse( _dn ) ) { + return NULL; + } dn.bv_val = (char *)_dn; dn.bv_len = strlen( _dn ); @@ -959,22 +963,19 @@ char *slapi_dn_beparent( Slapi_PBlock *pb, const char *_dn ) return NULL; } - if ( be != NULL && be_issuffix( be, &normalizedDN ) ) { - slapi_ch_free( (void **)&prettyDN.bv_val ); - slapi_ch_free( (void **)&normalizedDN.bv_val ); - return NULL; - } + be = select_backend( &dn, 0, 0 ); - dnParent( &prettyDN, &parentDN ); + if ( be == NULL || be_issuffix( be, &normalizedDN ) == 0 ) { + dnParent( &prettyDN, &parentDN ); + + if ( parentDN.bv_len != 0 ) + parent = slapi_ch_strdup( parentDN.bv_val ); + } slapi_ch_free( (void **)&prettyDN.bv_val ); slapi_ch_free( (void **)&normalizedDN.bv_val ); - if ( parentDN.bv_len == 0 ) { - return NULL; - } - - return slapi_ch_strdup( parentDN.bv_val ); + return parent; } char *