2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 1999-2005 The OpenLDAP Foundation.
5 * Portions Copyright 2001-2003 Pierangelo Masarati.
6 * Portions Copyright 1999-2003 Howard Chu.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted only as authorized by the OpenLDAP
13 * A copy of this license is available in the file LICENSE in the
14 * top-level directory of the distribution or, alternatively, at
15 * <http://www.OpenLDAP.org/license.html>.
18 * This work was initially developed by the Howard Chu for inclusion
19 * in OpenLDAP Software and subsequently enhanced by Pierangelo
27 #include <ac/socket.h>
28 #include <ac/string.h>
32 #include "../back-ldap/back-ldap.h"
33 #include "back-meta.h"
34 #undef ldap_debug /* silence a warning in ldap-int.h */
36 #include "../../../libraries/libldap/ldap-int.h"
47 meta_back_search_start(
51 metasingleconn_t *msc,
56 metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
57 struct berval realbase = op->o_req_dn;
58 int realscope = op->ors_scope;
59 ber_len_t suffixlen = 0;
60 struct berval mbase = BER_BVNULL;
61 struct berval mfilter = BER_BVNULL;
62 char **mapped_attrs = NULL;
65 /* should we check return values? */
66 if ( op->ors_deref != -1 ) {
67 ldap_set_option( msc->msc_ld, LDAP_OPT_DEREF,
68 ( void * )&op->ors_deref);
70 if ( op->ors_tlimit != SLAP_NO_LIMIT ) {
71 ldap_set_option( msc->msc_ld, LDAP_OPT_TIMELIMIT,
72 ( void * )&op->ors_tlimit);
74 if ( op->ors_slimit != SLAP_NO_LIMIT ) {
75 ldap_set_option( msc->msc_ld, LDAP_OPT_SIZELIMIT,
76 ( void * )&op->ors_slimit);
79 dc->target = &mi->mi_targets[ candidate ];
82 * modifies the base according to the scope, if required
84 suffixlen = mi->mi_targets[ candidate ].mt_nsuffix.bv_len;
85 if ( suffixlen > op->o_req_ndn.bv_len ) {
86 switch ( op->ors_scope ) {
87 case LDAP_SCOPE_SUBTREE:
89 * make the target suffix the new base
90 * FIXME: this is very forgiving, because
91 * "illegal" searchBases may be turned
92 * into the suffix of the target; however,
93 * the requested searchBase already passed
94 * thru the candidate analyzer...
96 if ( dnIsSuffix( &mi->mi_targets[ candidate ].mt_nsuffix,
99 realbase = mi->mi_targets[ candidate ].mt_nsuffix;
103 * this target is no longer candidate
109 #ifdef LDAP_SCOPE_SUBORDINATE
110 case LDAP_SCOPE_SUBORDINATE:
111 #endif /* LDAP_SCOPE_SUBORDINATE */
112 case LDAP_SCOPE_ONELEVEL:
114 struct berval rdn = mi->mi_targets[ candidate ].mt_nsuffix;
115 rdn.bv_len -= op->o_req_ndn.bv_len + STRLENOF( "," );
116 if ( dnIsOneLevelRDN( &rdn )
117 && dnIsSuffix( &mi->mi_targets[ candidate ].mt_nsuffix, &op->o_req_ndn ) )
120 * if there is exactly one level,
121 * make the target suffix the new
122 * base, and make scope "base"
124 realbase = mi->mi_targets[ candidate ].mt_nsuffix;
125 #ifdef LDAP_SCOPE_SUBORDINATE
126 if ( op->ors_scope == LDAP_SCOPE_SUBORDINATE ) {
127 realscope = LDAP_SCOPE_SUBTREE;
129 #endif /* LDAP_SCOPE_SUBORDINATE */
131 realscope = LDAP_SCOPE_BASE;
134 } /* else continue with the next case */
137 case LDAP_SCOPE_BASE:
139 * this target is no longer candidate
146 * Rewrite the search base, if required
148 dc->ctx = "searchBase";
149 switch ( ldap_back_dn_massage( dc, &realbase, &mbase ) ) {
153 case REWRITE_REGEXEC_UNWILLING:
154 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
155 rs->sr_text = "Operation not allowed";
156 send_ldap_result( op, rs );
159 case REWRITE_REGEXEC_ERR:
162 * this target is no longer candidate
170 rc = ldap_back_filter_map_rewrite( dc, op->ors_filter,
171 &mfilter, BACKLDAP_MAP );
176 case LDAP_COMPARE_FALSE:
179 * this target is no longer candidate
186 * Maps required attributes
188 rc = ldap_back_map_attrs( &mi->mi_targets[ candidate ].mt_rwmap.rwm_at,
189 op->ors_attrs, BACKLDAP_MAP, &mapped_attrs );
190 if ( rc != LDAP_SUCCESS ) {
192 * this target is no longer candidate
201 rc = ldap_search_ext( msc->msc_ld,
202 mbase.bv_val, realscope, mfilter.bv_val,
203 mapped_attrs, op->ors_attrsonly,
204 op->o_ctrls, NULL, NULL, op->ors_slimit,
205 &candidates[ candidate ].sr_msgid );
206 if ( rc == LDAP_SUCCESS ) {
210 candidates[ candidate ].sr_msgid = -1;
215 if ( mapped_attrs ) {
216 free( mapped_attrs );
218 if ( mfilter.bv_val != op->ors_filterstr.bv_val ) {
219 free( mfilter.bv_val );
221 if ( mbase.bv_val != realbase.bv_val ) {
222 free( mbase.bv_val );
229 meta_back_search( Operation *op, SlapReply *rs )
231 metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
233 struct timeval tv = { 0, 0 };
235 LDAPMessage *res = NULL, *e;
236 int rc = 0, sres = LDAP_SUCCESS;
237 char *matched = NULL;
238 int i, last = 0, ncandidates = 0,
239 initial_candidates = 0, candidate_match = 0;
243 SlapReply *candidates = meta_back_candidates_get( op );
246 * controls are set in ldap_back_dobind()
248 * FIXME: in case of values return filter, we might want
249 * to map attrs and maybe rewrite value
251 mc = meta_back_getconn( op, rs, NULL, LDAP_BACK_SENDERR );
252 if ( !mc || !meta_back_dobind( op, rs, mc, LDAP_BACK_SENDERR ) ) {
256 dc.conn = op->o_conn;
262 for ( i = 0; i < mi->mi_ntargets; i++ ) {
263 metasingleconn_t *msc = &mc->mc_conns[ i ];
265 candidates[ i ].sr_msgid = -1;
267 if ( candidates[ i ].sr_tag != META_CANDIDATE ) {
271 candidates[ i ].sr_err = LDAP_SUCCESS;
272 candidates[ i ].sr_matched = NULL;
273 candidates[ i ].sr_text = NULL;
274 candidates[ i ].sr_ref = NULL;
275 candidates[ i ].sr_ctrls = NULL;
277 switch ( meta_back_search_start( op, rs, &dc, msc, i, candidates ) )
292 initial_candidates = ncandidates;
299 for ( i = 0; i < mi->mi_ntargets; i++ ) {
300 if ( candidates[ i ].sr_tag == META_CANDIDATE ) {
308 Debug( LDAP_DEBUG_ANY, "%s meta_back_search: ncandidates=%d "
309 "cnd=\"%s\"\n", op->o_log_prefix, ncandidates, cnd );
313 if ( initial_candidates == 0 ) {
314 send_ldap_error( op, rs, LDAP_NO_SUCH_OBJECT, NULL );
315 /* FIXME: find a way to look up the best match */
317 rc = LDAP_NO_SUCH_OBJECT;
321 /* We pull apart the ber result, stuff it into a slapd entry, and
322 * let send_search_entry stuff it back into ber format. Slow & ugly,
323 * but this is necessary for version matching, and for ACL processing.
326 if ( op->ors_tlimit != SLAP_NO_LIMIT ) {
327 stoptime = op->o_time + op->ors_tlimit;
332 * In case there are no candidates, no cycle takes place...
334 * FIXME: we might use a queue, to better balance the load
335 * among the candidates
337 for ( rc = 0; ncandidates > 0; ) {
338 int gotit = 0, doabandon = 0;
340 for ( i = 0; i < mi->mi_ntargets; i++ ) {
341 metasingleconn_t *msc = &mc->mc_conns[ i ];
343 if ( candidates[ i ].sr_msgid == -1 ) {
347 /* check for abandon */
348 if ( op->o_abandon ) {
353 * FIXME: handle time limit as well?
354 * Note that target servers are likely
355 * to handle it, so at some time we'll
356 * get a LDAP_TIMELIMIT_EXCEEDED from
359 rc = ldap_result( msc->msc_ld, candidates[ i ].sr_msgid,
363 /* FIXME: res should not need to be freed */
364 assert( res == NULL );
366 /* check time limit */
367 if ( op->ors_tlimit != SLAP_NO_LIMIT
368 && slap_get_time() > stoptime )
371 rc = rs->sr_err = LDAP_TIMELIMIT_EXCEEDED;
372 savepriv = op->o_private;
373 op->o_private = (void *)i;
374 send_ldap_result( op, rs );
375 op->o_private = savepriv;
381 } else if ( rc == -1 ) {
383 /* something REALLY bad happened! */
384 ( void )meta_clear_unused_candidates( op, -1 );
385 rs->sr_err = LDAP_OTHER;
386 savepriv = op->o_private;
387 op->o_private = (void *)i;
388 send_ldap_result( op, rs );
389 op->o_private = savepriv;
391 /* anything else needs be done? */
393 /* FIXME: res should not need to be freed */
394 assert( res == NULL );
398 } else if ( rc == LDAP_RES_SEARCH_ENTRY ) {
399 if ( --op->ors_slimit == -1 ) {
403 rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
404 savepriv = op->o_private;
405 op->o_private = (void *)i;
406 send_ldap_result( op, rs );
407 op->o_private = savepriv;
413 e = ldap_first_entry( msc->msc_ld, res );
414 savepriv = op->o_private;
415 op->o_private = (void *)i;
416 meta_send_entry( op, rs, mc, i, e );
417 op->o_private = savepriv;
426 * If scope is BASE, we need to jump out
427 * as soon as one entry is found; if
428 * the target pool is properly crafted,
429 * this should correspond to the sole
430 * entry that has the base DN
432 /* FIXME: this defeats the purpose of
433 * doing a search with scope == base and
434 * sizelimit = 1 to determine if a
435 * candidate is actually unique */
436 if ( op->ors_scope == LDAP_SCOPE_BASE
437 && rs->sr_nentries > 0 )
446 } else if ( rc == LDAP_RES_SEARCH_REFERENCE ) {
447 char **references = NULL;
452 rc = ldap_parse_reference( msc->msc_ld, res,
453 &references, &rs->sr_ctrls, 1 );
456 if ( rc != LDAP_SUCCESS ) {
460 if ( references == NULL ) {
464 #ifdef ENABLE_REWRITE
465 dc.ctx = "referralDN";
466 #else /* ! ENABLE_REWRITE */
469 #endif /* ! ENABLE_REWRITE */
471 /* FIXME: merge all and return at the end */
473 for ( cnt = 0; references[ cnt ]; cnt++ )
476 rs->sr_ref = ch_calloc( sizeof( struct berval ), cnt + 1 );
478 for ( cnt = 0; references[ cnt ]; cnt++ ) {
479 ber_str2bv( references[ cnt ], 0, 1, &rs->sr_ref[ cnt ] );
481 BER_BVZERO( &rs->sr_ref[ cnt ] );
483 ( void )ldap_back_referral_result_rewrite( &dc, rs->sr_ref );
485 if ( rs->sr_ref != NULL && !BER_BVISNULL( &rs->sr_ref[ 0 ] ) ) {
486 /* ignore return value by now */
487 savepriv = op->o_private;
488 op->o_private = (void *)i;
489 ( void )send_search_reference( op, rs );
490 op->o_private = savepriv;
492 ber_bvarray_free( rs->sr_ref );
498 ldap_value_free( references );
501 if ( rs->sr_ctrls ) {
502 ldap_controls_free( rs->sr_ctrls );
506 } else if ( rc == LDAP_RES_SEARCH_RESULT ) {
507 char buf[ SLAP_TEXT_BUFLEN ];
508 char **references = NULL;
510 if ( ldap_parse_result( msc->msc_ld,
512 &candidates[ i ].sr_err,
513 (char **)&candidates[ i ].sr_matched,
514 NULL /* (char **)&candidates[ i ].sr_text */ ,
516 &candidates[ i ].sr_ctrls, 1 ) != LDAP_SUCCESS )
519 ldap_get_option( msc->msc_ld,
520 LDAP_OPT_ERROR_NUMBER,
522 sres = slap_map_api2result( rs );
526 rs->sr_err = candidates[ i ].sr_err;
527 sres = slap_map_api2result( rs );
530 /* massage matchedDN if need be */
531 if ( candidates[ i ].sr_matched != NULL ) {
532 if ( candidates[ i ].sr_matched[ 0 ] == '\0' ) {
533 ldap_memfree( (char *)candidates[ i ].sr_matched );
534 candidates[ i ].sr_matched = NULL;
537 struct berval match, mmatch;
539 ber_str2bv( candidates[ i ].sr_matched,
542 dc.ctx = "matchedDN";
543 dc.target = &mi->mi_targets[ i ];
545 if ( !ldap_back_dn_massage( &dc, &match, &mmatch ) ) {
546 if ( mmatch.bv_val == match.bv_val ) {
547 candidates[ i ].sr_matched = ch_strdup( mmatch.bv_val );
550 candidates[ i ].sr_matched = mmatch.bv_val;
555 ldap_memfree( match.bv_val );
559 /* just get rid of the error message, if any */
560 if ( candidates[ i ].sr_text && candidates[ i ].sr_text[ 0 ] == '\0' )
562 ldap_memfree( (char *)candidates[ i ].sr_text );
563 candidates[ i ].sr_text = NULL;
566 /* add references to array */
571 for ( cnt = 0; references[ cnt ]; cnt++ )
574 sr_ref = ch_calloc( sizeof( struct berval ), cnt + 1 );
576 for ( cnt = 0; references[ cnt ]; cnt++ ) {
577 ber_str2bv( references[ cnt ], 0, 1, &sr_ref[ cnt ] );
579 BER_BVZERO( &sr_ref[ cnt ] );
581 ( void )ldap_back_referral_result_rewrite( &dc, sr_ref );
584 ldap_value_free( references );
586 if ( rs->sr_v2ref == NULL ) {
587 rs->sr_v2ref = sr_ref;
590 for ( cnt = 0; !BER_BVISNULL( &sr_ref[ cnt ] ); cnt++ ) {
591 ber_bvarray_add( &rs->sr_v2ref, &sr_ref[ cnt ] );
593 ber_memfree( sr_ref );
597 rs->sr_err = candidates[ i ].sr_err;
598 sres = slap_map_api2result( rs );
600 snprintf( buf, sizeof( buf ),
601 "%s meta_back_search[%d] "
602 "match=\"%s\" err=%d\n",
604 candidates[ i ].sr_matched ? candidates[ i ].sr_matched : "",
605 candidates[ i ].sr_err );
606 Debug( LDAP_DEBUG_ANY, "%s", buf, 0, 0 );
609 case LDAP_NO_SUCH_OBJECT:
610 /* is_ok is touched any time a valid
611 * (even intermediate) result is
612 * returned; as a consequence, if
613 * a candidate returns noSuchObject
614 * it is ignored and the candidate
615 * is simply demoted. */
627 if ( META_BACK_ONERR_STOP( mi ) ) {
628 savepriv = op->o_private;
629 op->o_private = (void *)i;
630 send_ldap_result( op, rs );
631 op->o_private = savepriv;
641 * When no candidates are left,
642 * the outer cycle finishes
644 candidates[ i ].sr_msgid = -1;
653 /* check for abandon */
654 if ( op->o_abandon || doabandon ) {
655 for ( i = 0; i < mi->mi_ntargets; i++ ) {
656 metasingleconn_t *msc = &mc->mc_conns[ i ];
658 if ( candidates[ i ].sr_msgid != -1 ) {
659 ldap_abandon_ext( msc->msc_ld,
660 candidates[ i ].sr_msgid,
662 candidates[ i ].sr_msgid = -1;
666 if ( op->o_abandon ) {
674 tv.tv_usec = 100000; /* 0.1 s */
675 ldap_pvt_thread_yield();
685 * FIXME: need a better strategy to handle errors
687 rc = meta_back_op_result( mc, op, rs, META_TARGET_NONE );
692 * Rewrite the matched portion of the search base, if required
694 * FIXME: only the last one gets caught!
696 if ( candidate_match > 0 && rs->sr_nentries > 0 ) {
697 /* we use the first one */
698 for ( i = 0; i < mi->mi_ntargets; i++ ) {
699 if ( candidates[ i ].sr_tag == META_CANDIDATE
700 && candidates[ i ].sr_matched )
702 matched = (char *)candidates[ i ].sr_matched;
703 candidates[ i ].sr_matched = NULL;
715 for ( i = 0; i < mi->mi_ntargets; i++ ) {
716 if ( candidates[ i ].sr_tag == META_CANDIDATE ) {
724 snprintf( buf, sizeof( buf ), "%s meta_back_search: is_scope=%d is_ok=%d cnd=\"%s\"\n",
725 op->o_log_prefix, initial_candidates, is_ok, cnd );
727 Debug( LDAP_DEBUG_ANY, "%s", buf, 0, 0 );
732 * In case we returned at least one entry, we return LDAP_SUCCESS
733 * otherwise, the latter error code we got
735 * FIXME: we should handle error codes and return the more
736 * important/reasonable
739 if ( sres == LDAP_SUCCESS && rs->sr_v2ref ) {
740 sres = LDAP_REFERRAL;
743 rs->sr_matched = matched;
744 rs->sr_ref = ( sres == LDAP_REFERRAL ? rs->sr_v2ref : NULL );
745 savepriv = op->o_private;
746 op->o_private = (void *)mi->mi_ntargets;
747 send_ldap_result( op, rs );
748 op->o_private = savepriv;
749 rs->sr_matched = NULL;
757 if ( rs->sr_v2ref ) {
758 ber_bvarray_free( rs->sr_v2ref );
761 for ( i = 0; i < mi->mi_ntargets; i++ ) {
762 if ( candidates[ i ].sr_tag != META_CANDIDATE ) {
766 if ( candidates[ i ].sr_matched ) {
767 free( (char *)candidates[ i ].sr_matched );
768 candidates[ i ].sr_matched = NULL;
771 if ( candidates[ i ].sr_text ) {
772 ldap_memfree( (char *)candidates[ i ].sr_text );
773 candidates[ i ].sr_text = NULL;
776 if ( candidates[ i ].sr_ref ) {
777 ber_bvarray_free( candidates[ i ].sr_ref );
778 candidates[ i ].sr_ref = NULL;
781 if ( candidates[ i ].sr_ctrls ) {
782 ldap_controls_free( candidates[ i ].sr_ctrls );
783 candidates[ i ].sr_ctrls = NULL;
798 metainfo_t *mi = ( metainfo_t * )op->o_bd->be_private;
799 struct berval a, mapped;
801 BerElement ber = *e->lm_ber;
802 Attribute *attr, **attrp;
803 struct berval *bv, bdn;
807 if ( ber_scanf( &ber, "{m{", &bdn ) == LBER_ERROR ) {
808 return LDAP_DECODING_ERROR;
812 * Rewrite the dn of the result, if needed
814 dc.target = &mi->mi_targets[ target ];
815 dc.conn = op->o_conn;
817 dc.ctx = "searchResult";
819 rs->sr_err = ldap_back_dn_massage( &dc, &bdn, &ent.e_name );
820 if ( rs->sr_err != LDAP_SUCCESS) {
825 * Note: this may fail if the target host(s) schema differs
826 * from the one known to the meta, and a DN with unknown
827 * attributes is returned.
829 * FIXME: should we log anything, or delegate to dnNormalize?
831 if ( dnNormalize( 0, NULL, NULL, &ent.e_name, &ent.e_nname,
832 op->o_tmpmemctx ) != LDAP_SUCCESS )
834 return LDAP_INVALID_DN_SYNTAX;
840 if ( mi->mi_cache.ttl != META_DNCACHE_DISABLED ) {
841 ( void )meta_dncache_update_entry( &mi->mi_cache,
842 &ent.e_nname, target );
845 attrp = &ent.e_attrs;
847 dc.ctx = "searchAttrDN";
848 while ( ber_scanf( &ber, "{m", &a ) != LBER_ERROR ) {
851 ldap_back_map( &mi->mi_targets[ target ].mt_rwmap.rwm_at,
852 &a, &mapped, BACKLDAP_REMAP );
853 if ( BER_BVISNULL( &mapped ) || mapped.bv_val[0] == '\0' ) {
856 attr = ( Attribute * )ch_malloc( sizeof( Attribute ) );
857 if ( attr == NULL ) {
863 if ( slap_bv2ad( &mapped, &attr->a_desc, &text )
865 if ( slap_bv2undef_ad( &mapped, &attr->a_desc, &text )
868 char buf[ SLAP_TEXT_BUFLEN ];
870 snprintf( buf, sizeof( buf ),
871 "%s meta_send_entry(\"%s\"): "
872 "slap_bv2undef_ad(%s): %s\n",
873 op->o_log_prefix, ent.e_name.bv_val,
874 mapped.bv_val, text );
876 Debug( LDAP_DEBUG_ANY, "%s", buf, 0, 0 );
882 /* no subschemaSubentry */
883 if ( attr->a_desc == slap_schema.si_ad_subschemaSubentry ) {
886 * We eat target's subschemaSubentry because
887 * a search for this value is likely not
888 * to resolve to the appropriate backend;
889 * later, the local subschemaSubentry is
892 ( void )ber_scanf( &ber, "x" /* [W] */ );
898 if ( ber_scanf( &ber, "[W]", &attr->a_vals ) == LBER_ERROR
899 || attr->a_vals == NULL )
901 attr->a_vals = (struct berval *)&slap_dummy_bv;
903 } else if ( attr->a_desc == slap_schema.si_ad_objectClass
904 || attr->a_desc == slap_schema.si_ad_structuralObjectClass )
906 for ( last = 0; !BER_BVISNULL( &attr->a_vals[ last ] ); ++last );
908 for ( bv = attr->a_vals; !BER_BVISNULL( bv ); bv++ ) {
909 ldap_back_map( &mi->mi_targets[ target ].mt_rwmap.rwm_oc,
910 bv, &mapped, BACKLDAP_REMAP );
911 if ( BER_BVISNULL( &mapped ) || mapped.bv_val[0] == '\0') {
917 *bv = attr->a_vals[ last ];
918 BER_BVZERO( &attr->a_vals[ last ] );
921 } else if ( mapped.bv_val != bv->bv_val ) {
923 ber_dupbv( bv, &mapped );
927 * It is necessary to try to rewrite attributes with
928 * dn syntax because they might be used in ACLs as
929 * members of groups; since ACLs are applied to the
930 * rewritten stuff, no dn-based subecj clause could
931 * be used at the ldap backend side (see
932 * http://www.OpenLDAP.org/faq/data/cache/452.html)
933 * The problem can be overcome by moving the dn-based
934 * ACLs to the target directory server, and letting
935 * everything pass thru the ldap backend.
937 } else if ( attr->a_desc->ad_type->sat_syntax ==
938 slap_schema.si_syn_distinguishedName )
940 ldap_dnattr_result_rewrite( &dc, attr->a_vals );
942 } else if ( attr->a_desc == slap_schema.si_ad_ref ) {
943 ldap_back_referral_result_rewrite( &dc, attr->a_vals );
946 if ( last && attr->a_desc->ad_type->sat_equality &&
947 attr->a_desc->ad_type->sat_equality->smr_normalize ) {
950 attr->a_nvals = ch_malloc( ( last + 1 ) * sizeof( struct berval ) );
951 for ( i = 0; i<last; i++ ) {
952 attr->a_desc->ad_type->sat_equality->smr_normalize(
953 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
954 attr->a_desc->ad_type->sat_syntax,
955 attr->a_desc->ad_type->sat_equality,
956 &attr->a_vals[i], &attr->a_nvals[i],
959 BER_BVZERO( &attr->a_nvals[i] );
962 attr->a_nvals = attr->a_vals;
966 attrp = &attr->a_next;
969 rs->sr_attrs = op->ors_attrs;
971 send_search_entry( op, rs );
975 if ( !BER_BVISNULL( &ent.e_name ) ) {
976 if ( ent.e_name.bv_val != bdn.bv_val ) {
977 free( ent.e_name.bv_val );
979 BER_BVZERO( &ent.e_name );
981 if ( !BER_BVISNULL( &ent.e_nname ) ) {
982 free( ent.e_nname.bv_val );
983 BER_BVZERO( &ent.e_nname );