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-2008 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 while ( conn->c_writers > 0 ) {
148 ldap_pvt_thread_cond_wait( &conn->c_write1_cv, &conn->c_write1_mutex );
150 /* connection was closed under us */
151 if ( conn->c_writers < 0 ) {
153 /* we're the last waiter, let the closer continue */
154 if ( conn->c_writers == -1 )
155 ldap_pvt_thread_cond_signal( &conn->c_write1_cv );
159 ldap_pvt_thread_mutex_unlock( &conn->c_write1_mutex );
168 /* lock the connection */
169 ldap_pvt_thread_mutex_lock( &conn->c_mutex );
171 if ( ber_flush2( conn->c_sb, ber, LBER_FLUSH_FREE_NEVER ) == 0 ) {
172 ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
180 * we got an error. if it's ewouldblock, we need to
181 * wait on the socket being writable. otherwise, figure
182 * it's a hard error and return.
185 Debug( LDAP_DEBUG_CONNS, "ber_flush2 failed errno=%d reason=\"%s\"\n",
186 err, sock_errstr(err), 0 );
188 if ( err != EWOULDBLOCK && err != EAGAIN ) {
189 connection_closing( conn, "connection lost on write" );
191 ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
197 /* wait for socket to be write-ready */
198 ldap_pvt_thread_mutex_lock( &conn->c_write2_mutex );
199 conn->c_writewaiter = 1;
200 slapd_set_write( conn->c_sd, 1 );
202 ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
203 ldap_pvt_thread_cond_wait( &conn->c_write2_cv, &conn->c_write2_mutex );
204 conn->c_writewaiter = 0;
205 ldap_pvt_thread_mutex_unlock( &conn->c_write2_mutex );
206 ldap_pvt_thread_mutex_lock( &conn->c_write1_mutex );
207 closing = ( conn->c_writers < 0 );
208 ldap_pvt_thread_mutex_unlock( &conn->c_write1_mutex );
215 ldap_pvt_thread_mutex_lock( &conn->c_write1_mutex );
216 if ( conn->c_writers < 0 ) {
218 if ( !conn->c_writers )
219 ldap_pvt_thread_cond_signal( &conn->c_write1_cv );
222 ldap_pvt_thread_cond_signal( &conn->c_write1_cv );
224 ldap_pvt_thread_mutex_unlock( &conn->c_write1_mutex );
230 send_ldap_control( BerElement *ber, LDAPControl *c )
236 rc = ber_printf( ber, "{s" /*}*/, c->ldctl_oid );
238 if( c->ldctl_iscritical ) {
239 rc = ber_printf( ber, "b",
240 (ber_int_t) c->ldctl_iscritical ) ;
241 if( rc == -1 ) return rc;
244 if( c->ldctl_value.bv_val != NULL ) {
245 rc = ber_printf( ber, "O", &c->ldctl_value );
246 if( rc == -1 ) return rc;
249 rc = ber_printf( ber, /*{*/"N}" );
250 if( rc == -1 ) return rc;
256 send_ldap_controls( Operation *o, BerElement *ber, LDAPControl **c )
263 rc = ber_printf( ber, "t{"/*}*/, LDAP_TAG_CONTROLS );
264 if( rc == -1 ) return rc;
266 for( ; *c != NULL; c++) {
267 rc = send_ldap_control( ber, *c );
268 if( rc == -1 ) return rc;
271 #ifdef SLAP_CONTROL_X_SORTEDRESULTS
272 /* this is a hack to avoid having to modify op->s_ctrls */
273 if( o->o_sortedresults ) {
274 BerElementBuffer berbuf;
275 BerElement *sber = (BerElement *) &berbuf;
277 BER_BVZERO( &sorted.ldctl_value );
278 sorted.ldctl_oid = LDAP_CONTROL_SORTRESPONSE;
279 sorted.ldctl_iscritical = 0;
281 ber_init2( sber, NULL, LBER_USE_DER );
283 ber_printf( sber, "{e}", LDAP_UNWILLING_TO_PERFORM );
285 if( ber_flatten2( ber, &sorted.ldctl_value, 0 ) == -1 ) {
289 (void) ber_free_buf( ber );
291 rc = send_ldap_control( ber, &sorted );
292 if( rc == -1 ) return rc;
296 rc = ber_printf( ber, /*{*/"N}" );
302 * slap_response_play()
304 * plays the callback list; rationale: a callback can
305 * - remove itself from the list, by setting op->o_callback = NULL;
306 * malloc()'ed callbacks should free themselves from inside the
307 * sc_response() function.
308 * - replace itself with another (list of) callback(s), by setting
309 * op->o_callback = a new (list of) callback(s); in this case, it
310 * is the callback's responsibility to to append existing subsequent
311 * callbacks to the end of the list that is passed to the sc_response()
313 * - modify the list of subsequent callbacks by modifying the value
314 * of the sc_next field from inside the sc_response() function; this
315 * case does not require any handling from inside slap_response_play()
317 * To stop execution of the playlist, the sc_response() function must return
318 * a value different from SLAP_SC_CONTINUE.
320 * The same applies to slap_cleanup_play(); only, there is no means to stop
321 * execution of the playlist, since all cleanup functions must be called.
330 slap_callback *sc = op->o_callback, **scp;
332 rc = SLAP_CB_CONTINUE;
333 for ( scp = ≻ *scp; ) {
334 slap_callback *sc_next = (*scp)->sc_next, **sc_nextp = &(*scp)->sc_next;
336 op->o_callback = *scp;
337 if ( op->o_callback->sc_response ) {
338 rc = op->o_callback->sc_response( op, rs );
339 if ( op->o_callback == NULL ) {
340 /* the callback has been removed;
345 } else if ( op->o_callback != *scp ) {
346 /* a new callback has been inserted
347 * in place of the existing one; repair the list */
348 *scp = op->o_callback;
351 if ( rc != SLAP_CB_CONTINUE ) break;
365 slap_callback *sc = op->o_callback, **scp;
367 for ( scp = ≻ *scp; ) {
368 slap_callback *sc_next = (*scp)->sc_next, **sc_nextp = &(*scp)->sc_next;
370 op->o_callback = *scp;
371 if ( op->o_callback->sc_cleanup ) {
372 (void)op->o_callback->sc_cleanup( op, rs );
373 if ( op->o_callback == NULL ) {
374 /* the callback has been removed;
379 } else if ( op->o_callback != *scp ) {
380 /* a new callback has been inserted
381 * after the existing one; repair the list */
382 /* a new callback has been inserted
383 * in place of the existing one; repair the list */
384 *scp = op->o_callback;
387 /* don't care about the result; do all cleanup */
401 BerElementBuffer berbuf;
402 BerElement *ber = (BerElement *) &berbuf;
403 int rc = LDAP_SUCCESS;
406 if ( rs->sr_err == SLAPD_ABANDON || op->o_abandon ) {
411 if ( op->o_callback ) {
412 rc = slap_response_play( op, rs );
413 if ( rc != SLAP_CB_CONTINUE ) {
418 #ifdef LDAP_CONNECTIONLESS
419 if (op->o_conn && op->o_conn->c_is_udp)
424 ber_init_w_nullc( ber, LBER_USE_DER );
425 ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
428 Debug( LDAP_DEBUG_TRACE,
429 "send_ldap_response: msgid=%d tag=%lu err=%d\n",
430 rs->sr_msgid, rs->sr_tag, rs->sr_err );
433 Debug( LDAP_DEBUG_ARGS, "send_ldap_response: ref=\"%s\"\n",
434 rs->sr_ref[0].bv_val ? rs->sr_ref[0].bv_val : "NULL",
438 #ifdef LDAP_CONNECTIONLESS
439 if (op->o_conn && op->o_conn->c_is_udp &&
440 op->o_protocol == LDAP_VERSION2 )
442 rc = ber_printf( ber, "t{ess" /*"}"*/,
443 rs->sr_tag, rs->sr_err,
444 rs->sr_matched == NULL ? "" : rs->sr_matched,
445 rs->sr_text == NULL ? "" : rs->sr_text );
448 if ( rs->sr_type == REP_INTERMEDIATE ) {
449 rc = ber_printf( ber, "{it{" /*"}}"*/,
450 rs->sr_msgid, rs->sr_tag );
453 rc = ber_printf( ber, "{it{ess" /*"}}"*/,
454 rs->sr_msgid, rs->sr_tag, rs->sr_err,
455 rs->sr_matched == NULL ? "" : rs->sr_matched,
456 rs->sr_text == NULL ? "" : rs->sr_text );
460 if ( rs->sr_ref != NULL ) {
461 assert( rs->sr_err == LDAP_REFERRAL );
462 rc = ber_printf( ber, "t{W}",
463 LDAP_TAG_REFERRAL, rs->sr_ref );
465 assert( rs->sr_err != LDAP_REFERRAL );
469 if( rc != -1 && rs->sr_type == REP_SASL && rs->sr_sasldata != NULL ) {
470 rc = ber_printf( ber, "tO",
471 LDAP_TAG_SASL_RES_CREDS, rs->sr_sasldata );
475 ( rs->sr_type == REP_EXTENDED || rs->sr_type == REP_INTERMEDIATE ))
477 if ( rs->sr_rspoid != NULL ) {
478 rc = ber_printf( ber, "ts",
479 rs->sr_type == REP_EXTENDED
480 ? LDAP_TAG_EXOP_RES_OID : LDAP_TAG_IM_RES_OID,
483 if( rc != -1 && rs->sr_rspdata != NULL ) {
484 rc = ber_printf( ber, "tO",
485 rs->sr_type == REP_EXTENDED
486 ? LDAP_TAG_EXOP_RES_VALUE : LDAP_TAG_IM_RES_VALUE,
492 rc = ber_printf( ber, /*"{"*/ "N}" );
496 rc = send_ldap_controls( op, ber, rs->sr_ctrls );
500 rc = ber_printf( ber, /*"{"*/ "N}" );
503 #ifdef LDAP_CONNECTIONLESS
504 if( op->o_conn && op->o_conn->c_is_udp && op->o_protocol == LDAP_VERSION2
507 rc = ber_printf( ber, /*"{"*/ "N}" );
512 Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
514 #ifdef LDAP_CONNECTIONLESS
515 if (!op->o_conn || op->o_conn->c_is_udp == 0)
524 bytes = send_ldap_ber( op->o_conn, ber );
525 #ifdef LDAP_CONNECTIONLESS
526 if (!op->o_conn || op->o_conn->c_is_udp == 0)
533 Debug( LDAP_DEBUG_ANY,
534 "send_ldap_response: ber write failed\n",
540 ldap_pvt_thread_mutex_lock( &op->o_counters->sc_mutex );
541 ldap_pvt_mp_add_ulong( op->o_counters->sc_pdu, 1 );
542 ldap_pvt_mp_add_ulong( op->o_counters->sc_bytes, (unsigned long)bytes );
543 ldap_pvt_thread_mutex_unlock( &op->o_counters->sc_mutex );
546 /* Tell caller that we did this for real, as opposed to being
547 * overridden by a callback
549 rc = SLAP_CB_CONTINUE;
552 if ( op->o_callback ) {
553 (void)slap_cleanup_play( op, rs );
556 if ( rs->sr_flags & REP_MATCHED_MUSTBEFREED ) {
557 rs->sr_flags ^= REP_MATCHED_MUSTBEFREED; /* paranoia */
558 if ( rs->sr_matched ) {
559 free( (char *)rs->sr_matched );
560 rs->sr_matched = NULL;
564 if ( rs->sr_flags & REP_REF_MUSTBEFREED ) {
565 rs->sr_flags ^= REP_REF_MUSTBEFREED; /* paranoia */
567 ber_bvarray_free( rs->sr_ref );
572 if ( rs->sr_flags & REP_CTRLS_MUSTBEFREED ) {
573 rs->sr_flags ^= REP_CTRLS_MUSTBEFREED; /* paranoia */
574 if ( rs->sr_ctrls ) {
575 slap_free_ctrls( op, rs->sr_ctrls );
585 send_ldap_disconnect( Operation *op, SlapReply *rs )
587 #define LDAP_UNSOLICITED_ERROR(e) \
588 ( (e) == LDAP_PROTOCOL_ERROR \
589 || (e) == LDAP_STRONG_AUTH_REQUIRED \
590 || (e) == LDAP_UNAVAILABLE )
592 assert( LDAP_UNSOLICITED_ERROR( rs->sr_err ) );
594 rs->sr_type = REP_EXTENDED;
596 Debug( LDAP_DEBUG_TRACE,
597 "send_ldap_disconnect %d:%s\n",
598 rs->sr_err, rs->sr_text ? rs->sr_text : "", NULL );
600 if ( op->o_protocol < LDAP_VERSION3 ) {
601 rs->sr_rspoid = NULL;
602 rs->sr_tag = slap_req2res( op->o_tag );
603 rs->sr_msgid = (rs->sr_tag != LBER_SEQUENCE) ? op->o_msgid : 0;
606 rs->sr_rspoid = LDAP_NOTICE_DISCONNECT;
607 rs->sr_tag = LDAP_RES_EXTENDED;
608 rs->sr_msgid = LDAP_RES_UNSOLICITED;
611 if ( send_ldap_response( op, rs ) == SLAP_CB_CONTINUE ) {
612 Statslog( LDAP_DEBUG_STATS,
613 "%s DISCONNECT tag=%lu err=%d text=%s\n",
614 op->o_log_prefix, rs->sr_tag, rs->sr_err,
615 rs->sr_text ? rs->sr_text : "", 0 );
620 slap_send_ldap_result( Operation *op, SlapReply *rs )
623 const char *otext = rs->sr_text;
624 BerVarray oref = rs->sr_ref;
626 rs->sr_type = REP_RESULT;
628 /* Propagate Abandons so that cleanup callbacks can be processed */
629 if ( rs->sr_err == SLAPD_ABANDON || op->o_abandon )
632 assert( !LDAP_API_ERROR( rs->sr_err ) );
634 Debug( LDAP_DEBUG_TRACE,
635 "send_ldap_result: %s p=%d\n",
636 op->o_log_prefix, op->o_protocol, 0 );
638 Debug( LDAP_DEBUG_ARGS,
639 "send_ldap_result: err=%d matched=\"%s\" text=\"%s\"\n",
640 rs->sr_err, rs->sr_matched ? rs->sr_matched : "",
641 rs->sr_text ? rs->sr_text : "" );
645 Debug( LDAP_DEBUG_ARGS,
646 "send_ldap_result: referral=\"%s\"\n",
647 rs->sr_ref[0].bv_val ? rs->sr_ref[0].bv_val : "NULL",
651 assert( rs->sr_err != LDAP_PARTIAL_RESULTS );
653 if ( rs->sr_err == LDAP_REFERRAL ) {
654 if( op->o_domain_scope ) rs->sr_ref = NULL;
656 if( rs->sr_ref == NULL ) {
657 rs->sr_err = LDAP_NO_SUCH_OBJECT;
658 } else if ( op->o_protocol < LDAP_VERSION3 ) {
659 rs->sr_err = LDAP_PARTIAL_RESULTS;
663 if ( op->o_protocol < LDAP_VERSION3 ) {
664 tmp = v2ref( rs->sr_ref, rs->sr_text );
670 rs->sr_tag = slap_req2res( op->o_tag );
671 rs->sr_msgid = (rs->sr_tag != LBER_SEQUENCE) ? op->o_msgid : 0;
673 if ( rs->sr_flags & REP_REF_MUSTBEFREED ) {
674 if ( rs->sr_ref == NULL ) {
675 rs->sr_flags ^= REP_REF_MUSTBEFREED;
676 ber_bvarray_free( oref );
678 oref = NULL; /* send_ldap_response() will free rs->sr_ref if != NULL */
681 if ( send_ldap_response( op, rs ) == SLAP_CB_CONTINUE ) {
682 if ( op->o_tag == LDAP_REQ_SEARCH ) {
683 Statslog( LDAP_DEBUG_STATS,
684 "%s SEARCH RESULT tag=%lu err=%d nentries=%d text=%s\n",
685 op->o_log_prefix, rs->sr_tag, rs->sr_err,
686 rs->sr_nentries, rs->sr_text ? rs->sr_text : "" );
688 Statslog( LDAP_DEBUG_STATS,
689 "%s RESULT tag=%lu err=%d text=%s\n",
690 op->o_log_prefix, rs->sr_tag, rs->sr_err,
691 rs->sr_text ? rs->sr_text : "", 0 );
695 if( tmp != NULL ) ch_free(tmp);
701 send_ldap_sasl( Operation *op, SlapReply *rs )
703 rs->sr_type = REP_SASL;
704 Debug( LDAP_DEBUG_TRACE, "send_ldap_sasl: err=%d len=%ld\n",
706 rs->sr_sasldata ? (long) rs->sr_sasldata->bv_len : -1, NULL );
708 rs->sr_tag = slap_req2res( op->o_tag );
709 rs->sr_msgid = (rs->sr_tag != LBER_SEQUENCE) ? op->o_msgid : 0;
711 if ( send_ldap_response( op, rs ) == SLAP_CB_CONTINUE ) {
712 Statslog( LDAP_DEBUG_STATS,
713 "%s RESULT tag=%lu err=%d text=%s\n",
714 op->o_log_prefix, rs->sr_tag, rs->sr_err,
715 rs->sr_text ? rs->sr_text : "", 0 );
720 slap_send_ldap_extended( Operation *op, SlapReply *rs )
722 rs->sr_type = REP_EXTENDED;
724 Debug( LDAP_DEBUG_TRACE,
725 "send_ldap_extended: err=%d oid=%s len=%ld\n",
727 rs->sr_rspoid ? rs->sr_rspoid : "",
728 rs->sr_rspdata != NULL ? rs->sr_rspdata->bv_len : 0 );
730 rs->sr_tag = slap_req2res( op->o_tag );
731 rs->sr_msgid = (rs->sr_tag != LBER_SEQUENCE) ? op->o_msgid : 0;
733 if ( send_ldap_response( op, rs ) == SLAP_CB_CONTINUE ) {
734 Statslog( LDAP_DEBUG_STATS,
735 "%s RESULT oid=%s err=%d text=%s\n",
736 op->o_log_prefix, rs->sr_rspoid ? rs->sr_rspoid : "",
737 rs->sr_err, rs->sr_text ? rs->sr_text : "", 0 );
742 slap_send_ldap_intermediate( Operation *op, SlapReply *rs )
744 rs->sr_type = REP_INTERMEDIATE;
745 Debug( LDAP_DEBUG_TRACE,
746 "send_ldap_intermediate: err=%d oid=%s len=%ld\n",
748 rs->sr_rspoid ? rs->sr_rspoid : "",
749 rs->sr_rspdata != NULL ? rs->sr_rspdata->bv_len : 0 );
750 rs->sr_tag = LDAP_RES_INTERMEDIATE;
751 rs->sr_msgid = op->o_msgid;
752 if ( send_ldap_response( op, rs ) == SLAP_CB_CONTINUE ) {
753 Statslog( LDAP_DEBUG_STATS2,
754 "%s INTERM oid=%s\n",
756 rs->sr_rspoid ? rs->sr_rspoid : "", 0, 0, 0 );
763 * LDAP_SUCCESS entry sent
764 * LDAP_OTHER entry not sent (other)
765 * LDAP_INSUFFICIENT_ACCESS entry not sent (ACL)
766 * LDAP_UNAVAILABLE entry not sent (connection closed)
767 * LDAP_SIZELIMIT_EXCEEDED entry not sent (caller must send sizelimitExceeded)
771 slap_send_search_entry( Operation *op, SlapReply *rs )
773 BerElementBuffer berbuf;
774 BerElement *ber = (BerElement *) &berbuf;
776 int i, j, rc = LDAP_UNAVAILABLE, bytes;
778 AccessControlState acl_state = ACL_STATE_INIT;
780 AttributeDescription *ad_entry = slap_schema.si_ad_entry;
782 /* a_flags: array of flags telling if the i-th element will be
783 * returned or filtered out
784 * e_flags: array of a_flags
786 char **e_flags = NULL;
788 if ( op->ors_slimit >= 0 && rs->sr_nentries >= op->ors_slimit ) {
789 return LDAP_SIZELIMIT_EXCEEDED;
792 /* Every 64 entries, check for thread pool pause */
793 if ( ( ( rs->sr_nentries & 0x3f ) == 0x3f ) &&
794 ldap_pvt_thread_pool_pausing( &connection_pool ) > 0 )
799 rs->sr_type = REP_SEARCH;
801 /* eventually will loop through generated operational attribute types
802 * currently implemented types include:
803 * entryDN, subschemaSubentry, and hasSubordinates */
804 /* NOTE: moved before overlays callback circling because
805 * they may modify entry and other stuff in rs */
806 /* check for special all operational attributes ("+") type */
807 /* FIXME: maybe we could set this flag at the operation level;
808 * however, in principle the caller of send_search_entry() may
809 * change the attribute list at each call */
810 rs->sr_attr_flags = slap_attr_flags( rs->sr_attrs );
812 rc = backend_operational( op, rs );
817 if ( op->o_callback ) {
818 rc = slap_response_play( op, rs );
819 if ( rc != SLAP_CB_CONTINUE ) {
824 Debug( LDAP_DEBUG_TRACE, "=> send_search_entry: conn %lu dn=\"%s\"%s\n",
825 op->o_connid, rs->sr_entry->e_name.bv_val,
826 op->ors_attrsonly ? " (attrsOnly)" : "" );
828 attrsonly = op->ors_attrsonly;
830 if ( !access_allowed( op, rs->sr_entry, ad_entry, NULL, ACL_READ, NULL )) {
831 Debug( LDAP_DEBUG_ACL,
832 "send_search_entry: conn %lu access to entry (%s) not allowed\n",
833 op->o_connid, rs->sr_entry->e_name.bv_val, 0 );
835 rc = LDAP_INSUFFICIENT_ACCESS;
839 if ( op->o_res_ber ) {
840 /* read back control or LDAP_CONNECTIONLESS */
845 bv.bv_len = entry_flatsize( rs->sr_entry, 0 );
846 bv.bv_val = op->o_tmpalloc( bv.bv_len, op->o_tmpmemctx );
848 ber_init2( ber, &bv, LBER_USE_DER );
849 ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
852 #ifdef LDAP_CONNECTIONLESS
853 if ( op->o_conn && op->o_conn->c_is_udp ) {
855 if ( op->o_protocol == LDAP_VERSION2 ) {
856 rc = ber_printf(ber, "t{O{" /*}}*/,
857 LDAP_RES_SEARCH_ENTRY, &rs->sr_entry->e_name );
859 rc = ber_printf( ber, "{it{O{" /*}}}*/, op->o_msgid,
860 LDAP_RES_SEARCH_ENTRY, &rs->sr_entry->e_name );
864 if ( op->o_res_ber ) {
865 /* read back control */
866 rc = ber_printf( ber, "{O{" /*}}*/, &rs->sr_entry->e_name );
868 rc = ber_printf( ber, "{it{O{" /*}}}*/, op->o_msgid,
869 LDAP_RES_SEARCH_ENTRY, &rs->sr_entry->e_name );
873 Debug( LDAP_DEBUG_ANY,
874 "send_search_entry: conn %lu ber_printf failed\n",
875 op->o_connid, 0, 0 );
877 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
878 send_ldap_error( op, rs, LDAP_OTHER, "encoding DN error" );
883 /* check for special all user attributes ("*") type */
884 userattrs = SLAP_USERATTRS( rs->sr_attr_flags );
886 /* create an array of arrays of flags. Each flag corresponds
887 * to particular value of attribute and equals 1 if value matches
888 * to ValuesReturnFilter or 0 if not
890 if ( op->o_vrFilter != NULL ) {
894 for ( a = rs->sr_entry->e_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
895 for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) k++;
898 size = i * sizeof(char *) + k;
901 e_flags = slap_sl_calloc ( 1, i * sizeof(char *) + k, op->o_tmpmemctx );
902 if( e_flags == NULL ) {
903 Debug( LDAP_DEBUG_ANY,
904 "send_search_entry: conn %lu slap_sl_calloc failed\n",
905 op->o_connid ? op->o_connid : 0, 0, 0 );
908 send_ldap_error( op, rs, LDAP_OTHER, "out of memory" );
911 a_flags = (char *)(e_flags + i);
912 memset( a_flags, 0, k );
913 for ( a=rs->sr_entry->e_attrs, i=0; a != NULL; a=a->a_next, i++ ) {
914 for ( j = 0; a->a_vals[j].bv_val != NULL; j++ );
915 e_flags[i] = a_flags;
919 rc = filter_matched_values(op, rs->sr_entry->e_attrs, &e_flags) ;
921 Debug( LDAP_DEBUG_ANY, "send_search_entry: "
922 "conn %lu matched values filtering failed\n",
923 op->o_connid ? op->o_connid : 0, 0, 0 );
924 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
925 send_ldap_error( op, rs, LDAP_OTHER,
926 "matched values filtering error" );
933 for ( a = rs->sr_entry->e_attrs, j = 0; a != NULL; a = a->a_next, j++ ) {
934 AttributeDescription *desc = a->a_desc;
937 if ( rs->sr_attrs == NULL ) {
938 /* all user attrs request, skip operational attributes */
939 if( is_at_operational( desc->ad_type ) ) {
944 /* specific attrs requested */
945 if ( is_at_operational( desc->ad_type ) ) {
946 /* if not explicitly requested */
947 if ( !ad_inlist( desc, rs->sr_attrs )) {
948 /* if not all op attrs requested, skip */
949 if ( !SLAP_OPATTRS( rs->sr_attr_flags ))
951 /* if DSA-specific and replicating, skip */
952 if ( op->o_sync != SLAP_CONTROL_NONE &&
953 desc->ad_type->sat_usage == LDAP_SCHEMA_DSA_OPERATION )
957 if ( !userattrs && !ad_inlist( desc, rs->sr_attrs ) ) {
964 if ( ! access_allowed( op, rs->sr_entry, desc, NULL,
965 ACL_READ, &acl_state ) )
967 Debug( LDAP_DEBUG_ACL, "send_search_entry: "
968 "conn %lu access to attribute %s not allowed\n",
969 op->o_connid, desc->ad_cname.bv_val, 0 );
973 if (( rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname )) == -1 ) {
974 Debug( LDAP_DEBUG_ANY,
975 "send_search_entry: conn %lu ber_printf failed\n",
976 op->o_connid, 0, 0 );
978 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
979 send_ldap_error( op, rs, LDAP_OTHER,
980 "encoding description error");
988 for ( i = 0; a->a_nvals[i].bv_val != NULL; i++ ) {
989 if ( ! access_allowed( op, rs->sr_entry,
990 desc, &a->a_nvals[i], ACL_READ, &acl_state ) )
992 Debug( LDAP_DEBUG_ACL,
993 "send_search_entry: conn %lu "
994 "access to attribute %s, value #%d not allowed\n",
995 op->o_connid, desc->ad_cname.bv_val, i );
1000 if ( op->o_vrFilter && e_flags[j][i] == 0 ){
1007 if (( rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname )) == -1 ) {
1008 Debug( LDAP_DEBUG_ANY,
1009 "send_search_entry: conn %lu ber_printf failed\n",
1010 op->o_connid, 0, 0 );
1012 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1013 send_ldap_error( op, rs, LDAP_OTHER,
1014 "encoding description error");
1019 if (( rc = ber_printf( ber, "O", &a->a_vals[i] )) == -1 ) {
1020 Debug( LDAP_DEBUG_ANY,
1021 "send_search_entry: conn %lu "
1022 "ber_printf failed.\n", op->o_connid, 0, 0 );
1024 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1025 send_ldap_error( op, rs, LDAP_OTHER,
1026 "encoding values error" );
1033 if ( finish && ( rc = ber_printf( ber, /*{[*/ "]N}" )) == -1 ) {
1034 Debug( LDAP_DEBUG_ANY,
1035 "send_search_entry: conn %lu ber_printf failed\n",
1036 op->o_connid, 0, 0 );
1038 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1039 send_ldap_error( op, rs, LDAP_OTHER, "encode end error" );
1045 /* NOTE: moved before overlays callback circling because
1046 * they may modify entry and other stuff in rs */
1047 if ( rs->sr_operational_attrs != NULL && op->o_vrFilter != NULL ) {
1051 for ( a = rs->sr_operational_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
1052 for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) k++;
1055 size = i * sizeof(char *) + k;
1057 char *a_flags, **tmp;
1060 * Reuse previous memory - we likely need less space
1061 * for operational attributes
1063 tmp = slap_sl_realloc( e_flags, i * sizeof(char *) + k,
1065 if ( tmp == NULL ) {
1066 Debug( LDAP_DEBUG_ANY,
1067 "send_search_entry: conn %lu "
1068 "not enough memory "
1069 "for matched values filtering\n",
1070 op->o_connid, 0, 0 );
1071 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1072 send_ldap_error( op, rs, LDAP_OTHER,
1073 "not enough memory for matched values filtering" );
1077 a_flags = (char *)(e_flags + i);
1078 memset( a_flags, 0, k );
1079 for ( a = rs->sr_operational_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
1080 for ( j = 0; a->a_vals[j].bv_val != NULL; j++ );
1081 e_flags[i] = a_flags;
1084 rc = filter_matched_values(op, rs->sr_operational_attrs, &e_flags) ;
1087 Debug( LDAP_DEBUG_ANY,
1088 "send_search_entry: conn %lu "
1089 "matched values filtering failed\n",
1090 op->o_connid ? op->o_connid : 0, 0, 0);
1091 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1092 send_ldap_error( op, rs, LDAP_OTHER,
1093 "matched values filtering error" );
1100 for (a = rs->sr_operational_attrs, j=0; a != NULL; a = a->a_next, j++ ) {
1101 AttributeDescription *desc = a->a_desc;
1103 if ( rs->sr_attrs == NULL ) {
1104 /* all user attrs request, skip operational attributes */
1105 if( is_at_operational( desc->ad_type ) ) {
1110 /* specific attrs requested */
1111 if( is_at_operational( desc->ad_type ) ) {
1112 if ( !SLAP_OPATTRS( rs->sr_attr_flags ) &&
1113 !ad_inlist( desc, rs->sr_attrs ) )
1118 if ( !userattrs && !ad_inlist( desc, rs->sr_attrs ) ) {
1124 if ( ! access_allowed( op, rs->sr_entry, desc, NULL,
1125 ACL_READ, &acl_state ) )
1127 Debug( LDAP_DEBUG_ACL,
1128 "send_search_entry: conn %lu "
1129 "access to attribute %s not allowed\n",
1130 op->o_connid, desc->ad_cname.bv_val, 0 );
1135 rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname );
1137 Debug( LDAP_DEBUG_ANY,
1138 "send_search_entry: conn %lu "
1139 "ber_printf failed\n", op->o_connid, 0, 0 );
1141 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1142 send_ldap_error( op, rs, LDAP_OTHER,
1143 "encoding description error" );
1148 if ( ! attrsonly ) {
1149 for ( i = 0; a->a_vals[i].bv_val != NULL; i++ ) {
1150 if ( ! access_allowed( op, rs->sr_entry,
1151 desc, &a->a_vals[i], ACL_READ, &acl_state ) )
1153 Debug( LDAP_DEBUG_ACL,
1154 "send_search_entry: conn %lu "
1155 "access to %s, value %d not allowed\n",
1156 op->o_connid, desc->ad_cname.bv_val, i );
1161 if ( op->o_vrFilter && e_flags[j][i] == 0 ){
1165 if (( rc = ber_printf( ber, "O", &a->a_vals[i] )) == -1 ) {
1166 Debug( LDAP_DEBUG_ANY,
1167 "send_search_entry: conn %lu ber_printf failed\n",
1168 op->o_connid, 0, 0 );
1170 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1171 send_ldap_error( op, rs, LDAP_OTHER,
1172 "encoding values error" );
1179 if (( rc = ber_printf( ber, /*{[*/ "]N}" )) == -1 ) {
1180 Debug( LDAP_DEBUG_ANY,
1181 "send_search_entry: conn %lu ber_printf failed\n",
1182 op->o_connid, 0, 0 );
1184 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1185 send_ldap_error( op, rs, LDAP_OTHER, "encode end error" );
1193 slap_sl_free( e_flags, op->o_tmpmemctx );
1197 rc = ber_printf( ber, /*{{*/ "}N}" );
1200 rc = send_ldap_controls( op, ber, rs->sr_ctrls );
1204 #ifdef LDAP_CONNECTIONLESS
1205 if( op->o_conn && op->o_conn->c_is_udp ) {
1206 if ( op->o_protocol != LDAP_VERSION2 ) {
1207 rc = ber_printf( ber, /*{*/ "N}" );
1211 if ( op->o_res_ber == NULL ) {
1212 rc = ber_printf( ber, /*{*/ "N}" );
1217 Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
1219 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1220 send_ldap_error( op, rs, LDAP_OTHER, "encode entry end error" );
1225 Statslog( LDAP_DEBUG_STATS2, "%s ENTRY dn=\"%s\"\n",
1226 op->o_log_prefix, rs->sr_entry->e_nname.bv_val, 0, 0, 0 );
1228 if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
1229 be_entry_release_rw( op, rs->sr_entry, 0 );
1230 rs->sr_flags ^= REP_ENTRY_MUSTRELEASE;
1231 rs->sr_entry = NULL;
1234 if ( op->o_res_ber == NULL ) {
1235 bytes = send_ldap_ber( op->o_conn, ber );
1236 ber_free_buf( ber );
1239 Debug( LDAP_DEBUG_ANY,
1240 "send_search_entry: conn %lu ber write failed.\n",
1241 op->o_connid, 0, 0 );
1243 rc = LDAP_UNAVAILABLE;
1248 ldap_pvt_thread_mutex_lock( &op->o_counters->sc_mutex );
1249 ldap_pvt_mp_add_ulong( op->o_counters->sc_bytes, (unsigned long)bytes );
1250 ldap_pvt_mp_add_ulong( op->o_counters->sc_entries, 1 );
1251 ldap_pvt_mp_add_ulong( op->o_counters->sc_pdu, 1 );
1252 ldap_pvt_thread_mutex_unlock( &op->o_counters->sc_mutex );
1255 Debug( LDAP_DEBUG_TRACE,
1256 "<= send_search_entry: conn %lu exit.\n", op->o_connid, 0, 0 );
1261 if ( op->o_callback ) {
1262 (void)slap_cleanup_play( op, rs );
1266 slap_sl_free( e_flags, op->o_tmpmemctx );
1269 if ( rs->sr_operational_attrs ) {
1270 attrs_free( rs->sr_operational_attrs );
1271 rs->sr_operational_attrs = NULL;
1273 rs->sr_attr_flags = SLAP_ATTRS_UNDEFINED;
1275 /* FIXME: I think rs->sr_type should be explicitly set to
1276 * REP_SEARCH here. That's what it was when we entered this
1277 * function. send_ldap_error may have changed it, but we
1278 * should set it back so that the cleanup functions know
1279 * what they're doing.
1281 if ( op->o_tag == LDAP_REQ_SEARCH && rs->sr_type == REP_SEARCH
1283 && ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) )
1285 entry_free( rs->sr_entry );
1286 rs->sr_entry = NULL;
1287 rs->sr_flags &= ~REP_ENTRY_MUSTBEFREED;
1294 slap_send_search_reference( Operation *op, SlapReply *rs )
1296 BerElementBuffer berbuf;
1297 BerElement *ber = (BerElement *) &berbuf;
1300 char *edn = rs->sr_entry ? rs->sr_entry->e_name.bv_val : "(null)";
1302 AttributeDescription *ad_ref = slap_schema.si_ad_ref;
1303 AttributeDescription *ad_entry = slap_schema.si_ad_entry;
1305 rs->sr_type = REP_SEARCHREF;
1306 if ( op->o_callback ) {
1307 rc = slap_response_play( op, rs );
1308 if ( rc != SLAP_CB_CONTINUE ) {
1313 Debug( LDAP_DEBUG_TRACE,
1314 "=> send_search_reference: dn=\"%s\"\n",
1317 if ( rs->sr_entry && ! access_allowed( op, rs->sr_entry,
1318 ad_entry, NULL, ACL_READ, NULL ) )
1320 Debug( LDAP_DEBUG_ACL,
1321 "send_search_reference: access to entry not allowed\n",
1327 if ( rs->sr_entry && ! access_allowed( op, rs->sr_entry,
1328 ad_ref, NULL, ACL_READ, NULL ) )
1330 Debug( LDAP_DEBUG_ACL,
1331 "send_search_reference: access "
1332 "to reference not allowed\n",
1338 if( op->o_domain_scope ) {
1339 Debug( LDAP_DEBUG_ANY,
1340 "send_search_reference: domainScope control in (%s)\n",
1346 if( rs->sr_ref == NULL ) {
1347 Debug( LDAP_DEBUG_ANY,
1348 "send_search_reference: null ref in (%s)\n",
1354 if( op->o_protocol < LDAP_VERSION3 ) {
1356 /* save the references for the result */
1357 if( rs->sr_ref[0].bv_val != NULL ) {
1358 if( value_add( &rs->sr_v2ref, rs->sr_ref ) )
1364 #ifdef LDAP_CONNECTIONLESS
1365 if( op->o_conn && op->o_conn->c_is_udp ) {
1366 ber = op->o_res_ber;
1370 ber_init_w_nullc( ber, LBER_USE_DER );
1371 ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
1374 rc = ber_printf( ber, "{it{W}" /*"}"*/ , op->o_msgid,
1375 LDAP_RES_SEARCH_REFERENCE, rs->sr_ref );
1378 rc = send_ldap_controls( op, ber, rs->sr_ctrls );
1382 rc = ber_printf( ber, /*"{"*/ "N}" );
1386 Debug( LDAP_DEBUG_ANY,
1387 "send_search_reference: ber_printf failed\n", 0, 0, 0 );
1389 #ifdef LDAP_CONNECTIONLESS
1390 if (!op->o_conn || op->o_conn->c_is_udp == 0)
1392 ber_free_buf( ber );
1393 send_ldap_error( op, rs, LDAP_OTHER, "encode DN error" );
1398 if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
1399 assert( rs->sr_entry != NULL );
1400 be_entry_release_rw( op, rs->sr_entry, 0 );
1401 rs->sr_flags ^= REP_ENTRY_MUSTRELEASE;
1402 rs->sr_entry = NULL;
1405 #ifdef LDAP_CONNECTIONLESS
1406 if (!op->o_conn || op->o_conn->c_is_udp == 0) {
1408 bytes = send_ldap_ber( op->o_conn, ber );
1409 ber_free_buf( ber );
1412 rc = LDAP_UNAVAILABLE;
1414 ldap_pvt_thread_mutex_lock( &op->o_counters->sc_mutex );
1415 ldap_pvt_mp_add_ulong( op->o_counters->sc_bytes, (unsigned long)bytes );
1416 ldap_pvt_mp_add_ulong( op->o_counters->sc_refs, 1 );
1417 ldap_pvt_mp_add_ulong( op->o_counters->sc_pdu, 1 );
1418 ldap_pvt_thread_mutex_unlock( &op->o_counters->sc_mutex );
1420 #ifdef LDAP_CONNECTIONLESS
1423 if ( rs->sr_ref != NULL ) {
1426 for ( r = 0; !BER_BVISNULL( &rs->sr_ref[ r ] ); r++ ) {
1427 Statslog( LDAP_DEBUG_STATS2, "%s REF #%d \"%s\"\n",
1428 op->o_log_prefix, r, rs->sr_ref[0].bv_val,
1433 Statslog( LDAP_DEBUG_STATS2, "%s REF \"(null)\"\n",
1434 op->o_log_prefix, 0, 0, 0, 0 );
1437 Debug( LDAP_DEBUG_TRACE, "<= send_search_reference\n", 0, 0, 0 );
1440 if ( op->o_callback ) {
1441 (void)slap_cleanup_play( op, rs );
1457 *code = LDAP_SUCCESS;
1461 if ( strncasecmp( s, "RESULT", STRLENOF( "RESULT" ) ) != 0 ) {
1462 Debug( LDAP_DEBUG_ANY, "str2result (%s) expecting \"RESULT\"\n",
1469 while ( (s = strchr( s, '\n' )) != NULL ) {
1474 if ( (c = strchr( s, ':' )) != NULL ) {
1478 if ( strncasecmp( s, "code", STRLENOF( "code" ) ) == 0 ) {
1483 Debug( LDAP_DEBUG_ANY, "str2result (%s) missing value\n",
1489 while ( isspace( (unsigned char) c[ 0 ] ) ) c++;
1490 if ( c[ 0 ] == '\0' ) {
1491 Debug( LDAP_DEBUG_ANY, "str2result (%s) missing or empty value\n",
1497 retcode = strtol( c, &next, 10 );
1498 if ( next == NULL || next == c ) {
1499 Debug( LDAP_DEBUG_ANY, "str2result (%s) unable to parse value\n",
1505 while ( isspace( (unsigned char) next[ 0 ] ) ) next++;
1506 if ( next[ 0 ] != '\0' ) {
1507 Debug( LDAP_DEBUG_ANY, "str2result (%s) extra cruft after value\n",
1513 /* FIXME: what if it's larger that max int? */
1514 *code = (int)retcode;
1516 } else if ( strncasecmp( s, "matched", STRLENOF( "matched" ) ) == 0 ) {
1520 } else if ( strncasecmp( s, "info", STRLENOF( "info" ) ) == 0 ) {
1525 Debug( LDAP_DEBUG_ANY, "str2result (%s) unknown\n",
1535 int slap_read_controls(
1539 const struct berval *oid,
1540 LDAPControl **ctrl )
1544 BerElementBuffer berbuf;
1545 BerElement *ber = (BerElement *) &berbuf;
1549 Debug( LDAP_DEBUG_ANY, "%s slap_read_controls: (%s) %s\n",
1550 op->o_log_prefix, oid->bv_val, e->e_dn );
1553 rs->sr_attrs = ( oid == &slap_pre_read_bv ) ?
1554 op->o_preread_attrs : op->o_postread_attrs;
1556 bv.bv_len = entry_flatsize( rs->sr_entry, 0 );
1557 bv.bv_val = op->o_tmpalloc( bv.bv_len, op->o_tmpmemctx );
1559 ber_init2( ber, &bv, LBER_USE_DER );
1560 ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
1562 /* create new operation */
1564 /* FIXME: o_bd needed for ACL */
1565 myop.o_bd = op->o_bd;
1566 myop.o_res_ber = ber;
1567 myop.o_callback = NULL;
1568 myop.ors_slimit = 1;
1570 rc = slap_send_search_entry( &myop, rs );
1573 rc = ber_flatten2( ber, &c.ldctl_value, 0 );
1575 if( rc == -1 ) return LDAP_OTHER;
1577 c.ldctl_oid = oid->bv_val;
1578 c.ldctl_iscritical = 0;
1580 if ( *ctrl == NULL ) {
1582 *ctrl = (LDAPControl *) slap_sl_calloc( 1, sizeof(LDAPControl), NULL );
1584 /* retry: free previous try */
1585 slap_sl_free( (*ctrl)->ldctl_value.bv_val, op->o_tmpmemctx );
1589 return LDAP_SUCCESS;
1592 /* Map API errors to protocol errors... */
1594 slap_map_api2result( SlapReply *rs )
1596 switch(rs->sr_err) {
1597 case LDAP_SERVER_DOWN:
1598 return LDAP_UNAVAILABLE;
1599 case LDAP_LOCAL_ERROR:
1601 case LDAP_ENCODING_ERROR:
1602 case LDAP_DECODING_ERROR:
1603 return LDAP_PROTOCOL_ERROR;
1605 return LDAP_UNAVAILABLE;
1606 case LDAP_AUTH_UNKNOWN:
1607 return LDAP_AUTH_METHOD_NOT_SUPPORTED;
1608 case LDAP_FILTER_ERROR:
1609 rs->sr_text = "Filter error";
1611 case LDAP_USER_CANCELLED:
1612 rs->sr_text = "User cancelled";
1614 case LDAP_PARAM_ERROR:
1615 return LDAP_PROTOCOL_ERROR;
1616 case LDAP_NO_MEMORY:
1618 case LDAP_CONNECT_ERROR:
1619 return LDAP_UNAVAILABLE;
1620 case LDAP_NOT_SUPPORTED:
1621 return LDAP_UNWILLING_TO_PERFORM;
1622 case LDAP_CONTROL_NOT_FOUND:
1623 return LDAP_PROTOCOL_ERROR;
1624 case LDAP_NO_RESULTS_RETURNED:
1625 return LDAP_NO_SUCH_OBJECT;
1626 case LDAP_MORE_RESULTS_TO_RETURN:
1627 rs->sr_text = "More results to return";
1629 case LDAP_CLIENT_LOOP:
1630 case LDAP_REFERRAL_LIMIT_EXCEEDED:
1631 return LDAP_LOOP_DETECT;
1633 if ( LDAP_API_ERROR(rs->sr_err) ) return LDAP_OTHER;
1640 slap_attr_flags( AttributeName *an )
1642 slap_mask_t flags = SLAP_ATTRS_UNDEFINED;
1645 flags |= ( SLAP_OPATTRS_NO | SLAP_USERATTRS_YES );
1648 flags |= an_find( an, &AllOper )
1649 ? SLAP_OPATTRS_YES : SLAP_OPATTRS_NO;
1650 flags |= an_find( an, &AllUser )
1651 ? SLAP_USERATTRS_YES : SLAP_USERATTRS_NO;