1 /* result.c - routines to send ldap results, errors, and referrals */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 1998-2009 The OpenLDAP Foundation.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted only as authorized by the OpenLDAP
12 * A copy of this license is available in the file LICENSE in the
13 * top-level directory of the distribution or, alternatively, at
14 * <http://www.OpenLDAP.org/license.html>.
16 /* Portions Copyright (c) 1995 Regents of the University of Michigan.
17 * All rights reserved.
19 * Redistribution and use in source and binary forms are permitted
20 * provided that this notice is preserved and that due credit is given
21 * to the University of Michigan at Ann Arbor. The name of the University
22 * may not be used to endorse or promote products derived from this
23 * software without specific prior written permission. This software
24 * is provided ``as is'' without express or implied warranty.
31 #include <ac/socket.h>
33 #include <ac/string.h>
36 #include <ac/unistd.h>
40 const struct berval slap_dummy_bv = BER_BVNULL;
42 int slap_null_cb( Operation *op, SlapReply *rs )
47 int slap_freeself_cb( Operation *op, SlapReply *rs )
49 assert( op->o_callback != NULL );
51 op->o_tmpfree( op->o_callback, op->o_tmpmemctx );
52 op->o_callback = NULL;
54 return SLAP_CB_CONTINUE;
57 static char *v2ref( BerVarray ref, const char *text )
59 size_t len = 0, i = 0;
64 return ch_strdup(text);
72 if (text[len-1] != '\n') {
77 v2 = ch_malloc( len+i+sizeof("Referral:") );
85 strcpy( v2+len, "Referral:" );
86 len += sizeof("Referral:");
88 for( i=0; ref[i].bv_val != NULL; i++ ) {
89 v2 = ch_realloc( v2, len + ref[i].bv_len + 1 );
91 AC_MEMCPY(&v2[len], ref[i].bv_val, ref[i].bv_len );
93 if (ref[i].bv_val[ref[i].bv_len-1] != '/') {
103 slap_req2res( ber_tag_t tag )
108 case LDAP_REQ_COMPARE:
109 case LDAP_REQ_EXTENDED:
110 case LDAP_REQ_MODIFY:
111 case LDAP_REQ_MODRDN:
115 case LDAP_REQ_DELETE:
116 tag = LDAP_RES_DELETE;
119 case LDAP_REQ_ABANDON:
120 case LDAP_REQ_UNBIND:
124 case LDAP_REQ_SEARCH:
125 tag = LDAP_RES_SEARCH_RESULT;
135 static long send_ldap_ber(
143 ber_get_option( ber, LBER_OPT_BER_BYTES_TO_WRITE, &bytes );
145 /* write only one pdu at a time - wait til it's our turn */
146 ldap_pvt_thread_mutex_lock( &conn->c_write1_mutex );
147 if ( connection_state_closing( conn )) {
148 ldap_pvt_thread_mutex_unlock( &conn->c_write1_mutex );
151 while ( conn->c_writers > 0 ) {
152 ldap_pvt_thread_cond_wait( &conn->c_write1_cv, &conn->c_write1_mutex );
154 /* connection was closed under us */
155 if ( conn->c_writers < 0 ) {
157 /* we're the last waiter, let the closer continue */
158 if ( conn->c_writers == -1 )
159 ldap_pvt_thread_cond_signal( &conn->c_write1_cv );
163 ldap_pvt_thread_mutex_unlock( &conn->c_write1_mutex );
172 /* lock the connection */
173 ldap_pvt_thread_mutex_lock( &conn->c_mutex );
175 if ( ber_flush2( conn->c_sb, ber, LBER_FLUSH_FREE_NEVER ) == 0 ) {
176 ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
184 * we got an error. if it's ewouldblock, we need to
185 * wait on the socket being writable. otherwise, figure
186 * it's a hard error and return.
189 Debug( LDAP_DEBUG_CONNS, "ber_flush2 failed errno=%d reason=\"%s\"\n",
190 err, sock_errstr(err), 0 );
192 if ( err != EWOULDBLOCK && err != EAGAIN ) {
193 connection_closing( conn, "connection lost on write" );
195 ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
201 /* wait for socket to be write-ready */
202 ldap_pvt_thread_mutex_lock( &conn->c_write2_mutex );
203 conn->c_writewaiter = 1;
204 slapd_set_write( conn->c_sd, 1 );
206 ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
207 ldap_pvt_thread_cond_wait( &conn->c_write2_cv, &conn->c_write2_mutex );
208 conn->c_writewaiter = 0;
209 ldap_pvt_thread_mutex_unlock( &conn->c_write2_mutex );
210 ldap_pvt_thread_mutex_lock( &conn->c_write1_mutex );
211 closing = ( conn->c_writers < 0 );
212 ldap_pvt_thread_mutex_unlock( &conn->c_write1_mutex );
219 ldap_pvt_thread_mutex_lock( &conn->c_write1_mutex );
220 if ( conn->c_writers < 0 ) {
222 if ( !conn->c_writers )
223 ldap_pvt_thread_cond_signal( &conn->c_write1_cv );
226 ldap_pvt_thread_cond_signal( &conn->c_write1_cv );
228 ldap_pvt_thread_mutex_unlock( &conn->c_write1_mutex );
234 send_ldap_control( BerElement *ber, LDAPControl *c )
240 rc = ber_printf( ber, "{s" /*}*/, c->ldctl_oid );
242 if( c->ldctl_iscritical ) {
243 rc = ber_printf( ber, "b",
244 (ber_int_t) c->ldctl_iscritical ) ;
245 if( rc == -1 ) return rc;
248 if( c->ldctl_value.bv_val != NULL ) {
249 rc = ber_printf( ber, "O", &c->ldctl_value );
250 if( rc == -1 ) return rc;
253 rc = ber_printf( ber, /*{*/"N}" );
254 if( rc == -1 ) return rc;
260 send_ldap_controls( Operation *o, BerElement *ber, LDAPControl **c )
267 rc = ber_printf( ber, "t{"/*}*/, LDAP_TAG_CONTROLS );
268 if( rc == -1 ) return rc;
270 for( ; *c != NULL; c++) {
271 rc = send_ldap_control( ber, *c );
272 if( rc == -1 ) return rc;
275 #ifdef SLAP_CONTROL_X_SORTEDRESULTS
276 /* this is a hack to avoid having to modify op->s_ctrls */
277 if( o->o_sortedresults ) {
278 BerElementBuffer berbuf;
279 BerElement *sber = (BerElement *) &berbuf;
281 BER_BVZERO( &sorted.ldctl_value );
282 sorted.ldctl_oid = LDAP_CONTROL_SORTRESPONSE;
283 sorted.ldctl_iscritical = 0;
285 ber_init2( sber, NULL, LBER_USE_DER );
287 ber_printf( sber, "{e}", LDAP_UNWILLING_TO_PERFORM );
289 if( ber_flatten2( ber, &sorted.ldctl_value, 0 ) == -1 ) {
293 (void) ber_free_buf( ber );
295 rc = send_ldap_control( ber, &sorted );
296 if( rc == -1 ) return rc;
300 rc = ber_printf( ber, /*{*/"N}" );
306 * slap_response_play()
308 * plays the callback list; rationale: a callback can
309 * - remove itself from the list, by setting op->o_callback = NULL;
310 * malloc()'ed callbacks should free themselves from inside the
311 * sc_response() function.
312 * - replace itself with another (list of) callback(s), by setting
313 * op->o_callback = a new (list of) callback(s); in this case, it
314 * is the callback's responsibility to to append existing subsequent
315 * callbacks to the end of the list that is passed to the sc_response()
317 * - modify the list of subsequent callbacks by modifying the value
318 * of the sc_next field from inside the sc_response() function; this
319 * case does not require any handling from inside slap_response_play()
321 * To stop execution of the playlist, the sc_response() function must return
322 * a value different from SLAP_SC_CONTINUE.
324 * The same applies to slap_cleanup_play(); only, there is no means to stop
325 * execution of the playlist, since all cleanup functions must be called.
334 slap_callback *sc = op->o_callback, **scp;
336 rc = SLAP_CB_CONTINUE;
337 for ( scp = ≻ *scp; ) {
338 slap_callback *sc_next = (*scp)->sc_next, **sc_nextp = &(*scp)->sc_next;
340 op->o_callback = *scp;
341 if ( op->o_callback->sc_response ) {
342 rc = op->o_callback->sc_response( op, rs );
343 if ( op->o_callback == NULL ) {
344 /* the callback has been removed;
349 } else if ( op->o_callback != *scp ) {
350 /* a new callback has been inserted
351 * in place of the existing one; repair the list */
352 *scp = op->o_callback;
355 if ( rc != SLAP_CB_CONTINUE ) break;
369 slap_callback *sc = op->o_callback, **scp;
371 for ( scp = ≻ *scp; ) {
372 slap_callback *sc_next = (*scp)->sc_next, **sc_nextp = &(*scp)->sc_next;
374 op->o_callback = *scp;
375 if ( op->o_callback->sc_cleanup ) {
376 (void)op->o_callback->sc_cleanup( op, rs );
377 if ( op->o_callback == NULL ) {
378 /* the callback has been removed;
383 } else if ( op->o_callback != *scp ) {
384 /* a new callback has been inserted
385 * after the existing one; repair the list */
386 /* a new callback has been inserted
387 * in place of the existing one; repair the list */
388 *scp = op->o_callback;
391 /* don't care about the result; do all cleanup */
405 BerElementBuffer berbuf;
406 BerElement *ber = (BerElement *) &berbuf;
407 int rc = LDAP_SUCCESS;
410 if ( rs->sr_err == SLAPD_ABANDON || op->o_abandon ) {
415 if ( op->o_callback ) {
416 rc = slap_response_play( op, rs );
417 if ( rc != SLAP_CB_CONTINUE ) {
422 #ifdef LDAP_CONNECTIONLESS
423 if (op->o_conn && op->o_conn->c_is_udp)
428 ber_init_w_nullc( ber, LBER_USE_DER );
429 ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
432 Debug( LDAP_DEBUG_TRACE,
433 "send_ldap_response: msgid=%d tag=%lu err=%d\n",
434 rs->sr_msgid, rs->sr_tag, rs->sr_err );
437 Debug( LDAP_DEBUG_ARGS, "send_ldap_response: ref=\"%s\"\n",
438 rs->sr_ref[0].bv_val ? rs->sr_ref[0].bv_val : "NULL",
442 #ifdef LDAP_CONNECTIONLESS
443 if (op->o_conn && op->o_conn->c_is_udp &&
444 op->o_protocol == LDAP_VERSION2 )
446 rc = ber_printf( ber, "t{ess" /*"}"*/,
447 rs->sr_tag, rs->sr_err,
448 rs->sr_matched == NULL ? "" : rs->sr_matched,
449 rs->sr_text == NULL ? "" : rs->sr_text );
452 if ( rs->sr_type == REP_INTERMEDIATE ) {
453 rc = ber_printf( ber, "{it{" /*"}}"*/,
454 rs->sr_msgid, rs->sr_tag );
457 rc = ber_printf( ber, "{it{ess" /*"}}"*/,
458 rs->sr_msgid, rs->sr_tag, rs->sr_err,
459 rs->sr_matched == NULL ? "" : rs->sr_matched,
460 rs->sr_text == NULL ? "" : rs->sr_text );
464 if ( rs->sr_ref != NULL ) {
465 assert( rs->sr_err == LDAP_REFERRAL );
466 rc = ber_printf( ber, "t{W}",
467 LDAP_TAG_REFERRAL, rs->sr_ref );
469 assert( rs->sr_err != LDAP_REFERRAL );
473 if( rc != -1 && rs->sr_type == REP_SASL && rs->sr_sasldata != NULL ) {
474 rc = ber_printf( ber, "tO",
475 LDAP_TAG_SASL_RES_CREDS, rs->sr_sasldata );
479 ( rs->sr_type == REP_EXTENDED || rs->sr_type == REP_INTERMEDIATE ))
481 if ( rs->sr_rspoid != NULL ) {
482 rc = ber_printf( ber, "ts",
483 rs->sr_type == REP_EXTENDED
484 ? LDAP_TAG_EXOP_RES_OID : LDAP_TAG_IM_RES_OID,
487 if( rc != -1 && rs->sr_rspdata != NULL ) {
488 rc = ber_printf( ber, "tO",
489 rs->sr_type == REP_EXTENDED
490 ? LDAP_TAG_EXOP_RES_VALUE : LDAP_TAG_IM_RES_VALUE,
496 rc = ber_printf( ber, /*"{"*/ "N}" );
500 rc = send_ldap_controls( op, ber, rs->sr_ctrls );
504 rc = ber_printf( ber, /*"{"*/ "N}" );
507 #ifdef LDAP_CONNECTIONLESS
508 if( op->o_conn && op->o_conn->c_is_udp && op->o_protocol == LDAP_VERSION2
511 rc = ber_printf( ber, /*"{"*/ "N}" );
516 Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
518 #ifdef LDAP_CONNECTIONLESS
519 if (!op->o_conn || op->o_conn->c_is_udp == 0)
528 bytes = send_ldap_ber( op->o_conn, ber );
529 #ifdef LDAP_CONNECTIONLESS
530 if (!op->o_conn || op->o_conn->c_is_udp == 0)
537 Debug( LDAP_DEBUG_ANY,
538 "send_ldap_response: ber write failed\n",
544 ldap_pvt_thread_mutex_lock( &op->o_counters->sc_mutex );
545 ldap_pvt_mp_add_ulong( op->o_counters->sc_pdu, 1 );
546 ldap_pvt_mp_add_ulong( op->o_counters->sc_bytes, (unsigned long)bytes );
547 ldap_pvt_thread_mutex_unlock( &op->o_counters->sc_mutex );
550 /* Tell caller that we did this for real, as opposed to being
551 * overridden by a callback
553 rc = SLAP_CB_CONTINUE;
556 if ( op->o_callback ) {
557 (void)slap_cleanup_play( op, rs );
560 if ( rs->sr_flags & REP_MATCHED_MUSTBEFREED ) {
561 rs->sr_flags ^= REP_MATCHED_MUSTBEFREED; /* paranoia */
562 if ( rs->sr_matched ) {
563 free( (char *)rs->sr_matched );
564 rs->sr_matched = NULL;
568 if ( rs->sr_flags & REP_REF_MUSTBEFREED ) {
569 rs->sr_flags ^= REP_REF_MUSTBEFREED; /* paranoia */
571 ber_bvarray_free( rs->sr_ref );
576 if ( rs->sr_flags & REP_CTRLS_MUSTBEFREED ) {
577 rs->sr_flags ^= REP_CTRLS_MUSTBEFREED; /* paranoia */
578 if ( rs->sr_ctrls ) {
579 slap_free_ctrls( op, rs->sr_ctrls );
589 send_ldap_disconnect( Operation *op, SlapReply *rs )
591 #define LDAP_UNSOLICITED_ERROR(e) \
592 ( (e) == LDAP_PROTOCOL_ERROR \
593 || (e) == LDAP_STRONG_AUTH_REQUIRED \
594 || (e) == LDAP_UNAVAILABLE )
596 assert( LDAP_UNSOLICITED_ERROR( rs->sr_err ) );
598 rs->sr_type = REP_EXTENDED;
600 Debug( LDAP_DEBUG_TRACE,
601 "send_ldap_disconnect %d:%s\n",
602 rs->sr_err, rs->sr_text ? rs->sr_text : "", NULL );
604 if ( op->o_protocol < LDAP_VERSION3 ) {
605 rs->sr_rspoid = NULL;
606 rs->sr_tag = slap_req2res( op->o_tag );
607 rs->sr_msgid = (rs->sr_tag != LBER_SEQUENCE) ? op->o_msgid : 0;
610 rs->sr_rspoid = LDAP_NOTICE_DISCONNECT;
611 rs->sr_tag = LDAP_RES_EXTENDED;
612 rs->sr_msgid = LDAP_RES_UNSOLICITED;
615 if ( send_ldap_response( op, rs ) == SLAP_CB_CONTINUE ) {
616 Statslog( LDAP_DEBUG_STATS,
617 "%s DISCONNECT tag=%lu err=%d text=%s\n",
618 op->o_log_prefix, rs->sr_tag, rs->sr_err,
619 rs->sr_text ? rs->sr_text : "", 0 );
624 slap_send_ldap_result( Operation *op, SlapReply *rs )
627 const char *otext = rs->sr_text;
628 BerVarray oref = rs->sr_ref;
630 rs->sr_type = REP_RESULT;
632 /* Propagate Abandons so that cleanup callbacks can be processed */
633 if ( rs->sr_err == SLAPD_ABANDON || op->o_abandon )
636 assert( !LDAP_API_ERROR( rs->sr_err ) );
638 Debug( LDAP_DEBUG_TRACE,
639 "send_ldap_result: %s p=%d\n",
640 op->o_log_prefix, op->o_protocol, 0 );
642 Debug( LDAP_DEBUG_ARGS,
643 "send_ldap_result: err=%d matched=\"%s\" text=\"%s\"\n",
644 rs->sr_err, rs->sr_matched ? rs->sr_matched : "",
645 rs->sr_text ? rs->sr_text : "" );
649 Debug( LDAP_DEBUG_ARGS,
650 "send_ldap_result: referral=\"%s\"\n",
651 rs->sr_ref[0].bv_val ? rs->sr_ref[0].bv_val : "NULL",
655 assert( rs->sr_err != LDAP_PARTIAL_RESULTS );
657 if ( rs->sr_err == LDAP_REFERRAL ) {
658 if( op->o_domain_scope ) rs->sr_ref = NULL;
660 if( rs->sr_ref == NULL ) {
661 rs->sr_err = LDAP_NO_SUCH_OBJECT;
662 } else if ( op->o_protocol < LDAP_VERSION3 ) {
663 rs->sr_err = LDAP_PARTIAL_RESULTS;
667 if ( op->o_protocol < LDAP_VERSION3 ) {
668 tmp = v2ref( rs->sr_ref, rs->sr_text );
674 rs->sr_tag = slap_req2res( op->o_tag );
675 rs->sr_msgid = (rs->sr_tag != LBER_SEQUENCE) ? op->o_msgid : 0;
677 if ( rs->sr_flags & REP_REF_MUSTBEFREED ) {
678 if ( rs->sr_ref == NULL ) {
679 rs->sr_flags ^= REP_REF_MUSTBEFREED;
680 ber_bvarray_free( oref );
682 oref = NULL; /* send_ldap_response() will free rs->sr_ref if != NULL */
685 if ( send_ldap_response( op, rs ) == SLAP_CB_CONTINUE ) {
686 if ( op->o_tag == LDAP_REQ_SEARCH ) {
687 Statslog( LDAP_DEBUG_STATS,
688 "%s SEARCH RESULT tag=%lu err=%d nentries=%d text=%s\n",
689 op->o_log_prefix, rs->sr_tag, rs->sr_err,
690 rs->sr_nentries, rs->sr_text ? rs->sr_text : "" );
692 Statslog( LDAP_DEBUG_STATS,
693 "%s RESULT tag=%lu err=%d text=%s\n",
694 op->o_log_prefix, rs->sr_tag, rs->sr_err,
695 rs->sr_text ? rs->sr_text : "", 0 );
699 if( tmp != NULL ) ch_free(tmp);
705 send_ldap_sasl( Operation *op, SlapReply *rs )
707 rs->sr_type = REP_SASL;
708 Debug( LDAP_DEBUG_TRACE, "send_ldap_sasl: err=%d len=%ld\n",
710 rs->sr_sasldata ? (long) rs->sr_sasldata->bv_len : -1, NULL );
712 rs->sr_tag = slap_req2res( op->o_tag );
713 rs->sr_msgid = (rs->sr_tag != LBER_SEQUENCE) ? op->o_msgid : 0;
715 if ( send_ldap_response( op, rs ) == SLAP_CB_CONTINUE ) {
716 Statslog( LDAP_DEBUG_STATS,
717 "%s RESULT tag=%lu err=%d text=%s\n",
718 op->o_log_prefix, rs->sr_tag, rs->sr_err,
719 rs->sr_text ? rs->sr_text : "", 0 );
724 slap_send_ldap_extended( Operation *op, SlapReply *rs )
726 rs->sr_type = REP_EXTENDED;
728 Debug( LDAP_DEBUG_TRACE,
729 "send_ldap_extended: err=%d oid=%s len=%ld\n",
731 rs->sr_rspoid ? rs->sr_rspoid : "",
732 rs->sr_rspdata != NULL ? rs->sr_rspdata->bv_len : 0 );
734 rs->sr_tag = slap_req2res( op->o_tag );
735 rs->sr_msgid = (rs->sr_tag != LBER_SEQUENCE) ? op->o_msgid : 0;
737 if ( send_ldap_response( op, rs ) == SLAP_CB_CONTINUE ) {
738 Statslog( LDAP_DEBUG_STATS,
739 "%s RESULT oid=%s err=%d text=%s\n",
740 op->o_log_prefix, rs->sr_rspoid ? rs->sr_rspoid : "",
741 rs->sr_err, rs->sr_text ? rs->sr_text : "", 0 );
746 slap_send_ldap_intermediate( Operation *op, SlapReply *rs )
748 rs->sr_type = REP_INTERMEDIATE;
749 Debug( LDAP_DEBUG_TRACE,
750 "send_ldap_intermediate: err=%d oid=%s len=%ld\n",
752 rs->sr_rspoid ? rs->sr_rspoid : "",
753 rs->sr_rspdata != NULL ? rs->sr_rspdata->bv_len : 0 );
754 rs->sr_tag = LDAP_RES_INTERMEDIATE;
755 rs->sr_msgid = op->o_msgid;
756 if ( send_ldap_response( op, rs ) == SLAP_CB_CONTINUE ) {
757 Statslog( LDAP_DEBUG_STATS2,
758 "%s INTERM oid=%s\n",
760 rs->sr_rspoid ? rs->sr_rspoid : "", 0, 0, 0 );
767 * LDAP_SUCCESS entry sent
768 * LDAP_OTHER entry not sent (other)
769 * LDAP_INSUFFICIENT_ACCESS entry not sent (ACL)
770 * LDAP_UNAVAILABLE entry not sent (connection closed)
771 * LDAP_SIZELIMIT_EXCEEDED entry not sent (caller must send sizelimitExceeded)
775 slap_send_search_entry( Operation *op, SlapReply *rs )
777 BerElementBuffer berbuf;
778 BerElement *ber = (BerElement *) &berbuf;
780 int i, j, rc = LDAP_UNAVAILABLE, bytes;
782 AccessControlState acl_state = ACL_STATE_INIT;
784 AttributeDescription *ad_entry = slap_schema.si_ad_entry;
786 /* a_flags: array of flags telling if the i-th element will be
787 * returned or filtered out
788 * e_flags: array of a_flags
790 char **e_flags = NULL;
792 if ( op->ors_slimit >= 0 && rs->sr_nentries >= op->ors_slimit ) {
793 return LDAP_SIZELIMIT_EXCEEDED;
796 /* Every 64 entries, check for thread pool pause */
797 if ( ( ( rs->sr_nentries & 0x3f ) == 0x3f ) &&
798 ldap_pvt_thread_pool_pausing( &connection_pool ) > 0 )
803 rs->sr_type = REP_SEARCH;
805 /* eventually will loop through generated operational attribute types
806 * currently implemented types include:
807 * entryDN, subschemaSubentry, and hasSubordinates */
808 /* NOTE: moved before overlays callback circling because
809 * they may modify entry and other stuff in rs */
810 /* check for special all operational attributes ("+") type */
811 /* FIXME: maybe we could set this flag at the operation level;
812 * however, in principle the caller of send_search_entry() may
813 * change the attribute list at each call */
814 rs->sr_attr_flags = slap_attr_flags( rs->sr_attrs );
816 rc = backend_operational( op, rs );
821 if ( op->o_callback ) {
822 rc = slap_response_play( op, rs );
823 if ( rc != SLAP_CB_CONTINUE ) {
828 Debug( LDAP_DEBUG_TRACE, "=> send_search_entry: conn %lu dn=\"%s\"%s\n",
829 op->o_connid, rs->sr_entry->e_name.bv_val,
830 op->ors_attrsonly ? " (attrsOnly)" : "" );
832 attrsonly = op->ors_attrsonly;
834 if ( !access_allowed( op, rs->sr_entry, ad_entry, NULL, ACL_READ, NULL )) {
835 Debug( LDAP_DEBUG_ACL,
836 "send_search_entry: conn %lu access to entry (%s) not allowed\n",
837 op->o_connid, rs->sr_entry->e_name.bv_val, 0 );
839 rc = LDAP_INSUFFICIENT_ACCESS;
843 if ( op->o_res_ber ) {
844 /* read back control or LDAP_CONNECTIONLESS */
849 bv.bv_len = entry_flatsize( rs->sr_entry, 0 );
850 bv.bv_val = op->o_tmpalloc( bv.bv_len, op->o_tmpmemctx );
852 ber_init2( ber, &bv, LBER_USE_DER );
853 ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
856 #ifdef LDAP_CONNECTIONLESS
857 if ( op->o_conn && op->o_conn->c_is_udp ) {
859 if ( op->o_protocol == LDAP_VERSION2 ) {
860 rc = ber_printf(ber, "t{O{" /*}}*/,
861 LDAP_RES_SEARCH_ENTRY, &rs->sr_entry->e_name );
863 rc = ber_printf( ber, "{it{O{" /*}}}*/, op->o_msgid,
864 LDAP_RES_SEARCH_ENTRY, &rs->sr_entry->e_name );
868 if ( op->o_res_ber ) {
869 /* read back control */
870 rc = ber_printf( ber, "{O{" /*}}*/, &rs->sr_entry->e_name );
872 rc = ber_printf( ber, "{it{O{" /*}}}*/, op->o_msgid,
873 LDAP_RES_SEARCH_ENTRY, &rs->sr_entry->e_name );
877 Debug( LDAP_DEBUG_ANY,
878 "send_search_entry: conn %lu ber_printf failed\n",
879 op->o_connid, 0, 0 );
881 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
882 send_ldap_error( op, rs, LDAP_OTHER, "encoding DN error" );
887 /* check for special all user attributes ("*") type */
888 userattrs = SLAP_USERATTRS( rs->sr_attr_flags );
890 /* create an array of arrays of flags. Each flag corresponds
891 * to particular value of attribute and equals 1 if value matches
892 * to ValuesReturnFilter or 0 if not
894 if ( op->o_vrFilter != NULL ) {
898 for ( a = rs->sr_entry->e_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
899 for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) k++;
902 size = i * sizeof(char *) + k;
905 e_flags = slap_sl_calloc ( 1, i * sizeof(char *) + k, op->o_tmpmemctx );
906 if( e_flags == NULL ) {
907 Debug( LDAP_DEBUG_ANY,
908 "send_search_entry: conn %lu slap_sl_calloc failed\n",
909 op->o_connid ? op->o_connid : 0, 0, 0 );
912 send_ldap_error( op, rs, LDAP_OTHER, "out of memory" );
915 a_flags = (char *)(e_flags + i);
916 memset( a_flags, 0, k );
917 for ( a=rs->sr_entry->e_attrs, i=0; a != NULL; a=a->a_next, i++ ) {
918 for ( j = 0; a->a_vals[j].bv_val != NULL; j++ );
919 e_flags[i] = a_flags;
923 rc = filter_matched_values(op, rs->sr_entry->e_attrs, &e_flags) ;
925 Debug( LDAP_DEBUG_ANY, "send_search_entry: "
926 "conn %lu matched values filtering failed\n",
927 op->o_connid ? op->o_connid : 0, 0, 0 );
928 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
929 send_ldap_error( op, rs, LDAP_OTHER,
930 "matched values filtering error" );
937 for ( a = rs->sr_entry->e_attrs, j = 0; a != NULL; a = a->a_next, j++ ) {
938 AttributeDescription *desc = a->a_desc;
941 if ( rs->sr_attrs == NULL ) {
942 /* all user attrs request, skip operational attributes */
943 if( is_at_operational( desc->ad_type ) ) {
948 /* specific attrs requested */
949 if ( is_at_operational( desc->ad_type ) ) {
950 /* if not explicitly requested */
951 if ( !ad_inlist( desc, rs->sr_attrs )) {
952 /* if not all op attrs requested, skip */
953 if ( !SLAP_OPATTRS( rs->sr_attr_flags ))
955 /* if DSA-specific and replicating, skip */
956 if ( op->o_sync != SLAP_CONTROL_NONE &&
957 desc->ad_type->sat_usage == LDAP_SCHEMA_DSA_OPERATION )
961 if ( !userattrs && !ad_inlist( desc, rs->sr_attrs ) ) {
968 if ( ! access_allowed( op, rs->sr_entry, desc, NULL,
969 ACL_READ, &acl_state ) )
971 Debug( LDAP_DEBUG_ACL, "send_search_entry: "
972 "conn %lu access to attribute %s not allowed\n",
973 op->o_connid, desc->ad_cname.bv_val, 0 );
977 if (( rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname )) == -1 ) {
978 Debug( LDAP_DEBUG_ANY,
979 "send_search_entry: conn %lu ber_printf failed\n",
980 op->o_connid, 0, 0 );
982 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
983 send_ldap_error( op, rs, LDAP_OTHER,
984 "encoding description error");
992 for ( i = 0; a->a_nvals[i].bv_val != NULL; i++ ) {
993 if ( ! access_allowed( op, rs->sr_entry,
994 desc, &a->a_nvals[i], ACL_READ, &acl_state ) )
996 Debug( LDAP_DEBUG_ACL,
997 "send_search_entry: conn %lu "
998 "access to attribute %s, value #%d not allowed\n",
999 op->o_connid, desc->ad_cname.bv_val, i );
1004 if ( op->o_vrFilter && e_flags[j][i] == 0 ){
1011 if (( rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname )) == -1 ) {
1012 Debug( LDAP_DEBUG_ANY,
1013 "send_search_entry: conn %lu ber_printf failed\n",
1014 op->o_connid, 0, 0 );
1016 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1017 send_ldap_error( op, rs, LDAP_OTHER,
1018 "encoding description error");
1023 if (( rc = ber_printf( ber, "O", &a->a_vals[i] )) == -1 ) {
1024 Debug( LDAP_DEBUG_ANY,
1025 "send_search_entry: conn %lu "
1026 "ber_printf failed.\n", op->o_connid, 0, 0 );
1028 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1029 send_ldap_error( op, rs, LDAP_OTHER,
1030 "encoding values error" );
1037 if ( finish && ( rc = ber_printf( ber, /*{[*/ "]N}" )) == -1 ) {
1038 Debug( LDAP_DEBUG_ANY,
1039 "send_search_entry: conn %lu ber_printf failed\n",
1040 op->o_connid, 0, 0 );
1042 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1043 send_ldap_error( op, rs, LDAP_OTHER, "encode end error" );
1049 /* NOTE: moved before overlays callback circling because
1050 * they may modify entry and other stuff in rs */
1051 if ( rs->sr_operational_attrs != NULL && op->o_vrFilter != NULL ) {
1055 for ( a = rs->sr_operational_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
1056 for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) k++;
1059 size = i * sizeof(char *) + k;
1061 char *a_flags, **tmp;
1064 * Reuse previous memory - we likely need less space
1065 * for operational attributes
1067 tmp = slap_sl_realloc( e_flags, i * sizeof(char *) + k,
1069 if ( tmp == NULL ) {
1070 Debug( LDAP_DEBUG_ANY,
1071 "send_search_entry: conn %lu "
1072 "not enough memory "
1073 "for matched values filtering\n",
1074 op->o_connid, 0, 0 );
1075 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1076 send_ldap_error( op, rs, LDAP_OTHER,
1077 "not enough memory for matched values filtering" );
1081 a_flags = (char *)(e_flags + i);
1082 memset( a_flags, 0, k );
1083 for ( a = rs->sr_operational_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
1084 for ( j = 0; a->a_vals[j].bv_val != NULL; j++ );
1085 e_flags[i] = a_flags;
1088 rc = filter_matched_values(op, rs->sr_operational_attrs, &e_flags) ;
1091 Debug( LDAP_DEBUG_ANY,
1092 "send_search_entry: conn %lu "
1093 "matched values filtering failed\n",
1094 op->o_connid ? op->o_connid : 0, 0, 0);
1095 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1096 send_ldap_error( op, rs, LDAP_OTHER,
1097 "matched values filtering error" );
1104 for (a = rs->sr_operational_attrs, j=0; a != NULL; a = a->a_next, j++ ) {
1105 AttributeDescription *desc = a->a_desc;
1107 if ( rs->sr_attrs == NULL ) {
1108 /* all user attrs request, skip operational attributes */
1109 if( is_at_operational( desc->ad_type ) ) {
1114 /* specific attrs requested */
1115 if( is_at_operational( desc->ad_type ) ) {
1116 if ( !SLAP_OPATTRS( rs->sr_attr_flags ) &&
1117 !ad_inlist( desc, rs->sr_attrs ) )
1122 if ( !userattrs && !ad_inlist( desc, rs->sr_attrs ) ) {
1128 if ( ! access_allowed( op, rs->sr_entry, desc, NULL,
1129 ACL_READ, &acl_state ) )
1131 Debug( LDAP_DEBUG_ACL,
1132 "send_search_entry: conn %lu "
1133 "access to attribute %s not allowed\n",
1134 op->o_connid, desc->ad_cname.bv_val, 0 );
1139 rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname );
1141 Debug( LDAP_DEBUG_ANY,
1142 "send_search_entry: conn %lu "
1143 "ber_printf failed\n", op->o_connid, 0, 0 );
1145 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1146 send_ldap_error( op, rs, LDAP_OTHER,
1147 "encoding description error" );
1152 if ( ! attrsonly ) {
1153 for ( i = 0; a->a_vals[i].bv_val != NULL; i++ ) {
1154 if ( ! access_allowed( op, rs->sr_entry,
1155 desc, &a->a_vals[i], ACL_READ, &acl_state ) )
1157 Debug( LDAP_DEBUG_ACL,
1158 "send_search_entry: conn %lu "
1159 "access to %s, value %d not allowed\n",
1160 op->o_connid, desc->ad_cname.bv_val, i );
1165 if ( op->o_vrFilter && e_flags[j][i] == 0 ){
1169 if (( rc = ber_printf( ber, "O", &a->a_vals[i] )) == -1 ) {
1170 Debug( LDAP_DEBUG_ANY,
1171 "send_search_entry: conn %lu ber_printf failed\n",
1172 op->o_connid, 0, 0 );
1174 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1175 send_ldap_error( op, rs, LDAP_OTHER,
1176 "encoding values error" );
1183 if (( rc = ber_printf( ber, /*{[*/ "]N}" )) == -1 ) {
1184 Debug( LDAP_DEBUG_ANY,
1185 "send_search_entry: conn %lu ber_printf failed\n",
1186 op->o_connid, 0, 0 );
1188 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1189 send_ldap_error( op, rs, LDAP_OTHER, "encode end error" );
1197 slap_sl_free( e_flags, op->o_tmpmemctx );
1201 rc = ber_printf( ber, /*{{*/ "}N}" );
1204 rc = send_ldap_controls( op, ber, rs->sr_ctrls );
1208 #ifdef LDAP_CONNECTIONLESS
1209 if( op->o_conn && op->o_conn->c_is_udp ) {
1210 if ( op->o_protocol != LDAP_VERSION2 ) {
1211 rc = ber_printf( ber, /*{*/ "N}" );
1215 if ( op->o_res_ber == NULL ) {
1216 rc = ber_printf( ber, /*{*/ "N}" );
1221 Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
1223 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1224 send_ldap_error( op, rs, LDAP_OTHER, "encode entry end error" );
1229 Statslog( LDAP_DEBUG_STATS2, "%s ENTRY dn=\"%s\"\n",
1230 op->o_log_prefix, rs->sr_entry->e_nname.bv_val, 0, 0, 0 );
1232 if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
1233 be_entry_release_rw( op, rs->sr_entry, 0 );
1234 rs->sr_flags ^= REP_ENTRY_MUSTRELEASE;
1235 rs->sr_entry = NULL;
1238 if ( op->o_res_ber == NULL ) {
1239 bytes = send_ldap_ber( op->o_conn, ber );
1240 ber_free_buf( ber );
1243 Debug( LDAP_DEBUG_ANY,
1244 "send_search_entry: conn %lu ber write failed.\n",
1245 op->o_connid, 0, 0 );
1247 rc = LDAP_UNAVAILABLE;
1252 ldap_pvt_thread_mutex_lock( &op->o_counters->sc_mutex );
1253 ldap_pvt_mp_add_ulong( op->o_counters->sc_bytes, (unsigned long)bytes );
1254 ldap_pvt_mp_add_ulong( op->o_counters->sc_entries, 1 );
1255 ldap_pvt_mp_add_ulong( op->o_counters->sc_pdu, 1 );
1256 ldap_pvt_thread_mutex_unlock( &op->o_counters->sc_mutex );
1259 Debug( LDAP_DEBUG_TRACE,
1260 "<= send_search_entry: conn %lu exit.\n", op->o_connid, 0, 0 );
1265 if ( op->o_callback ) {
1266 (void)slap_cleanup_play( op, rs );
1270 slap_sl_free( e_flags, op->o_tmpmemctx );
1273 if ( rs->sr_operational_attrs ) {
1274 attrs_free( rs->sr_operational_attrs );
1275 rs->sr_operational_attrs = NULL;
1277 rs->sr_attr_flags = SLAP_ATTRS_UNDEFINED;
1279 /* FIXME: I think rs->sr_type should be explicitly set to
1280 * REP_SEARCH here. That's what it was when we entered this
1281 * function. send_ldap_error may have changed it, but we
1282 * should set it back so that the cleanup functions know
1283 * what they're doing.
1285 if ( op->o_tag == LDAP_REQ_SEARCH && rs->sr_type == REP_SEARCH
1287 && ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) )
1289 entry_free( rs->sr_entry );
1290 rs->sr_entry = NULL;
1291 rs->sr_flags &= ~REP_ENTRY_MUSTBEFREED;
1298 slap_send_search_reference( Operation *op, SlapReply *rs )
1300 BerElementBuffer berbuf;
1301 BerElement *ber = (BerElement *) &berbuf;
1304 char *edn = rs->sr_entry ? rs->sr_entry->e_name.bv_val : "(null)";
1306 AttributeDescription *ad_ref = slap_schema.si_ad_ref;
1307 AttributeDescription *ad_entry = slap_schema.si_ad_entry;
1309 rs->sr_type = REP_SEARCHREF;
1310 if ( op->o_callback ) {
1311 rc = slap_response_play( op, rs );
1312 if ( rc != SLAP_CB_CONTINUE ) {
1317 Debug( LDAP_DEBUG_TRACE,
1318 "=> send_search_reference: dn=\"%s\"\n",
1321 if ( rs->sr_entry && ! access_allowed( op, rs->sr_entry,
1322 ad_entry, NULL, ACL_READ, NULL ) )
1324 Debug( LDAP_DEBUG_ACL,
1325 "send_search_reference: access to entry not allowed\n",
1331 if ( rs->sr_entry && ! access_allowed( op, rs->sr_entry,
1332 ad_ref, NULL, ACL_READ, NULL ) )
1334 Debug( LDAP_DEBUG_ACL,
1335 "send_search_reference: access "
1336 "to reference not allowed\n",
1342 if( op->o_domain_scope ) {
1343 Debug( LDAP_DEBUG_ANY,
1344 "send_search_reference: domainScope control in (%s)\n",
1350 if( rs->sr_ref == NULL ) {
1351 Debug( LDAP_DEBUG_ANY,
1352 "send_search_reference: null ref in (%s)\n",
1358 if( op->o_protocol < LDAP_VERSION3 ) {
1360 /* save the references for the result */
1361 if( rs->sr_ref[0].bv_val != NULL ) {
1362 if( value_add( &rs->sr_v2ref, rs->sr_ref ) )
1368 #ifdef LDAP_CONNECTIONLESS
1369 if( op->o_conn && op->o_conn->c_is_udp ) {
1370 ber = op->o_res_ber;
1374 ber_init_w_nullc( ber, LBER_USE_DER );
1375 ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
1378 rc = ber_printf( ber, "{it{W}" /*"}"*/ , op->o_msgid,
1379 LDAP_RES_SEARCH_REFERENCE, rs->sr_ref );
1382 rc = send_ldap_controls( op, ber, rs->sr_ctrls );
1386 rc = ber_printf( ber, /*"{"*/ "N}" );
1390 Debug( LDAP_DEBUG_ANY,
1391 "send_search_reference: ber_printf failed\n", 0, 0, 0 );
1393 #ifdef LDAP_CONNECTIONLESS
1394 if (!op->o_conn || op->o_conn->c_is_udp == 0)
1396 ber_free_buf( ber );
1397 send_ldap_error( op, rs, LDAP_OTHER, "encode DN error" );
1402 if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
1403 assert( rs->sr_entry != NULL );
1404 be_entry_release_rw( op, rs->sr_entry, 0 );
1405 rs->sr_flags ^= REP_ENTRY_MUSTRELEASE;
1406 rs->sr_entry = NULL;
1409 #ifdef LDAP_CONNECTIONLESS
1410 if (!op->o_conn || op->o_conn->c_is_udp == 0) {
1412 bytes = send_ldap_ber( op->o_conn, ber );
1413 ber_free_buf( ber );
1416 rc = LDAP_UNAVAILABLE;
1418 ldap_pvt_thread_mutex_lock( &op->o_counters->sc_mutex );
1419 ldap_pvt_mp_add_ulong( op->o_counters->sc_bytes, (unsigned long)bytes );
1420 ldap_pvt_mp_add_ulong( op->o_counters->sc_refs, 1 );
1421 ldap_pvt_mp_add_ulong( op->o_counters->sc_pdu, 1 );
1422 ldap_pvt_thread_mutex_unlock( &op->o_counters->sc_mutex );
1424 #ifdef LDAP_CONNECTIONLESS
1427 if ( rs->sr_ref != NULL ) {
1430 for ( r = 0; !BER_BVISNULL( &rs->sr_ref[ r ] ); r++ ) {
1431 Statslog( LDAP_DEBUG_STATS2, "%s REF #%d \"%s\"\n",
1432 op->o_log_prefix, r, rs->sr_ref[0].bv_val,
1437 Statslog( LDAP_DEBUG_STATS2, "%s REF \"(null)\"\n",
1438 op->o_log_prefix, 0, 0, 0, 0 );
1441 Debug( LDAP_DEBUG_TRACE, "<= send_search_reference\n", 0, 0, 0 );
1444 if ( op->o_callback ) {
1445 (void)slap_cleanup_play( op, rs );
1461 *code = LDAP_SUCCESS;
1465 if ( strncasecmp( s, "RESULT", STRLENOF( "RESULT" ) ) != 0 ) {
1466 Debug( LDAP_DEBUG_ANY, "str2result (%s) expecting \"RESULT\"\n",
1473 while ( (s = strchr( s, '\n' )) != NULL ) {
1478 if ( (c = strchr( s, ':' )) != NULL ) {
1482 if ( strncasecmp( s, "code", STRLENOF( "code" ) ) == 0 ) {
1487 Debug( LDAP_DEBUG_ANY, "str2result (%s) missing value\n",
1493 while ( isspace( (unsigned char) c[ 0 ] ) ) c++;
1494 if ( c[ 0 ] == '\0' ) {
1495 Debug( LDAP_DEBUG_ANY, "str2result (%s) missing or empty value\n",
1501 retcode = strtol( c, &next, 10 );
1502 if ( next == NULL || next == c ) {
1503 Debug( LDAP_DEBUG_ANY, "str2result (%s) unable to parse value\n",
1509 while ( isspace( (unsigned char) next[ 0 ] ) ) next++;
1510 if ( next[ 0 ] != '\0' ) {
1511 Debug( LDAP_DEBUG_ANY, "str2result (%s) extra cruft after value\n",
1517 /* FIXME: what if it's larger that max int? */
1518 *code = (int)retcode;
1520 } else if ( strncasecmp( s, "matched", STRLENOF( "matched" ) ) == 0 ) {
1524 } else if ( strncasecmp( s, "info", STRLENOF( "info" ) ) == 0 ) {
1529 Debug( LDAP_DEBUG_ANY, "str2result (%s) unknown\n",
1539 int slap_read_controls(
1543 const struct berval *oid,
1544 LDAPControl **ctrl )
1548 BerElementBuffer berbuf;
1549 BerElement *ber = (BerElement *) &berbuf;
1553 Debug( LDAP_DEBUG_ANY, "%s slap_read_controls: (%s) %s\n",
1554 op->o_log_prefix, oid->bv_val, e->e_dn );
1557 rs->sr_attrs = ( oid == &slap_pre_read_bv ) ?
1558 op->o_preread_attrs : op->o_postread_attrs;
1560 bv.bv_len = entry_flatsize( rs->sr_entry, 0 );
1561 bv.bv_val = op->o_tmpalloc( bv.bv_len, op->o_tmpmemctx );
1563 ber_init2( ber, &bv, LBER_USE_DER );
1564 ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
1566 /* create new operation */
1568 /* FIXME: o_bd needed for ACL */
1569 myop.o_bd = op->o_bd;
1570 myop.o_res_ber = ber;
1571 myop.o_callback = NULL;
1572 myop.ors_slimit = 1;
1574 rc = slap_send_search_entry( &myop, rs );
1577 rc = ber_flatten2( ber, &c.ldctl_value, 0 );
1579 if( rc == -1 ) return LDAP_OTHER;
1581 c.ldctl_oid = oid->bv_val;
1582 c.ldctl_iscritical = 0;
1584 if ( *ctrl == NULL ) {
1586 *ctrl = (LDAPControl *) slap_sl_calloc( 1, sizeof(LDAPControl), NULL );
1588 /* retry: free previous try */
1589 slap_sl_free( (*ctrl)->ldctl_value.bv_val, op->o_tmpmemctx );
1593 return LDAP_SUCCESS;
1596 /* Map API errors to protocol errors... */
1598 slap_map_api2result( SlapReply *rs )
1600 switch(rs->sr_err) {
1601 case LDAP_SERVER_DOWN:
1602 return LDAP_UNAVAILABLE;
1603 case LDAP_LOCAL_ERROR:
1605 case LDAP_ENCODING_ERROR:
1606 case LDAP_DECODING_ERROR:
1607 return LDAP_PROTOCOL_ERROR;
1609 return LDAP_UNAVAILABLE;
1610 case LDAP_AUTH_UNKNOWN:
1611 return LDAP_AUTH_METHOD_NOT_SUPPORTED;
1612 case LDAP_FILTER_ERROR:
1613 rs->sr_text = "Filter error";
1615 case LDAP_USER_CANCELLED:
1616 rs->sr_text = "User cancelled";
1618 case LDAP_PARAM_ERROR:
1619 return LDAP_PROTOCOL_ERROR;
1620 case LDAP_NO_MEMORY:
1622 case LDAP_CONNECT_ERROR:
1623 return LDAP_UNAVAILABLE;
1624 case LDAP_NOT_SUPPORTED:
1625 return LDAP_UNWILLING_TO_PERFORM;
1626 case LDAP_CONTROL_NOT_FOUND:
1627 return LDAP_PROTOCOL_ERROR;
1628 case LDAP_NO_RESULTS_RETURNED:
1629 return LDAP_NO_SUCH_OBJECT;
1630 case LDAP_MORE_RESULTS_TO_RETURN:
1631 rs->sr_text = "More results to return";
1633 case LDAP_CLIENT_LOOP:
1634 case LDAP_REFERRAL_LIMIT_EXCEEDED:
1635 return LDAP_LOOP_DETECT;
1637 if ( LDAP_API_ERROR(rs->sr_err) ) return LDAP_OTHER;
1644 slap_attr_flags( AttributeName *an )
1646 slap_mask_t flags = SLAP_ATTRS_UNDEFINED;
1649 flags |= ( SLAP_OPATTRS_NO | SLAP_USERATTRS_YES );
1652 flags |= an_find( an, &AllOper )
1653 ? SLAP_OPATTRS_YES : SLAP_OPATTRS_NO;
1654 flags |= an_find( an, &AllUser )
1655 ? SLAP_USERATTRS_YES : SLAP_USERATTRS_NO;