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-2006 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 int slap_replog_cb( Operation *op, SlapReply *rs )
59 if ( rs->sr_err == LDAP_SUCCESS ) {
62 return SLAP_CB_CONTINUE;
65 static char *v2ref( BerVarray ref, const char *text )
67 size_t len = 0, i = 0;
72 return ch_strdup(text);
80 if (text[len-1] != '\n') {
85 v2 = ch_malloc( len+i+sizeof("Referral:") );
93 strcpy( v2+len, "Referral:" );
94 len += sizeof("Referral:");
96 for( i=0; ref[i].bv_val != NULL; i++ ) {
97 v2 = ch_realloc( v2, len + ref[i].bv_len + 1 );
99 AC_MEMCPY(&v2[len], ref[i].bv_val, ref[i].bv_len );
100 len += ref[i].bv_len;
101 if (ref[i].bv_val[ref[i].bv_len-1] != '/') {
111 slap_req2res( ber_tag_t tag )
116 case LDAP_REQ_COMPARE:
117 case LDAP_REQ_EXTENDED:
118 case LDAP_REQ_MODIFY:
119 case LDAP_REQ_MODRDN:
123 case LDAP_REQ_DELETE:
124 tag = LDAP_RES_DELETE;
127 case LDAP_REQ_ABANDON:
128 case LDAP_REQ_UNBIND:
132 case LDAP_REQ_SEARCH:
133 tag = LDAP_RES_SEARCH_RESULT;
143 static long send_ldap_ber(
149 ber_get_option( ber, LBER_OPT_BER_BYTES_TO_WRITE, &bytes );
151 /* write only one pdu at a time - wait til it's our turn */
152 ldap_pvt_thread_mutex_lock( &conn->c_write_mutex );
154 /* lock the connection */
155 ldap_pvt_thread_mutex_lock( &conn->c_mutex );
162 if ( connection_state_closing( conn ) ) {
163 ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
164 ldap_pvt_thread_mutex_unlock( &conn->c_write_mutex );
169 if ( ber_flush2( conn->c_sb, ber, LBER_FLUSH_FREE_NEVER ) == 0 ) {
176 * we got an error. if it's ewouldblock, we need to
177 * wait on the socket being writable. otherwise, figure
178 * it's a hard error and return.
181 Debug( LDAP_DEBUG_CONNS, "ber_flush2 failed errno=%d reason=\"%s\"\n",
182 err, sock_errstr(err), 0 );
184 if ( err != EWOULDBLOCK && err != EAGAIN ) {
185 connection_closing( conn, "connection lost on write" );
187 ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
188 ldap_pvt_thread_mutex_unlock( &conn->c_write_mutex );
193 /* wait for socket to be write-ready */
194 conn->c_writewaiter = 1;
195 ber_sockbuf_ctrl( conn->c_sb, LBER_SB_OPT_GET_FD, &sd );
196 slapd_set_write( sd, 1 );
198 ldap_pvt_thread_cond_wait( &conn->c_write_cv, &conn->c_mutex );
199 conn->c_writewaiter = 0;
202 ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
203 ldap_pvt_thread_mutex_unlock( &conn->c_write_mutex );
209 send_ldap_control( BerElement *ber, LDAPControl *c )
215 rc = ber_printf( ber, "{s" /*}*/, c->ldctl_oid );
217 if( c->ldctl_iscritical ) {
218 rc = ber_printf( ber, "b",
219 (ber_int_t) c->ldctl_iscritical ) ;
220 if( rc == -1 ) return rc;
223 if( c->ldctl_value.bv_val != NULL ) {
224 rc = ber_printf( ber, "O", &c->ldctl_value );
225 if( rc == -1 ) return rc;
228 rc = ber_printf( ber, /*{*/"N}" );
229 if( rc == -1 ) return rc;
235 send_ldap_controls( Operation *o, BerElement *ber, LDAPControl **c )
242 rc = ber_printf( ber, "t{"/*}*/, LDAP_TAG_CONTROLS );
243 if( rc == -1 ) return rc;
245 for( ; *c != NULL; c++) {
246 rc = send_ldap_control( ber, *c );
247 if( rc == -1 ) return rc;
251 /* this is a hack to avoid having to modify op->s_ctrls */
252 if( o->o_sortedresults ) {
253 BerElementBuffer berbuf;
254 BerElement *sber = (BerElement *) &berbuf;
256 BER_BVZERO( &sorted.ldctl_value );
257 sorted.ldctl_oid = LDAP_CONTROL_SORTRESPONSE;
258 sorted.ldctl_iscritical = 0;
260 ber_init2( sber, NULL, LBER_USE_DER );
262 ber_printf( sber, "{e}", LDAP_UNWILLING_TO_PERFORM );
264 if( ber_flatten2( ber, &sorted.ldctl_value, 0 ) == -1 ) {
268 (void) ber_free_buf( ber );
270 rc = send_ldap_control( ber, &sorted );
271 if( rc == -1 ) return rc;
275 rc = ber_printf( ber, /*{*/"N}" );
281 * slap_response_play()
283 * plays the callback list; rationale: a callback can
284 * - remove itself from the list, by setting op->o_callback = NULL;
285 * malloc()'ed callbacks should free themselves from inside the
286 * sc_response() function.
287 * - replace itself with another (list of) callback(s), by setting
288 * op->o_callback = a new (list of) callback(s); in this case, it
289 * is the callback's responsibility to to append existing subsequent
290 * callbacks to the end of the list that is passed to the sc_response()
292 * - modify the list of subsequent callbacks by modifying the value
293 * of the sc_next field from inside the sc_response() function; this
294 * case does not require any handling from inside slap_response_play()
296 * To stop execution of the playlist, the sc_response() function must return
297 * a value different from SLAP_SC_CONTINUE.
299 * The same applies to slap_cleanup_play(); only, there is no means to stop
300 * execution of the playlist, since all cleanup functions must be called.
310 slap_callback *sc = op->o_callback, **scp;
312 rc = SLAP_CB_CONTINUE;
313 for ( scp = ≻ *scp; ) {
314 slap_callback *sc_next = (*scp)->sc_next, **sc_nextp = &(*scp)->sc_next;
316 op->o_callback = *scp;
317 if ( op->o_callback->sc_response ) {
318 rc = op->o_callback->sc_response( op, rs );
319 if ( op->o_callback == NULL ) {
320 /* the callback has been removed;
325 } else if ( op->o_callback != *scp ) {
326 /* a new callback has been inserted
327 * in place of the existing one; repair the list */
328 *scp = op->o_callback;
331 if ( rc != SLAP_CB_CONTINUE ) break;
337 #else /* ! LDAP_DEVEL */
338 slap_callback *sc = op->o_callback, **sc_prev = &sc, *sc_next;
340 rc = SLAP_CB_CONTINUE;
341 for ( sc_next = op->o_callback; sc_next; op->o_callback = sc_next) {
342 sc_next = op->o_callback->sc_next;
343 if ( op->o_callback->sc_response ) {
344 slap_callback *sc2 = op->o_callback;
345 rc = op->o_callback->sc_response( op, rs );
346 if ( op->o_callback != sc2 ) {
347 *sc_prev = op->o_callback;
349 if ( rc != SLAP_CB_CONTINUE || !op->o_callback ) break;
350 if ( op->o_callback != sc2 ) continue;
352 sc_prev = &op->o_callback->sc_next;
356 #endif /* ! LDAP_DEVEL */
367 slap_callback *sc = op->o_callback, **scp;
369 for ( scp = ≻ *scp; ) {
370 slap_callback *sc_next = (*scp)->sc_next, **sc_nextp = &(*scp)->sc_next;
372 op->o_callback = *scp;
373 if ( op->o_callback->sc_cleanup ) {
374 (void)op->o_callback->sc_cleanup( op, rs );
375 if ( op->o_callback == NULL ) {
376 /* the callback has been removed;
381 } else if ( op->o_callback != *scp ) {
382 /* a new callback has been inserted
383 * after the existing one; repair the list */
384 /* a new callback has been inserted
385 * in place of the existing one; repair the list */
386 *scp = op->o_callback;
389 /* don't care about the result; do all cleanup */
395 #else /* ! LDAP_DEVEL */
396 slap_callback *sc = op->o_callback, **sc_prev = &sc, *sc_next;
398 for ( sc_next = op->o_callback; sc_next; op->o_callback = sc_next) {
399 sc_next = op->o_callback->sc_next;
400 if ( op->o_callback->sc_cleanup ) {
401 slap_callback *sc2 = op->o_callback;
402 (void)op->o_callback->sc_cleanup( op, rs );
403 if ( op->o_callback != sc2 ) {
404 *sc_prev = op->o_callback;
406 if ( !op->o_callback ) break;
407 if ( op->o_callback != sc2 ) continue;
409 sc_prev = &op->o_callback->sc_next;
413 #endif /* ! LDAP_DEVEL */
423 BerElementBuffer berbuf;
424 BerElement *ber = (BerElement *) &berbuf;
425 int rc = LDAP_SUCCESS;
428 if ( rs->sr_err == SLAPD_ABANDON || op->o_abandon ) {
433 if ( op->o_callback ) {
434 rc = slap_response_play( op, rs );
435 if ( rc != SLAP_CB_CONTINUE ) {
440 #ifdef LDAP_CONNECTIONLESS
441 if (op->o_conn && op->o_conn->c_is_udp)
446 ber_init_w_nullc( ber, LBER_USE_DER );
447 ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
450 Debug( LDAP_DEBUG_TRACE,
451 "send_ldap_response: msgid=%d tag=%lu err=%d\n",
452 rs->sr_msgid, rs->sr_tag, rs->sr_err );
455 Debug( LDAP_DEBUG_ARGS, "send_ldap_response: ref=\"%s\"\n",
456 rs->sr_ref[0].bv_val ? rs->sr_ref[0].bv_val : "NULL",
460 #ifdef LDAP_CONNECTIONLESS
461 if (op->o_conn && op->o_conn->c_is_udp &&
462 op->o_protocol == LDAP_VERSION2 )
464 rc = ber_printf( ber, "t{ess" /*"}"*/,
465 rs->sr_tag, rs->sr_err,
466 rs->sr_matched == NULL ? "" : rs->sr_matched,
467 rs->sr_text == NULL ? "" : rs->sr_text );
470 if ( rs->sr_type == REP_INTERMEDIATE ) {
471 rc = ber_printf( ber, "{it{" /*"}}"*/,
472 rs->sr_msgid, rs->sr_tag );
475 rc = ber_printf( ber, "{it{ess" /*"}}"*/,
476 rs->sr_msgid, rs->sr_tag, rs->sr_err,
477 rs->sr_matched == NULL ? "" : rs->sr_matched,
478 rs->sr_text == NULL ? "" : rs->sr_text );
482 if ( rs->sr_ref != NULL ) {
483 assert( rs->sr_err == LDAP_REFERRAL );
484 rc = ber_printf( ber, "t{W}",
485 LDAP_TAG_REFERRAL, rs->sr_ref );
487 assert( rs->sr_err != LDAP_REFERRAL );
491 if( rc != -1 && rs->sr_type == REP_SASL && rs->sr_sasldata != NULL ) {
492 rc = ber_printf( ber, "tO",
493 LDAP_TAG_SASL_RES_CREDS, rs->sr_sasldata );
497 ( rs->sr_type == REP_EXTENDED || rs->sr_type == REP_INTERMEDIATE ))
499 if ( rs->sr_rspoid != NULL ) {
500 rc = ber_printf( ber, "ts",
501 rs->sr_type == REP_EXTENDED
502 ? LDAP_TAG_EXOP_RES_OID : LDAP_TAG_IM_RES_OID,
505 if( rc != -1 && rs->sr_rspdata != NULL ) {
506 rc = ber_printf( ber, "tO",
507 rs->sr_type == REP_EXTENDED
508 ? LDAP_TAG_EXOP_RES_VALUE : LDAP_TAG_IM_RES_VALUE,
514 rc = ber_printf( ber, /*"{"*/ "N}" );
518 rc = send_ldap_controls( op, ber, rs->sr_ctrls );
522 rc = ber_printf( ber, /*"{"*/ "N}" );
525 #ifdef LDAP_CONNECTIONLESS
526 if( op->o_conn && op->o_conn->c_is_udp && op->o_protocol == LDAP_VERSION2
529 rc = ber_printf( ber, /*"{"*/ "N}" );
534 Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
536 #ifdef LDAP_CONNECTIONLESS
537 if (!op->o_conn || op->o_conn->c_is_udp == 0)
546 bytes = send_ldap_ber( op->o_conn, ber );
547 #ifdef LDAP_CONNECTIONLESS
548 if (!op->o_conn || op->o_conn->c_is_udp == 0)
555 Debug( LDAP_DEBUG_ANY,
556 "send_ldap_response: ber write failed\n",
562 ldap_pvt_thread_mutex_lock( &slap_counters.sc_sent_mutex );
563 ldap_pvt_mp_add_ulong( slap_counters.sc_pdu, 1 );
564 ldap_pvt_mp_add_ulong( slap_counters.sc_bytes, (unsigned long)bytes );
565 ldap_pvt_thread_mutex_unlock( &slap_counters.sc_sent_mutex );
568 /* Tell caller that we did this for real, as opposed to being
569 * overridden by a callback
571 rc = SLAP_CB_CONTINUE;
574 if ( op->o_callback ) {
575 (void)slap_cleanup_play( op, rs );
578 if ( rs->sr_matched && rs->sr_flags & REP_MATCHED_MUSTBEFREED ) {
579 free( (char *)rs->sr_matched );
580 rs->sr_matched = NULL;
583 if ( rs->sr_ref && rs->sr_flags & REP_REF_MUSTBEFREED ) {
584 ber_bvarray_free( rs->sr_ref );
593 send_ldap_disconnect( Operation *op, SlapReply *rs )
595 #define LDAP_UNSOLICITED_ERROR(e) \
596 ( (e) == LDAP_PROTOCOL_ERROR \
597 || (e) == LDAP_STRONG_AUTH_REQUIRED \
598 || (e) == LDAP_UNAVAILABLE )
600 assert( LDAP_UNSOLICITED_ERROR( rs->sr_err ) );
602 rs->sr_type = REP_EXTENDED;
604 Debug( LDAP_DEBUG_TRACE,
605 "send_ldap_disconnect %d:%s\n",
606 rs->sr_err, rs->sr_text ? rs->sr_text : "", NULL );
608 if ( op->o_protocol < LDAP_VERSION3 ) {
609 rs->sr_rspoid = NULL;
610 rs->sr_tag = slap_req2res( op->o_tag );
611 rs->sr_msgid = (rs->sr_tag != LBER_SEQUENCE) ? op->o_msgid : 0;
614 rs->sr_rspoid = LDAP_NOTICE_DISCONNECT;
615 rs->sr_tag = LDAP_RES_EXTENDED;
619 if ( send_ldap_response( op, rs ) == SLAP_CB_CONTINUE ) {
620 Statslog( LDAP_DEBUG_STATS,
621 "%s DISCONNECT tag=%lu err=%d text=%s\n",
622 op->o_log_prefix, rs->sr_tag, rs->sr_err,
623 rs->sr_text ? rs->sr_text : "", 0 );
628 slap_send_ldap_result( Operation *op, SlapReply *rs )
631 const char *otext = rs->sr_text;
632 BerVarray oref = rs->sr_ref;
634 rs->sr_type = REP_RESULT;
636 /* Propagate Abandons so that cleanup callbacks can be processed */
637 if ( rs->sr_err == SLAPD_ABANDON || op->o_abandon )
640 assert( !LDAP_API_ERROR( rs->sr_err ) );
642 Debug( LDAP_DEBUG_TRACE,
643 "send_ldap_result: %s p=%d\n",
644 op->o_log_prefix, op->o_protocol, 0 );
646 Debug( LDAP_DEBUG_ARGS,
647 "send_ldap_result: err=%d matched=\"%s\" text=\"%s\"\n",
648 rs->sr_err, rs->sr_matched ? rs->sr_matched : "",
649 rs->sr_text ? rs->sr_text : "" );
653 Debug( LDAP_DEBUG_ARGS,
654 "send_ldap_result: referral=\"%s\"\n",
655 rs->sr_ref[0].bv_val ? rs->sr_ref[0].bv_val : "NULL",
659 assert( rs->sr_err != LDAP_PARTIAL_RESULTS );
661 if ( rs->sr_err == LDAP_REFERRAL ) {
662 if( op->o_domain_scope ) rs->sr_ref = NULL;
664 if( rs->sr_ref == NULL ) {
665 rs->sr_err = LDAP_NO_SUCH_OBJECT;
666 } else if ( op->o_protocol < LDAP_VERSION3 ) {
667 rs->sr_err = LDAP_PARTIAL_RESULTS;
671 if ( op->o_protocol < LDAP_VERSION3 ) {
672 tmp = v2ref( rs->sr_ref, rs->sr_text );
677 rs->sr_tag = slap_req2res( op->o_tag );
678 rs->sr_msgid = (rs->sr_tag != LBER_SEQUENCE) ? op->o_msgid : 0;
681 if ( send_ldap_response( op, rs ) == SLAP_CB_CONTINUE ) {
682 if ( op->o_tag == LDAP_REQ_SEARCH ) {
684 snprintf( nbuf, sizeof nbuf, "%d nentries=%d",
685 rs->sr_err, rs->sr_nentries );
687 Statslog( LDAP_DEBUG_STATS,
688 "%s SEARCH RESULT tag=%lu err=%s text=%s\n",
689 op->o_log_prefix, rs->sr_tag, nbuf,
690 rs->sr_text ? rs->sr_text : "", 0 );
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;
783 AccessControlState acl_state = ACL_STATE_INIT;
785 AttributeDescription *ad_entry = slap_schema.si_ad_entry;
787 /* a_flags: array of flags telling if the i-th element will be
788 * returned or filtered out
789 * e_flags: array of a_flags
791 char **e_flags = NULL;
793 if ( op->ors_slimit >= 0 && rs->sr_nentries >= op->ors_slimit ) {
794 return LDAP_SIZELIMIT_EXCEEDED;
797 rs->sr_type = REP_SEARCH;
799 /* eventually will loop through generated operational attribute types
800 * currently implemented types include:
801 * entryDN, subschemaSubentry, and hasSubordinates */
802 /* NOTE: moved before overlays callback circling because
803 * they may modify entry and other stuff in rs */
804 /* check for special all operational attributes ("+") type */
805 /* FIXME: maybe we could set this flag at the operation level;
806 * however, in principle the caller of send_search_entry() may
807 * change the attribute list at each call */
808 rs->sr_attr_flags = slap_attr_flags( rs->sr_attrs );
810 rc = backend_operational( op, rs );
815 if ( op->o_callback ) {
816 rc = slap_response_play( op, rs );
817 if ( rc != SLAP_CB_CONTINUE ) {
822 Debug( LDAP_DEBUG_TRACE, "=> send_search_entry: conn %lu dn=\"%s\"%s\n",
823 op->o_connid, rs->sr_entry->e_name.bv_val,
824 op->ors_attrsonly ? " (attrsOnly)" : "" );
826 attrsonly = op->ors_attrsonly;
828 if ( !access_allowed( op, rs->sr_entry, ad_entry, NULL, ACL_READ, NULL )) {
829 Debug( LDAP_DEBUG_ACL,
830 "send_search_entry: conn %lu access to entry (%s) not allowed\n",
831 op->o_connid, rs->sr_entry->e_name.bv_val, 0 );
833 rc = LDAP_INSUFFICIENT_ACCESS;
837 edn = rs->sr_entry->e_nname.bv_val;
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 ( !SLAP_OPATTRS( rs->sr_attr_flags ) &&
947 !ad_inlist( desc, rs->sr_attrs ) )
953 if ( !userattrs && !ad_inlist( desc, rs->sr_attrs ) ) {
960 if ( ! access_allowed( op, rs->sr_entry, desc, NULL,
961 ACL_READ, &acl_state ) )
963 Debug( LDAP_DEBUG_ACL, "send_search_entry: "
964 "conn %lu access to attribute %s not allowed\n",
965 op->o_connid, desc->ad_cname.bv_val, 0 );
969 if (( rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname )) == -1 ) {
970 Debug( LDAP_DEBUG_ANY,
971 "send_search_entry: conn %lu ber_printf failed\n",
972 op->o_connid, 0, 0 );
974 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
975 send_ldap_error( op, rs, LDAP_OTHER,
976 "encoding description error");
984 for ( i = 0; a->a_nvals[i].bv_val != NULL; i++ ) {
985 if ( ! access_allowed( op, rs->sr_entry,
986 desc, &a->a_nvals[i], ACL_READ, &acl_state ) )
988 Debug( LDAP_DEBUG_ACL,
989 "send_search_entry: conn %lu "
990 "access to attribute %s, value #%d not allowed\n",
991 op->o_connid, desc->ad_cname.bv_val, i );
996 if ( op->o_vrFilter && e_flags[j][i] == 0 ){
1003 if (( rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname )) == -1 ) {
1004 Debug( LDAP_DEBUG_ANY,
1005 "send_search_entry: conn %lu ber_printf failed\n",
1006 op->o_connid, 0, 0 );
1008 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1009 send_ldap_error( op, rs, LDAP_OTHER,
1010 "encoding description error");
1015 if (( rc = ber_printf( ber, "O", &a->a_vals[i] )) == -1 ) {
1016 Debug( LDAP_DEBUG_ANY,
1017 "send_search_entry: conn %lu "
1018 "ber_printf failed.\n", op->o_connid, 0, 0 );
1020 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1021 send_ldap_error( op, rs, LDAP_OTHER,
1022 "encoding values error" );
1029 if ( finish && ( rc = ber_printf( ber, /*{[*/ "]N}" )) == -1 ) {
1030 Debug( LDAP_DEBUG_ANY,
1031 "send_search_entry: conn %lu ber_printf failed\n",
1032 op->o_connid, 0, 0 );
1034 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1035 send_ldap_error( op, rs, LDAP_OTHER, "encode end error" );
1041 /* NOTE: moved before overlays callback circling because
1042 * they may modify entry and other stuff in rs */
1043 if ( rs->sr_operational_attrs != NULL && op->o_vrFilter != NULL ) {
1047 for ( a = rs->sr_operational_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
1048 for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) k++;
1051 size = i * sizeof(char *) + k;
1053 char *a_flags, **tmp;
1056 * Reuse previous memory - we likely need less space
1057 * for operational attributes
1059 tmp = slap_sl_realloc( e_flags, i * sizeof(char *) + k,
1061 if ( tmp == NULL ) {
1062 Debug( LDAP_DEBUG_ANY,
1063 "send_search_entry: conn %lu "
1064 "not enough memory "
1065 "for matched values filtering\n",
1066 op->o_connid, 0, 0 );
1067 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1068 send_ldap_error( op, rs, LDAP_OTHER,
1069 "not enough memory for matched values filtering" );
1073 a_flags = (char *)(e_flags + i);
1074 memset( a_flags, 0, k );
1075 for ( a = rs->sr_operational_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
1076 for ( j = 0; a->a_vals[j].bv_val != NULL; j++ );
1077 e_flags[i] = a_flags;
1080 rc = filter_matched_values(op, rs->sr_operational_attrs, &e_flags) ;
1083 Debug( LDAP_DEBUG_ANY,
1084 "send_search_entry: conn %lu "
1085 "matched values filtering failed\n",
1086 op->o_connid ? op->o_connid : 0, 0, 0);
1087 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1088 send_ldap_error( op, rs, LDAP_OTHER,
1089 "matched values filtering error" );
1096 for (a = rs->sr_operational_attrs, j=0; a != NULL; a = a->a_next, j++ ) {
1097 AttributeDescription *desc = a->a_desc;
1099 if ( rs->sr_attrs == NULL ) {
1100 /* all user attrs request, skip operational attributes */
1101 if( is_at_operational( desc->ad_type ) ) {
1106 /* specific attrs requested */
1107 if( is_at_operational( desc->ad_type ) ) {
1108 if ( !SLAP_OPATTRS( rs->sr_attr_flags ) &&
1109 !ad_inlist( desc, rs->sr_attrs ) )
1114 if ( !userattrs && !ad_inlist( desc, rs->sr_attrs ) ) {
1120 if ( ! access_allowed( op, rs->sr_entry, desc, NULL,
1121 ACL_READ, &acl_state ) )
1123 Debug( LDAP_DEBUG_ACL,
1124 "send_search_entry: conn %lu "
1125 "access to attribute %s not allowed\n",
1126 op->o_connid, desc->ad_cname.bv_val, 0 );
1131 rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname );
1133 Debug( LDAP_DEBUG_ANY,
1134 "send_search_entry: conn %lu "
1135 "ber_printf failed\n", op->o_connid, 0, 0 );
1137 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1138 send_ldap_error( op, rs, LDAP_OTHER,
1139 "encoding description error" );
1144 if ( ! attrsonly ) {
1145 for ( i = 0; a->a_vals[i].bv_val != NULL; i++ ) {
1146 if ( ! access_allowed( op, rs->sr_entry,
1147 desc, &a->a_vals[i], ACL_READ, &acl_state ) )
1149 Debug( LDAP_DEBUG_ACL,
1150 "send_search_entry: conn %lu "
1151 "access to %s, value %d not allowed\n",
1152 op->o_connid, desc->ad_cname.bv_val, i );
1157 if ( op->o_vrFilter && e_flags[j][i] == 0 ){
1161 if (( rc = ber_printf( ber, "O", &a->a_vals[i] )) == -1 ) {
1162 Debug( LDAP_DEBUG_ANY,
1163 "send_search_entry: conn %lu ber_printf failed\n",
1164 op->o_connid, 0, 0 );
1166 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1167 send_ldap_error( op, rs, LDAP_OTHER,
1168 "encoding values error" );
1175 if (( rc = ber_printf( ber, /*{[*/ "]N}" )) == -1 ) {
1176 Debug( LDAP_DEBUG_ANY,
1177 "send_search_entry: conn %lu ber_printf failed\n",
1178 op->o_connid, 0, 0 );
1180 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1181 send_ldap_error( op, rs, LDAP_OTHER, "encode end error" );
1189 slap_sl_free( e_flags, op->o_tmpmemctx );
1193 rc = ber_printf( ber, /*{{*/ "}N}" );
1196 rc = send_ldap_controls( op, ber, rs->sr_ctrls );
1200 #ifdef LDAP_CONNECTIONLESS
1201 if( op->o_conn && op->o_conn->c_is_udp ) {
1202 if ( op->o_protocol != LDAP_VERSION2 ) {
1203 rc = ber_printf( ber, /*{*/ "N}" );
1207 if ( op->o_res_ber == NULL ) {
1208 rc = ber_printf( ber, /*{*/ "N}" );
1213 Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
1215 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1216 send_ldap_error( op, rs, LDAP_OTHER, "encode entry end error" );
1221 if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
1222 be_entry_release_rw( op, rs->sr_entry, 0 );
1223 rs->sr_flags ^= REP_ENTRY_MUSTRELEASE;
1224 rs->sr_entry = NULL;
1227 if ( op->o_res_ber == NULL ) {
1228 bytes = send_ldap_ber( op->o_conn, ber );
1229 ber_free_buf( ber );
1232 Debug( LDAP_DEBUG_ANY,
1233 "send_search_entry: conn %lu ber write failed.\n",
1234 op->o_connid, 0, 0 );
1236 rc = LDAP_UNAVAILABLE;
1241 ldap_pvt_thread_mutex_lock( &slap_counters.sc_sent_mutex );
1242 ldap_pvt_mp_add_ulong( slap_counters.sc_bytes, (unsigned long)bytes );
1243 ldap_pvt_mp_add_ulong( slap_counters.sc_entries, 1 );
1244 ldap_pvt_mp_add_ulong( slap_counters.sc_pdu, 1 );
1245 ldap_pvt_thread_mutex_unlock( &slap_counters.sc_sent_mutex );
1248 Statslog( LDAP_DEBUG_STATS2, "%s ENTRY dn=\"%s\"\n",
1249 op->o_log_prefix, edn, 0, 0, 0 );
1251 Debug( LDAP_DEBUG_TRACE,
1252 "<= send_search_entry: conn %lu exit.\n", op->o_connid, 0, 0 );
1257 if ( op->o_callback ) {
1258 (void)slap_cleanup_play( op, rs );
1262 slap_sl_free( e_flags, op->o_tmpmemctx );
1265 if ( rs->sr_operational_attrs ) {
1266 attrs_free( rs->sr_operational_attrs );
1267 rs->sr_operational_attrs = NULL;
1269 rs->sr_attr_flags = SLAP_ATTRS_UNDEFINED;
1271 /* FIXME: I think rs->sr_type should be explicitly set to
1272 * REP_SEARCH here. That's what it was when we entered this
1273 * function. send_ldap_error may have changed it, but we
1274 * should set it back so that the cleanup functions know
1275 * what they're doing.
1277 if ( op->o_tag == LDAP_REQ_SEARCH && rs->sr_type == REP_SEARCH
1279 && ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) )
1281 entry_free( rs->sr_entry );
1282 rs->sr_entry = NULL;
1283 rs->sr_flags &= ~REP_ENTRY_MUSTBEFREED;
1290 slap_send_search_reference( Operation *op, SlapReply *rs )
1292 BerElementBuffer berbuf;
1293 BerElement *ber = (BerElement *) &berbuf;
1297 AttributeDescription *ad_ref = slap_schema.si_ad_ref;
1298 AttributeDescription *ad_entry = slap_schema.si_ad_entry;
1300 rs->sr_type = REP_SEARCHREF;
1301 if ( op->o_callback ) {
1302 rc = slap_response_play( op, rs );
1303 if ( rc != SLAP_CB_CONTINUE ) {
1308 Debug( LDAP_DEBUG_TRACE,
1309 "=> send_search_reference: dn=\"%s\"\n",
1310 rs->sr_entry ? rs->sr_entry->e_name.bv_val : "(null)", 0, 0 );
1312 if ( rs->sr_entry && ! access_allowed( op, rs->sr_entry,
1313 ad_entry, NULL, ACL_READ, NULL ) )
1315 Debug( LDAP_DEBUG_ACL,
1316 "send_search_reference: access to entry not allowed\n",
1322 if ( rs->sr_entry && ! access_allowed( op, rs->sr_entry,
1323 ad_ref, NULL, ACL_READ, NULL ) )
1325 Debug( LDAP_DEBUG_ACL,
1326 "send_search_reference: access "
1327 "to reference not allowed\n",
1333 if( op->o_domain_scope ) {
1334 Debug( LDAP_DEBUG_ANY,
1335 "send_search_reference: domainScope control in (%s)\n",
1336 rs->sr_entry->e_dn, 0, 0 );
1341 if( rs->sr_ref == NULL ) {
1342 Debug( LDAP_DEBUG_ANY,
1343 "send_search_reference: null ref in (%s)\n",
1344 rs->sr_entry ? rs->sr_entry->e_dn : "(null)", 0, 0 );
1349 if( op->o_protocol < LDAP_VERSION3 ) {
1351 /* save the references for the result */
1352 if( rs->sr_ref[0].bv_val != NULL ) {
1353 if( value_add( &rs->sr_v2ref, rs->sr_ref ) )
1359 #ifdef LDAP_CONNECTIONLESS
1360 if( op->o_conn && op->o_conn->c_is_udp ) {
1361 ber = op->o_res_ber;
1365 ber_init_w_nullc( ber, LBER_USE_DER );
1366 ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
1369 rc = ber_printf( ber, "{it{W}" /*"}"*/ , op->o_msgid,
1370 LDAP_RES_SEARCH_REFERENCE, rs->sr_ref );
1373 rc = send_ldap_controls( op, ber, rs->sr_ctrls );
1377 rc = ber_printf( ber, /*"{"*/ "N}" );
1381 Debug( LDAP_DEBUG_ANY,
1382 "send_search_reference: ber_printf failed\n", 0, 0, 0 );
1384 #ifdef LDAP_CONNECTIONLESS
1385 if (!op->o_conn || op->o_conn->c_is_udp == 0)
1387 ber_free_buf( ber );
1388 send_ldap_error( op, rs, LDAP_OTHER, "encode DN error" );
1393 if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
1394 be_entry_release_rw( op, rs->sr_entry, 0 );
1395 rs->sr_flags ^= REP_ENTRY_MUSTRELEASE;
1396 rs->sr_entry = NULL;
1399 #ifdef LDAP_CONNECTIONLESS
1400 if (!op->o_conn || op->o_conn->c_is_udp == 0) {
1402 bytes = send_ldap_ber( op->o_conn, ber );
1403 ber_free_buf( ber );
1405 ldap_pvt_thread_mutex_lock( &slap_counters.sc_sent_mutex );
1406 ldap_pvt_mp_add_ulong( slap_counters.sc_bytes, (unsigned long)bytes );
1407 ldap_pvt_mp_add_ulong( slap_counters.sc_refs, 1 );
1408 ldap_pvt_mp_add_ulong( slap_counters.sc_pdu, 1 );
1409 ldap_pvt_thread_mutex_unlock( &slap_counters.sc_sent_mutex );
1410 #ifdef LDAP_CONNECTIONLESS
1413 if ( rs->sr_ref != NULL ) {
1416 for ( r = 0; !BER_BVISNULL( &rs->sr_ref[ r ] ); r++ ) {
1417 Statslog( LDAP_DEBUG_STATS2, "%s REF #%d \"%s\"\n",
1418 op->o_log_prefix, r, rs->sr_ref[0].bv_val,
1423 Statslog( LDAP_DEBUG_STATS2, "%s REF \"(null)\"\n",
1424 op->o_log_prefix, 0, 0, 0, 0 );
1427 Debug( LDAP_DEBUG_TRACE, "<= send_search_reference\n", 0, 0, 0 );
1430 if ( op->o_callback ) {
1431 (void)slap_cleanup_play( op, rs );
1447 *code = LDAP_SUCCESS;
1451 if ( strncasecmp( s, "RESULT", STRLENOF( "RESULT" ) ) != 0 ) {
1452 Debug( LDAP_DEBUG_ANY, "str2result (%s) expecting \"RESULT\"\n",
1459 while ( (s = strchr( s, '\n' )) != NULL ) {
1464 if ( (c = strchr( s, ':' )) != NULL ) {
1468 if ( strncasecmp( s, "code", STRLENOF( "code" ) ) == 0 ) {
1473 Debug( LDAP_DEBUG_ANY, "str2result (%s) missing value\n",
1479 while ( isspace( (unsigned char) c[ 0 ] ) ) c++;
1480 if ( c[ 0 ] == '\0' ) {
1481 Debug( LDAP_DEBUG_ANY, "str2result (%s) missing or empty value\n",
1487 retcode = strtol( c, &next, 10 );
1488 if ( next == NULL || next == c ) {
1489 Debug( LDAP_DEBUG_ANY, "str2result (%s) unable to parse value\n",
1495 while ( isspace( (unsigned char) next[ 0 ] ) ) next++;
1496 if ( next[ 0 ] != '\0' ) {
1497 Debug( LDAP_DEBUG_ANY, "str2result (%s) extra cruft after value\n",
1503 /* FIXME: what if it's larger that max int? */
1504 *code = (int)retcode;
1506 } else if ( strncasecmp( s, "matched", STRLENOF( "matched" ) ) == 0 ) {
1510 } else if ( strncasecmp( s, "info", STRLENOF( "info" ) ) == 0 ) {
1515 Debug( LDAP_DEBUG_ANY, "str2result (%s) unknown\n",
1525 int slap_read_controls(
1529 const struct berval *oid,
1530 LDAPControl **ctrl )
1534 BerElementBuffer berbuf;
1535 BerElement *ber = (BerElement *) &berbuf;
1539 Debug( LDAP_DEBUG_ANY, "slap_read_controls: (%s) %s\n",
1540 oid->bv_val, e->e_dn, 0 );
1543 rs->sr_attrs = ( oid == &slap_pre_read_bv ) ?
1544 op->o_preread_attrs : op->o_postread_attrs;
1546 bv.bv_len = entry_flatsize( rs->sr_entry, 0 );
1547 bv.bv_val = op->o_tmpalloc(bv.bv_len, op->o_tmpmemctx );
1549 ber_init2( ber, &bv, LBER_USE_DER );
1550 ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
1552 /* create new operation */
1555 myop.o_res_ber = ber;
1556 myop.o_callback = NULL;
1557 myop.ors_slimit = 1;
1559 rc = slap_send_search_entry( &myop, rs );
1562 rc = ber_flatten2( ber, &c.ldctl_value, 0 );
1564 if( rc == LBER_ERROR ) return LDAP_OTHER;
1566 c.ldctl_oid = oid->bv_val;
1567 c.ldctl_iscritical = 0;
1569 if ( *ctrl == NULL ) {
1571 *ctrl = (LDAPControl *) slap_sl_calloc( 1, sizeof(LDAPControl), NULL );
1573 /* retry: free previous try */
1574 slap_sl_free( (*ctrl)->ldctl_value.bv_val, op->o_tmpmemctx );
1578 return LDAP_SUCCESS;
1581 /* Map API errors to protocol errors... */
1583 slap_map_api2result( SlapReply *rs )
1585 switch(rs->sr_err) {
1586 case LDAP_SERVER_DOWN:
1587 return LDAP_UNAVAILABLE;
1588 case LDAP_LOCAL_ERROR:
1590 case LDAP_ENCODING_ERROR:
1591 case LDAP_DECODING_ERROR:
1592 return LDAP_PROTOCOL_ERROR;
1594 return LDAP_UNAVAILABLE;
1595 case LDAP_AUTH_UNKNOWN:
1596 return LDAP_AUTH_METHOD_NOT_SUPPORTED;
1597 case LDAP_FILTER_ERROR:
1598 rs->sr_text = "Filter error";
1600 case LDAP_USER_CANCELLED:
1601 rs->sr_text = "User cancelled";
1603 case LDAP_PARAM_ERROR:
1604 return LDAP_PROTOCOL_ERROR;
1605 case LDAP_NO_MEMORY:
1607 case LDAP_CONNECT_ERROR:
1608 return LDAP_UNAVAILABLE;
1609 case LDAP_NOT_SUPPORTED:
1610 return LDAP_UNWILLING_TO_PERFORM;
1611 case LDAP_CONTROL_NOT_FOUND:
1612 return LDAP_PROTOCOL_ERROR;
1613 case LDAP_NO_RESULTS_RETURNED:
1614 return LDAP_NO_SUCH_OBJECT;
1615 case LDAP_MORE_RESULTS_TO_RETURN:
1616 rs->sr_text = "More results to return";
1618 case LDAP_CLIENT_LOOP:
1619 case LDAP_REFERRAL_LIMIT_EXCEEDED:
1620 return LDAP_LOOP_DETECT;
1622 if ( LDAP_API_ERROR(rs->sr_err) ) return LDAP_OTHER;
1629 slap_attr_flags( AttributeName *an )
1631 slap_mask_t flags = SLAP_ATTRS_UNDEFINED;
1634 flags |= ( SLAP_OPATTRS_NO | SLAP_USERATTRS_YES );
1637 flags |= an_find( an, &AllOper )
1638 ? SLAP_OPATTRS_YES : SLAP_OPATTRS_NO;
1639 flags |= an_find( an, &AllUser )
1640 ? SLAP_USERATTRS_YES : SLAP_USERATTRS_NO;