1 /* search.c - ldap backend search function */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1999-2009 The OpenLDAP Foundation.
6 * Portions Copyright 1999-2003 Howard Chu.
7 * Portions Copyright 2000-2003 Pierangelo Masarati.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted only as authorized by the OpenLDAP
14 * A copy of this license is available in the file LICENSE in the
15 * top-level directory of the distribution or, alternatively, at
16 * <http://www.OpenLDAP.org/license.html>.
19 * This work was initially developed by the Howard Chu for inclusion
20 * in OpenLDAP Software and subsequently enhanced by Pierangelo
28 #include <ac/socket.h>
29 #include <ac/string.h>
33 #include "back-ldap.h"
34 #undef ldap_debug /* silence a warning in ldap-int.h */
35 #include "../../../libraries/libldap/ldap-int.h"
40 ldap_build_entry( Operation *op, LDAPMessage *e, Entry *ent,
44 * Quick'n'dirty rewrite of filter in case of error, to deal with
45 * <draft-zeilenga-ldap-t-f>.
48 ldap_back_munge_filter(
50 struct berval *filter,
53 ldapinfo_t *li = (ldapinfo_t *) op->o_bd->be_private;
58 Debug( LDAP_DEBUG_ARGS, "=> ldap_back_munge_filter \"%s\"\n",
59 filter->bv_val, 0, 0 );
61 for ( ptr = strstr( filter->bv_val, "(?=" );
63 ptr = strstr( ptr, "(?=" ) )
66 bv_true = BER_BVC( "(?=true)" ),
67 bv_false = BER_BVC( "(?=false)" ),
68 bv_undefined = BER_BVC( "(?=undefined)" ),
69 bv_t = BER_BVC( "(&)" ),
70 bv_f = BER_BVC( "(|)" ),
71 bv_T = BER_BVC( "(objectClass=*)" ),
72 bv_F = BER_BVC( "(!(objectClass=*))" );
73 struct berval *oldbv = NULL,
75 oldfilter = BER_BVNULL;
77 if ( strncmp( ptr, bv_true.bv_val, bv_true.bv_len ) == 0 ) {
79 if ( LDAP_BACK_T_F( li ) ) {
86 } else if ( strncmp( ptr, bv_false.bv_val, bv_false.bv_len ) == 0 )
89 if ( LDAP_BACK_T_F( li ) ) {
96 } else if ( strncmp( ptr, bv_undefined.bv_val, bv_undefined.bv_len ) == 0 )
98 /* if undef or invalid filter is not allowed,
99 * don't rewrite filter */
100 if ( LDAP_BACK_NOUNDEFFILTER( li ) ) {
101 if ( filter->bv_val != op->ors_filterstr.bv_val ) {
102 op->o_tmpfree( filter->bv_val, op->o_tmpmemctx );
104 BER_BVZERO( filter );
109 oldbv = &bv_undefined;
118 filter->bv_len += newbv->bv_len - oldbv->bv_len;
119 if ( filter->bv_val == op->ors_filterstr.bv_val ) {
120 filter->bv_val = op->o_tmpalloc( filter->bv_len + 1,
123 AC_MEMCPY( filter->bv_val, op->ors_filterstr.bv_val,
124 op->ors_filterstr.bv_len + 1 );
128 filter->bv_val = op->o_tmprealloc( filter->bv_val,
129 filter->bv_len + 1, op->o_tmpmemctx );
132 ptr = filter->bv_val + ( ptr - oldfilter.bv_val );
134 AC_MEMCPY( &ptr[ newbv->bv_len ],
135 &ptr[ oldbv->bv_len ],
136 oldfilter.bv_len - ( ptr - filter->bv_val ) - oldbv->bv_len + 1 );
137 AC_MEMCPY( ptr, newbv->bv_val, newbv->bv_len );
139 ptr += newbv->bv_len;
144 Debug( LDAP_DEBUG_ARGS, "<= ldap_back_munge_filter \"%s\" (%d)\n",
145 filter->bv_val, gotit, 0 );
155 ldapinfo_t *li = (ldapinfo_t *) op->o_bd->be_private;
157 ldapconn_t *lc = NULL;
159 time_t stoptime = (time_t)(-1);
164 struct berval match = BER_BVNULL,
168 int freetext = 0, freefilter = 0;
169 int do_retry = 1, dont_retry = 0;
170 LDAPControl **ctrls = NULL;
171 char **references = NULL;
173 /* FIXME: shouldn't this be null? */
174 const char *save_matched = rs->sr_matched;
176 if ( !ldap_back_dobind( &lc, op, rs, LDAP_BACK_SENDERR ) ) {
181 * FIXME: in case of values return filter, we might want
182 * to map attrs and maybe rewrite value
185 if ( op->ors_tlimit != SLAP_NO_LIMIT ) {
186 tv.tv_sec = op->ors_tlimit;
188 stoptime = op->o_time + op->ors_tlimit;
191 LDAP_BACK_TV_SET( &tv );
194 if ( op->ors_attrs ) {
195 for ( i = 0; !BER_BVISNULL( &op->ors_attrs[i].an_name ); i++ )
196 /* just count attrs */ ;
198 attrs = op->o_tmpalloc( ( i + 1 )*sizeof( char * ),
200 if ( attrs == NULL ) {
201 rs->sr_err = LDAP_NO_MEMORY;
206 for ( i = 0; !BER_BVISNULL( &op->ors_attrs[i].an_name ); i++ ) {
207 attrs[ i ] = op->ors_attrs[i].an_name.bv_val;
213 rc = ldap_back_controls_add( op, rs, lc, &ctrls );
214 if ( rc != LDAP_SUCCESS ) {
218 /* deal with <draft-zeilenga-ldap-t-f> filters */
219 filter = op->ors_filterstr;
221 rs->sr_err = ldap_pvt_search( lc->lc_ld, op->o_req_dn.bv_val,
222 op->ors_scope, filter.bv_val,
223 attrs, op->ors_attrsonly, ctrls, NULL,
224 tv.tv_sec ? &tv : NULL,
225 op->ors_slimit, op->ors_deref, &msgid );
227 if ( rs->sr_err != LDAP_SUCCESS ) {
228 switch ( rs->sr_err ) {
229 case LDAP_SERVER_DOWN:
232 if ( ldap_back_retry( &lc, op, rs, LDAP_BACK_DONTSEND ) ) {
238 /* reset by ldap_back_retry ... */
239 rs->sr_err = slap_map_api2result( rs );
242 rc = ldap_back_op_result( lc, op, rs, msgid, 0, LDAP_BACK_DONTSEND );
247 case LDAP_FILTER_ERROR:
248 if (ldap_back_munge_filter( op, &filter, &freefilter ) > 0 ) {
252 /* invalid filters return success with no data */
253 rs->sr_err = LDAP_SUCCESS;
258 rs->sr_err = slap_map_api2result( rs );
264 /* if needed, initialize timeout */
265 if ( li->li_timeout[ SLAP_OP_SEARCH ] ) {
266 if ( tv.tv_sec == 0 || tv.tv_sec > li->li_timeout[ SLAP_OP_SEARCH ] ) {
267 tv.tv_sec = li->li_timeout[ SLAP_OP_SEARCH ];
272 /* We pull apart the ber result, stuff it into a slapd entry, and
273 * let send_search_entry stuff it back into ber format. Slow & ugly,
274 * but this is necessary for version matching, and for ACL processing.
277 for ( rc = -2; rc != -1; rc = ldap_result( lc->lc_ld, msgid, LDAP_MSG_ONE, &tv, &res ) )
279 /* check for abandon */
280 if ( op->o_abandon || LDAP_BACK_CONN_ABANDON( lc ) ) {
284 (void)ldap_back_cancel( lc, op, rs, msgid, LDAP_BACK_DONTSEND );
289 if ( rc == 0 || rc == -2 ) {
290 ldap_pvt_thread_yield();
293 if ( li->li_timeout[ SLAP_OP_SEARCH ] ) {
295 (void)ldap_back_cancel( lc, op, rs, msgid, LDAP_BACK_DONTSEND );
296 rs->sr_text = "Operation timed out";
297 rc = rs->sr_err = op->o_protocol >= LDAP_VERSION3 ?
298 LDAP_ADMINLIMIT_EXCEEDED : LDAP_OTHER;
303 LDAP_BACK_TV_SET( &tv );
306 /* check time limit */
307 if ( op->ors_tlimit != SLAP_NO_LIMIT
308 && slap_get_time() > stoptime )
310 (void)ldap_back_cancel( lc, op, rs, msgid, LDAP_BACK_DONTSEND );
311 rc = rs->sr_err = LDAP_TIMELIMIT_EXCEEDED;
317 /* only touch when activity actually took place... */
318 if ( li->li_idle_timeout && lc ) {
319 lc->lc_time = op->o_time;
322 /* don't retry any more */
327 if ( rc == LDAP_RES_SEARCH_ENTRY ) {
329 struct berval bdn = BER_BVNULL;
333 e = ldap_first_entry( lc->lc_ld, res );
334 rc = ldap_build_entry( op, e, &ent, &bdn );
335 if ( rc == LDAP_SUCCESS ) {
336 ldap_get_entry_controls( lc->lc_ld, res, &rs->sr_ctrls );
338 rs->sr_attrs = op->ors_attrs;
339 rs->sr_operational_attrs = NULL;
341 rs->sr_err = LDAP_SUCCESS;
342 rc = rs->sr_err = send_search_entry( op, rs );
343 if ( rs->sr_ctrls ) {
344 ldap_controls_free( rs->sr_ctrls );
348 if ( !BER_BVISNULL( &ent.e_name ) ) {
349 assert( ent.e_name.bv_val != bdn.bv_val );
350 op->o_tmpfree( ent.e_name.bv_val, op->o_tmpmemctx );
351 BER_BVZERO( &ent.e_name );
353 if ( !BER_BVISNULL( &ent.e_nname ) ) {
354 op->o_tmpfree( ent.e_nname.bv_val, op->o_tmpmemctx );
355 BER_BVZERO( &ent.e_nname );
362 case LDAP_INSUFFICIENT_ACCESS:
366 if ( rc == LDAP_UNAVAILABLE ) {
367 rc = rs->sr_err = LDAP_OTHER;
369 (void)ldap_back_cancel( lc, op, rs, msgid, LDAP_BACK_DONTSEND );
374 } else if ( rc == LDAP_RES_SEARCH_REFERENCE ) {
375 if ( LDAP_BACK_NOREFS( li ) ) {
381 rc = ldap_parse_reference( lc->lc_ld, res,
382 &references, &rs->sr_ctrls, 1 );
384 if ( rc != LDAP_SUCCESS ) {
388 /* FIXME: there MUST be at least one */
389 if ( references && references[ 0 ] && references[ 0 ][ 0 ] ) {
392 for ( cnt = 0; references[ cnt ]; cnt++ )
395 /* FIXME: there MUST be at least one */
396 rs->sr_ref = op->o_tmpalloc( ( cnt + 1 ) * sizeof( struct berval ),
399 for ( cnt = 0; references[ cnt ]; cnt++ ) {
400 ber_str2bv( references[ cnt ], 0, 0, &rs->sr_ref[ cnt ] );
402 BER_BVZERO( &rs->sr_ref[ cnt ] );
404 /* ignore return value by now */
406 ( void )send_search_reference( op, rs );
409 Debug( LDAP_DEBUG_ANY,
410 "%s ldap_back_search: "
411 "got SEARCH_REFERENCE "
412 "with no referrals\n",
413 op->o_log_prefix, 0, 0 );
418 ber_memvfree( (void **)references );
419 op->o_tmpfree( rs->sr_ref, op->o_tmpmemctx );
424 if ( rs->sr_ctrls ) {
425 ldap_controls_free( rs->sr_ctrls );
429 } else if ( rc == LDAP_RES_INTERMEDIATE ) {
430 /* FIXME: response controls
431 * are passed without checks */
432 rc = ldap_parse_intermediate( lc->lc_ld,
434 (char **)&rs->sr_rspoid,
438 if ( rc != LDAP_SUCCESS ) {
442 slap_send_ldap_intermediate( op, rs );
444 if ( rs->sr_rspoid != NULL ) {
445 ber_memfree( (char *)rs->sr_rspoid );
446 rs->sr_rspoid = NULL;
449 if ( rs->sr_rspdata != NULL ) {
450 ber_bvfree( rs->sr_rspdata );
451 rs->sr_rspdata = NULL;
454 if ( rs->sr_ctrls != NULL ) {
455 ldap_controls_free( rs->sr_ctrls );
462 rc = ldap_parse_result( lc->lc_ld, res, &rs->sr_err,
464 &references, &rs->sr_ctrls, 1 );
465 if ( rc != LDAP_SUCCESS ) {
468 rs->sr_err = slap_map_api2result( rs );
474 /* RFC 4511: referrals can only appear
475 * if result code is LDAP_REFERRAL */
478 && references[ 0 ][ 0 ] )
480 if ( rs->sr_err != LDAP_REFERRAL ) {
481 Debug( LDAP_DEBUG_ANY,
482 "%s ldap_back_search: "
483 "got referrals with err=%d\n",
490 for ( cnt = 0; references[ cnt ]; cnt++ )
493 rs->sr_ref = op->o_tmpalloc( ( cnt + 1 ) * sizeof( struct berval ),
496 for ( cnt = 0; references[ cnt ]; cnt++ ) {
498 ber_str2bv( references[ cnt ], 0, 0, &rs->sr_ref[ cnt ] );
500 BER_BVZERO( &rs->sr_ref[ cnt ] );
503 } else if ( rs->sr_err == LDAP_REFERRAL ) {
504 Debug( LDAP_DEBUG_ANY,
505 "%s ldap_back_search: "
506 "got err=%d with null "
507 "or empty referrals\n",
511 rs->sr_err = LDAP_NO_SUCH_OBJECT;
514 if ( match.bv_val != NULL ) {
515 match.bv_len = strlen( match.bv_val );
522 /* if needed, restore timeout */
523 if ( li->li_timeout[ SLAP_OP_SEARCH ] ) {
524 if ( tv.tv_sec == 0 || tv.tv_sec > li->li_timeout[ SLAP_OP_SEARCH ] ) {
525 tv.tv_sec = li->li_timeout[ SLAP_OP_SEARCH ];
531 if ( rc == -1 && dont_retry == 0 ) {
534 if ( ldap_back_retry( &lc, op, rs, LDAP_BACK_DONTSEND ) ) {
538 rs->sr_err = LDAP_SERVER_DOWN;
539 rs->sr_err = slap_map_api2result( rs );
544 * Rewrite the matched portion of the search base, if required
546 if ( !BER_BVISNULL( &match ) && !BER_BVISEMPTY( &match ) ) {
547 struct berval pmatch;
549 if ( dnPretty( NULL, &match, &pmatch, op->o_tmpmemctx ) == LDAP_SUCCESS ) {
550 rs->sr_matched = pmatch.bv_val;
551 LDAP_FREE( match.bv_val );
554 rs->sr_matched = match.bv_val;
558 if ( rs->sr_v2ref ) {
559 rs->sr_err = LDAP_REFERRAL;
563 if ( LDAP_BACK_QUARANTINE( li ) ) {
564 ldap_back_quarantine( op, rs );
567 if ( freefilter && filter.bv_val != op->ors_filterstr.bv_val ) {
568 op->o_tmpfree( filter.bv_val, op->o_tmpmemctx );
572 /* let send_ldap_result play cleanup handlers (ITS#4645) */
573 if ( rc != SLAPD_ABANDON )
576 send_ldap_result( op, rs );
579 (void)ldap_back_controls_free( op, rs, &ctrls );
581 if ( rs->sr_ctrls ) {
582 ldap_controls_free( rs->sr_ctrls );
586 if ( rs->sr_matched != NULL && rs->sr_matched != save_matched ) {
587 if ( rs->sr_matched != match.bv_val ) {
588 ber_memfree_x( (char *)rs->sr_matched, op->o_tmpmemctx );
591 LDAP_FREE( match.bv_val );
593 rs->sr_matched = save_matched;
598 LDAP_FREE( (char *)rs->sr_text );
604 op->o_tmpfree( rs->sr_ref, op->o_tmpmemctx );
609 ber_memvfree( (void **)references );
613 op->o_tmpfree( attrs, op->o_tmpmemctx );
617 ldap_back_release_conn( li, lc );
631 BerElement ber = *e->lm_ber;
632 Attribute *attr, **attrp;
638 /* safe assumptions ... */
639 assert( ent != NULL );
640 BER_BVZERO( &ent->e_bv );
642 if ( ber_scanf( &ber, "{m", bdn ) == LBER_ERROR ) {
643 return LDAP_DECODING_ERROR;
647 * Note: this may fail if the target host(s) schema differs
648 * from the one known to the meta, and a DN with unknown
649 * attributes is returned.
651 * FIXME: should we log anything, or delegate to dnNormalize?
653 /* Note: if the distinguished values or the naming attributes
654 * change, should we massage them as well?
656 if ( dnPrettyNormal( NULL, bdn, &ent->e_name, &ent->e_nname,
657 op->o_tmpmemctx ) != LDAP_SUCCESS )
659 return LDAP_INVALID_DN_SYNTAX;
663 if ( ber_first_element( &ber, &len, &lastb ) != LBER_SEQUENCE ) {
667 attrp = &ent->e_attrs;
668 while ( ber_next_element( &ber, &len, lastb ) == LBER_SEQUENCE &&
669 ber_scanf( &ber, "{m", &a ) != LBER_ERROR ) {
671 slap_syntax_validate_func *validate;
672 slap_syntax_transform_func *pretty;
674 attr = attr_alloc( NULL );
675 if ( attr == NULL ) {
678 if ( slap_bv2ad( &a, &attr->a_desc, &text )
681 if ( slap_bv2undef_ad( &a, &attr->a_desc, &text,
682 SLAP_AD_PROXIED ) != LDAP_SUCCESS )
684 Debug( LDAP_DEBUG_ANY,
685 "%s ldap_build_entry: "
686 "slap_bv2undef_ad(%s): %s\n",
687 op->o_log_prefix, a.bv_val, text );
689 ( void )ber_scanf( &ber, "x" /* [W] */ );
695 /* no subschemaSubentry */
696 if ( attr->a_desc == slap_schema.si_ad_subschemaSubentry
697 || attr->a_desc == slap_schema.si_ad_entryDN )
701 * We eat target's subschemaSubentry because
702 * a search for this value is likely not
703 * to resolve to the appropriate backend;
704 * later, the local subschemaSubentry is
707 * We also eat entryDN because the frontend
708 * will reattach it without checking if already
711 ( void )ber_scanf( &ber, "x" /* [W] */ );
716 if ( ber_scanf( &ber, "[W]", &attr->a_vals ) == LBER_ERROR
717 || attr->a_vals == NULL )
720 * Note: attr->a_vals can be null when using
721 * values result filter
723 attr->a_vals = (struct berval *)&slap_dummy_bv;
726 validate = attr->a_desc->ad_type->sat_syntax->ssyn_validate;
727 pretty = attr->a_desc->ad_type->sat_syntax->ssyn_pretty;
729 if ( !validate && !pretty ) {
730 attr->a_nvals = NULL;
735 for ( i = 0; !BER_BVISNULL( &attr->a_vals[i] ); i++ ) ;
739 * check that each value is valid per syntax
740 * and pretty if appropriate
742 for ( i = 0; i<last; i++ ) {
747 rc = ordered_value_pretty( attr->a_desc,
748 &attr->a_vals[i], &pval, NULL );
751 rc = ordered_value_validate( attr->a_desc,
752 &attr->a_vals[i], 0 );
755 if ( rc != LDAP_SUCCESS ) {
758 /* check if, by chance, it's an undefined objectClass */
759 if ( attr->a_desc == slap_schema.si_ad_objectClass &&
760 ( oc = oc_bvfind_undef( &attr->a_vals[i] ) ) != NULL )
762 ber_dupbv( &pval, &oc->soc_cname );
766 LBER_FREE( attr->a_vals[i].bv_val );
768 BER_BVZERO( &attr->a_vals[i] );
771 attr->a_vals[i] = attr->a_vals[last];
772 BER_BVZERO( &attr->a_vals[last] );
777 if ( rc == LDAP_SUCCESS && pretty ) {
778 LBER_FREE( attr->a_vals[i].bv_val );
779 attr->a_vals[i] = pval;
782 attr->a_numvals = last = i;
783 if ( last == 0 && attr->a_vals != &slap_dummy_bv ) {
784 attr->a_nvals = NULL;
789 if ( last && attr->a_desc->ad_type->sat_equality &&
790 attr->a_desc->ad_type->sat_equality->smr_normalize )
792 attr->a_nvals = ch_malloc( ( last + 1 )*sizeof( struct berval ) );
793 for ( i = 0; i < last; i++ ) {
796 rc = ordered_value_normalize(
797 SLAP_MR_VALUE_OF_ATTRIBUTE_SYNTAX,
799 attr->a_desc->ad_type->sat_equality,
800 &attr->a_vals[i], &attr->a_nvals[i],
803 if ( rc != LDAP_SUCCESS ) {
804 LBER_FREE( attr->a_vals[i].bv_val );
806 BER_BVZERO( &attr->a_vals[i] );
809 attr->a_vals[i] = attr->a_vals[last];
810 BER_BVZERO( &attr->a_vals[last] );
814 BER_BVZERO( &attr->a_nvals[i] );
821 attr->a_nvals = attr->a_vals;
824 attr->a_numvals = last;
826 /* Handle sorted vals, strip dups but keep the attr */
827 if ( attr->a_desc->ad_type->sat_flags & SLAP_AT_SORTED_VAL ) {
828 while ( attr->a_numvals > 1 ) {
829 int rc = slap_sort_vals( (Modifications *)attr, &text, &i, op->o_tmpmemctx );
830 if ( rc != LDAP_TYPE_OR_VALUE_EXISTS )
833 /* Strip duplicate values */
834 if ( attr->a_nvals != attr->a_vals )
835 LBER_FREE( attr->a_nvals[i].bv_val );
836 LBER_FREE( attr->a_vals[i].bv_val );
840 if ( (unsigned)i < attr->a_numvals ) {
841 attr->a_vals[i] = attr->a_vals[attr->a_numvals];
842 if ( attr->a_nvals != attr->a_vals )
843 attr->a_nvals[i] = attr->a_nvals[attr->a_numvals];
845 BER_BVZERO(&attr->a_vals[attr->a_numvals]);
846 if ( attr->a_nvals != attr->a_vals )
847 BER_BVZERO(&attr->a_nvals[attr->a_numvals]);
849 attr->a_flags |= SLAP_ATTR_SORTED_VALS;
853 attrp = &attr->a_next;
861 /* return 0 IFF we can retrieve the entry with ndn
868 AttributeDescription *at,
872 ldapinfo_t *li = (ldapinfo_t *) op->o_bd->be_private;
874 ldapconn_t *lc = NULL;
879 LDAPMessage *result = NULL,
881 char *attr[3], **attrp = NULL;
885 LDAPControl **ctrls = NULL;
889 /* Tell getconn this is a privileged op */
890 do_not_cache = op->o_do_not_cache;
893 op->o_do_not_cache = 1;
894 /* ldap_back_entry_get() is an entry lookup, so it does not need
895 * to know what the entry is being looked up for */
896 op->o_tag = LDAP_REQ_SEARCH;
897 rc = ldap_back_dobind( &lc, op, &rs, LDAP_BACK_DONTSEND );
898 op->o_do_not_cache = do_not_cache;
906 if ( oc && at != slap_schema.si_ad_objectClass ) {
907 attr[0] = slap_schema.si_ad_objectClass->ad_cname.bv_val;
908 attr[1] = at->ad_cname.bv_val;
912 attr[0] = at->ad_cname.bv_val;
920 filter = op->o_tmpalloc( STRLENOF( "(objectClass=" ")" )
921 + oc->soc_cname.bv_len + 1, op->o_tmpmemctx );
922 ptr = lutil_strcopy( filter, "(objectClass=" );
923 ptr = lutil_strcopy( ptr, oc->soc_cname.bv_val );
930 rc = ldap_back_controls_add( op, &rs, lc, &ctrls );
931 if ( rc != LDAP_SUCCESS ) {
936 rc = ldap_pvt_search_s( lc->lc_ld, ndn->bv_val, LDAP_SCOPE_BASE, filter,
937 attrp, LDAP_DEREF_NEVER, ctrls, NULL,
938 NULL, LDAP_NO_LIMIT, 0, &result );
939 if ( rc != LDAP_SUCCESS ) {
940 if ( rc == LDAP_SERVER_DOWN && do_retry ) {
942 if ( ldap_back_retry( &lc, op, &rs, LDAP_BACK_DONTSEND ) ) {
943 /* if the identity changed, there might be need to re-authz */
944 (void)ldap_back_controls_free( op, &rs, &ctrls );
951 e = ldap_first_entry( lc->lc_ld, result );
953 /* the entry exists, but it doesn't match the filter? */
957 *ent = entry_alloc();
958 if ( *ent == NULL ) {
963 rc = ldap_build_entry( op, e, *ent, &bdn );
965 if ( rc != LDAP_SUCCESS ) {
971 (void)ldap_back_controls_free( op, &rs, &ctrls );
974 ldap_msgfree( result );
978 op->o_tmpfree( filter, op->o_tmpmemctx );
982 ldap_back_release_conn( li, lc );