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_flush( conn->c_sb, ber, 0 ) == 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_flush 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}" );
285 BerElementBuffer berbuf;
286 BerElement *ber = (BerElement *) &berbuf;
287 int rc = LDAP_SUCCESS;
290 if ( rs->sr_err == SLAPD_ABANDON ) {
295 if ( op->o_callback ) {
296 slap_callback *sc = op->o_callback, **sc_prev = &sc, *sc_next;
298 rc = SLAP_CB_CONTINUE;
299 for ( sc_next = op->o_callback; sc_next; op->o_callback = sc_next) {
300 sc_next = op->o_callback->sc_next;
301 if ( op->o_callback->sc_response ) {
302 slap_callback *sc2 = op->o_callback;
303 rc = op->o_callback->sc_response( op, rs );
304 if ( op->o_callback != sc2 ) {
305 *sc_prev = op->o_callback;
307 if ( rc != SLAP_CB_CONTINUE || !op->o_callback ) break;
308 if ( op->o_callback != sc2 ) continue;
310 sc_prev = &op->o_callback->sc_next;
314 if ( rc != SLAP_CB_CONTINUE ) goto clean2;
317 #ifdef LDAP_CONNECTIONLESS
318 if (op->o_conn && op->o_conn->c_is_udp)
323 ber_init_w_nullc( ber, LBER_USE_DER );
324 ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
327 Debug( LDAP_DEBUG_TRACE,
328 "send_ldap_response: msgid=%d tag=%lu err=%d\n",
329 rs->sr_msgid, rs->sr_tag, rs->sr_err );
332 Debug( LDAP_DEBUG_ARGS, "send_ldap_response: ref=\"%s\"\n",
333 rs->sr_ref[0].bv_val ? rs->sr_ref[0].bv_val : "NULL",
337 #ifdef LDAP_CONNECTIONLESS
338 if (op->o_conn && op->o_conn->c_is_udp &&
339 op->o_protocol == LDAP_VERSION2 )
341 rc = ber_printf( ber, "t{ess" /*"}"*/,
342 rs->sr_tag, rs->sr_err,
343 rs->sr_matched == NULL ? "" : rs->sr_matched,
344 rs->sr_text == NULL ? "" : rs->sr_text );
347 if ( rs->sr_type == REP_INTERMEDIATE ) {
348 rc = ber_printf( ber, "{it{" /*"}}"*/,
349 rs->sr_msgid, rs->sr_tag );
352 rc = ber_printf( ber, "{it{ess" /*"}}"*/,
353 rs->sr_msgid, rs->sr_tag, rs->sr_err,
354 rs->sr_matched == NULL ? "" : rs->sr_matched,
355 rs->sr_text == NULL ? "" : rs->sr_text );
359 if ( rs->sr_ref != NULL ) {
360 assert( rs->sr_err == LDAP_REFERRAL );
361 rc = ber_printf( ber, "t{W}",
362 LDAP_TAG_REFERRAL, rs->sr_ref );
364 assert( rs->sr_err != LDAP_REFERRAL );
368 if( rc != -1 && rs->sr_type == REP_SASL && rs->sr_sasldata != NULL ) {
369 rc = ber_printf( ber, "tO",
370 LDAP_TAG_SASL_RES_CREDS, rs->sr_sasldata );
374 ( rs->sr_type == REP_EXTENDED || rs->sr_type == REP_INTERMEDIATE ))
376 if ( rs->sr_rspoid != NULL ) {
377 rc = ber_printf( ber, "ts",
378 rs->sr_type == REP_EXTENDED
379 ? LDAP_TAG_EXOP_RES_OID : LDAP_TAG_IM_RES_OID,
382 if( rc != -1 && rs->sr_rspdata != NULL ) {
383 rc = ber_printf( ber, "tO",
384 rs->sr_type == REP_EXTENDED
385 ? LDAP_TAG_EXOP_RES_VALUE : LDAP_TAG_IM_RES_VALUE,
391 rc = ber_printf( ber, /*"{"*/ "N}" );
395 rc = send_ldap_controls( op, ber, rs->sr_ctrls );
399 rc = ber_printf( ber, /*"{"*/ "N}" );
402 #ifdef LDAP_CONNECTIONLESS
403 if( op->o_conn && op->o_conn->c_is_udp && op->o_protocol == LDAP_VERSION2
406 rc = ber_printf( ber, /*"{"*/ "N}" );
411 Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
413 #ifdef LDAP_CONNECTIONLESS
414 if (!op->o_conn || op->o_conn->c_is_udp == 0)
423 bytes = send_ldap_ber( op->o_conn, ber );
424 #ifdef LDAP_CONNECTIONLESS
425 if (!op->o_conn || op->o_conn->c_is_udp == 0)
432 Debug( LDAP_DEBUG_ANY,
433 "send_ldap_response: ber write failed\n",
439 ldap_pvt_thread_mutex_lock( &slap_counters.sc_sent_mutex );
440 ldap_pvt_mp_add_ulong( slap_counters.sc_pdu, 1 );
441 ldap_pvt_mp_add_ulong( slap_counters.sc_bytes, (unsigned long)bytes );
442 ldap_pvt_thread_mutex_unlock( &slap_counters.sc_sent_mutex );
445 /* Tell caller that we did this for real, as opposed to being
446 * overridden by a callback
448 rc = SLAP_CB_CONTINUE;
451 if ( op->o_callback ) {
452 slap_callback *sc = op->o_callback, **sc_prev = &sc, *sc_next;
454 for ( sc_next = op->o_callback; sc_next; op->o_callback = sc_next) {
455 sc_next = op->o_callback->sc_next;
456 if ( op->o_callback->sc_cleanup ) {
457 slap_callback *sc2 = op->o_callback;
458 (void)op->o_callback->sc_cleanup( op, rs );
459 if ( op->o_callback != sc2 ) {
460 *sc_prev = op->o_callback;
462 if ( !op->o_callback ) break;
463 if ( op->o_callback != sc2 ) continue;
465 sc_prev = &op->o_callback->sc_next;
471 if ( rs->sr_matched && rs->sr_flags & REP_MATCHED_MUSTBEFREED ) {
472 free( (char *)rs->sr_matched );
473 rs->sr_matched = NULL;
476 if ( rs->sr_ref && rs->sr_flags & REP_REF_MUSTBEFREED ) {
477 ber_bvarray_free( rs->sr_ref );
486 send_ldap_disconnect( Operation *op, SlapReply *rs )
488 #define LDAP_UNSOLICITED_ERROR(e) \
489 ( (e) == LDAP_PROTOCOL_ERROR \
490 || (e) == LDAP_STRONG_AUTH_REQUIRED \
491 || (e) == LDAP_UNAVAILABLE )
493 assert( LDAP_UNSOLICITED_ERROR( rs->sr_err ) );
495 rs->sr_type = REP_EXTENDED;
497 Debug( LDAP_DEBUG_TRACE,
498 "send_ldap_disconnect %d:%s\n",
499 rs->sr_err, rs->sr_text ? rs->sr_text : "", NULL );
501 if ( op->o_protocol < LDAP_VERSION3 ) {
502 rs->sr_rspoid = NULL;
503 rs->sr_tag = slap_req2res( op->o_tag );
504 rs->sr_msgid = (rs->sr_tag != LBER_SEQUENCE) ? op->o_msgid : 0;
507 rs->sr_rspoid = LDAP_NOTICE_DISCONNECT;
508 rs->sr_tag = LDAP_RES_EXTENDED;
512 if ( send_ldap_response( op, rs ) == SLAP_CB_CONTINUE ) {
513 Statslog( LDAP_DEBUG_STATS,
514 "%s DISCONNECT tag=%lu err=%d text=%s\n",
515 op->o_log_prefix, rs->sr_tag, rs->sr_err,
516 rs->sr_text ? rs->sr_text : "", 0 );
521 slap_send_ldap_result( Operation *op, SlapReply *rs )
524 const char *otext = rs->sr_text;
525 BerVarray oref = rs->sr_ref;
527 rs->sr_type = REP_RESULT;
529 /* Propagate Abandons so that cleanup callbacks can be processed */
530 if ( rs->sr_err == SLAPD_ABANDON )
533 assert( !LDAP_API_ERROR( rs->sr_err ) );
535 Debug( LDAP_DEBUG_TRACE,
536 "send_ldap_result: %s p=%d\n",
537 op->o_log_prefix, op->o_protocol, 0 );
539 Debug( LDAP_DEBUG_ARGS,
540 "send_ldap_result: err=%d matched=\"%s\" text=\"%s\"\n",
541 rs->sr_err, rs->sr_matched ? rs->sr_matched : "",
542 rs->sr_text ? rs->sr_text : "" );
546 Debug( LDAP_DEBUG_ARGS,
547 "send_ldap_result: referral=\"%s\"\n",
548 rs->sr_ref[0].bv_val ? rs->sr_ref[0].bv_val : "NULL",
552 assert( rs->sr_err != LDAP_PARTIAL_RESULTS );
554 if ( rs->sr_err == LDAP_REFERRAL ) {
555 if( op->o_domain_scope ) rs->sr_ref = NULL;
557 if( rs->sr_ref == NULL ) {
558 rs->sr_err = LDAP_NO_SUCH_OBJECT;
559 } else if ( op->o_protocol < LDAP_VERSION3 ) {
560 rs->sr_err = LDAP_PARTIAL_RESULTS;
564 if ( op->o_protocol < LDAP_VERSION3 ) {
565 tmp = v2ref( rs->sr_ref, rs->sr_text );
570 rs->sr_tag = slap_req2res( op->o_tag );
571 rs->sr_msgid = (rs->sr_tag != LBER_SEQUENCE) ? op->o_msgid : 0;
574 if ( send_ldap_response( op, rs ) == SLAP_CB_CONTINUE ) {
575 if ( op->o_tag == LDAP_REQ_SEARCH ) {
577 snprintf( nbuf, sizeof nbuf, "%d nentries=%d",
578 rs->sr_err, rs->sr_nentries );
580 Statslog( LDAP_DEBUG_STATS,
581 "%s SEARCH RESULT tag=%lu err=%s text=%s\n",
582 op->o_log_prefix, rs->sr_tag, nbuf,
583 rs->sr_text ? rs->sr_text : "", 0 );
585 Statslog( LDAP_DEBUG_STATS,
586 "%s RESULT tag=%lu err=%d text=%s\n",
587 op->o_log_prefix, rs->sr_tag, rs->sr_err,
588 rs->sr_text ? rs->sr_text : "", 0 );
592 if( tmp != NULL ) ch_free(tmp);
598 send_ldap_sasl( Operation *op, SlapReply *rs )
600 rs->sr_type = REP_SASL;
601 Debug( LDAP_DEBUG_TRACE, "send_ldap_sasl: err=%d len=%ld\n",
603 rs->sr_sasldata ? (long) rs->sr_sasldata->bv_len : -1, NULL );
605 rs->sr_tag = slap_req2res( op->o_tag );
606 rs->sr_msgid = (rs->sr_tag != LBER_SEQUENCE) ? op->o_msgid : 0;
608 if ( send_ldap_response( op, rs ) == SLAP_CB_CONTINUE ) {
609 Statslog( LDAP_DEBUG_STATS,
610 "%s RESULT tag=%lu err=%d text=%s\n",
611 op->o_log_prefix, rs->sr_tag, rs->sr_err,
612 rs->sr_text ? rs->sr_text : "", 0 );
617 slap_send_ldap_extended( Operation *op, SlapReply *rs )
619 rs->sr_type = REP_EXTENDED;
621 Debug( LDAP_DEBUG_TRACE,
622 "send_ldap_extended: err=%d oid=%s len=%ld\n",
624 rs->sr_rspoid ? rs->sr_rspoid : "",
625 rs->sr_rspdata != NULL ? rs->sr_rspdata->bv_len : 0 );
627 rs->sr_tag = slap_req2res( op->o_tag );
628 rs->sr_msgid = (rs->sr_tag != LBER_SEQUENCE) ? op->o_msgid : 0;
630 if ( send_ldap_response( op, rs ) == SLAP_CB_CONTINUE ) {
631 Statslog( LDAP_DEBUG_STATS,
632 "%s RESULT oid=%s err=%d text=%s\n",
633 op->o_log_prefix, rs->sr_rspoid ? rs->sr_rspoid : "",
634 rs->sr_err, rs->sr_text ? rs->sr_text : "", 0 );
639 slap_send_ldap_intermediate( Operation *op, SlapReply *rs )
641 rs->sr_type = REP_INTERMEDIATE;
642 Debug( LDAP_DEBUG_TRACE,
643 "send_ldap_intermediate: err=%d oid=%s len=%ld\n",
645 rs->sr_rspoid ? rs->sr_rspoid : "",
646 rs->sr_rspdata != NULL ? rs->sr_rspdata->bv_len : 0 );
647 rs->sr_tag = LDAP_RES_INTERMEDIATE;
648 rs->sr_msgid = op->o_msgid;
649 if ( send_ldap_response( op, rs ) == SLAP_CB_CONTINUE ) {
650 Statslog( LDAP_DEBUG_STATS2,
651 "%s INTERM oid=%s\n",
653 rs->sr_rspoid ? rs->sr_rspoid : "", 0, 0, 0 );
660 * LDAP_SUCCESS entry sent
661 * LDAP_OTHER entry not sent (other)
662 * LDAP_INSUFFICIENT_ACCESS entry not sent (ACL)
663 * LDAP_UNAVAILABLE entry not sent (connection closed)
664 * LDAP_SIZELIMIT_EXCEEDED entry not sent (caller must send sizelimitExceeded)
668 slap_send_search_entry( Operation *op, SlapReply *rs )
670 BerElementBuffer berbuf;
671 BerElement *ber = (BerElement *) &berbuf;
673 int i, j, rc = LDAP_UNAVAILABLE, bytes;
676 AccessControlState acl_state = ACL_STATE_INIT;
678 AttributeDescription *ad_entry = slap_schema.si_ad_entry;
680 /* a_flags: array of flags telling if the i-th element will be
681 * returned or filtered out
682 * e_flags: array of a_flags
684 char **e_flags = NULL;
686 if ( op->ors_slimit >= 0 && rs->sr_nentries >= op->ors_slimit ) {
687 return LDAP_SIZELIMIT_EXCEEDED;
690 rs->sr_type = REP_SEARCH;
692 /* eventually will loop through generated operational attribute types
693 * currently implemented types include:
694 * entryDN, subschemaSubentry, and hasSubordinates */
695 /* NOTE: moved before overlays callback circling because
696 * they may modify entry and other stuff in rs */
697 /* check for special all operational attributes ("+") type */
698 /* FIXME: maybe we could se this flag at the operation level;
699 * however, in principle the caller of send_search_entry() may
700 * change the attribute list at each call */
701 rs->sr_attr_flags = slap_attr_flags( rs->sr_attrs );
703 rc = backend_operational( op, rs );
708 if ( op->o_callback ) {
709 slap_callback *sc = op->o_callback, **sc_prev = &sc, *sc_next;
711 rc = SLAP_CB_CONTINUE;
712 for ( sc_next = op->o_callback; sc_next; op->o_callback = sc_next )
714 sc_next = op->o_callback->sc_next;
715 if ( op->o_callback->sc_response ) {
716 slap_callback *sc2 = op->o_callback;
717 rc = op->o_callback->sc_response( op, rs );
718 if ( op->o_callback != sc2 ) {
719 *sc_prev = op->o_callback;
721 if ( rc != SLAP_CB_CONTINUE || !op->o_callback ) break;
722 if ( op->o_callback != sc2 ) continue;
724 sc_prev = &op->o_callback->sc_next;
728 if ( rc != SLAP_CB_CONTINUE ) goto error_return;
731 Debug( LDAP_DEBUG_TRACE, "=> send_search_entry: conn %lu dn=\"%s\"%s\n",
732 op->o_connid, rs->sr_entry->e_name.bv_val,
733 op->ors_attrsonly ? " (attrsOnly)" : "" );
735 attrsonly = op->ors_attrsonly;
737 if ( !access_allowed( op, rs->sr_entry, ad_entry, NULL, ACL_READ, NULL )) {
738 Debug( LDAP_DEBUG_ACL,
739 "send_search_entry: conn %lu access to entry (%s) not allowed\n",
740 op->o_connid, rs->sr_entry->e_name.bv_val, 0 );
742 rc = LDAP_INSUFFICIENT_ACCESS;
746 edn = rs->sr_entry->e_nname.bv_val;
748 if ( op->o_res_ber ) {
749 /* read back control or LDAP_CONNECTIONLESS */
754 bv.bv_len = entry_flatsize( rs->sr_entry, 0 );
755 bv.bv_val = op->o_tmpalloc( bv.bv_len, op->o_tmpmemctx );
757 ber_init2( ber, &bv, LBER_USE_DER );
758 ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
761 #ifdef LDAP_CONNECTIONLESS
762 if ( op->o_conn && op->o_conn->c_is_udp ) {
764 if ( op->o_protocol == LDAP_VERSION2 ) {
765 rc = ber_printf(ber, "t{O{" /*}}*/,
766 LDAP_RES_SEARCH_ENTRY, &rs->sr_entry->e_name );
768 rc = ber_printf( ber, "{it{O{" /*}}}*/, op->o_msgid,
769 LDAP_RES_SEARCH_ENTRY, &rs->sr_entry->e_name );
773 if ( op->o_res_ber ) {
774 /* read back control */
775 rc = ber_printf( ber, "{O{" /*}}*/, &rs->sr_entry->e_name );
777 rc = ber_printf( ber, "{it{O{" /*}}}*/, op->o_msgid,
778 LDAP_RES_SEARCH_ENTRY, &rs->sr_entry->e_name );
782 Debug( LDAP_DEBUG_ANY,
783 "send_search_entry: conn %lu ber_printf failed\n",
784 op->o_connid, 0, 0 );
786 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
787 send_ldap_error( op, rs, LDAP_OTHER, "encoding DN error" );
792 /* check for special all user attributes ("*") type */
793 userattrs = SLAP_USERATTRS( rs->sr_attr_flags );
795 /* create an array of arrays of flags. Each flag corresponds
796 * to particular value of attribute and equals 1 if value matches
797 * to ValuesReturnFilter or 0 if not
799 if ( op->o_vrFilter != NULL ) {
803 for ( a = rs->sr_entry->e_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
804 for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) k++;
807 size = i * sizeof(char *) + k;
810 e_flags = slap_sl_calloc ( 1, i * sizeof(char *) + k, op->o_tmpmemctx );
811 if( e_flags == NULL ) {
812 Debug( LDAP_DEBUG_ANY,
813 "send_search_entry: conn %lu slap_sl_calloc failed\n",
814 op->o_connid ? op->o_connid : 0, 0, 0 );
817 send_ldap_error( op, rs, LDAP_OTHER, "out of memory" );
820 a_flags = (char *)(e_flags + i);
821 memset( a_flags, 0, k );
822 for ( a=rs->sr_entry->e_attrs, i=0; a != NULL; a=a->a_next, i++ ) {
823 for ( j = 0; a->a_vals[j].bv_val != NULL; j++ );
824 e_flags[i] = a_flags;
828 rc = filter_matched_values(op, rs->sr_entry->e_attrs, &e_flags) ;
830 Debug( LDAP_DEBUG_ANY, "send_search_entry: "
831 "conn %lu matched values filtering failed\n",
832 op->o_connid ? op->o_connid : 0, 0, 0 );
833 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
834 send_ldap_error( op, rs, LDAP_OTHER,
835 "matched values filtering error" );
842 for ( a = rs->sr_entry->e_attrs, j = 0; a != NULL; a = a->a_next, j++ ) {
843 AttributeDescription *desc = a->a_desc;
846 if ( rs->sr_attrs == NULL ) {
847 /* all user attrs request, skip operational attributes */
848 if( is_at_operational( desc->ad_type ) ) {
853 /* specific attrs requested */
854 if ( is_at_operational( desc->ad_type ) ) {
855 if ( !SLAP_OPATTRS( rs->sr_attr_flags ) &&
856 !ad_inlist( desc, rs->sr_attrs ) )
862 if ( !userattrs && !ad_inlist( desc, rs->sr_attrs ) ) {
869 if ( ! access_allowed( op, rs->sr_entry, desc, NULL,
870 ACL_READ, &acl_state ) )
872 Debug( LDAP_DEBUG_ACL, "send_search_entry: "
873 "conn %lu access to attribute %s not allowed\n",
874 op->o_connid, desc->ad_cname.bv_val, 0 );
878 if (( rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname )) == -1 ) {
879 Debug( LDAP_DEBUG_ANY,
880 "send_search_entry: conn %lu ber_printf failed\n",
881 op->o_connid, 0, 0 );
883 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
884 send_ldap_error( op, rs, LDAP_OTHER,
885 "encoding description error");
893 for ( i = 0; a->a_nvals[i].bv_val != NULL; i++ ) {
894 if ( ! access_allowed( op, rs->sr_entry,
895 desc, &a->a_nvals[i], ACL_READ, &acl_state ) )
897 Debug( LDAP_DEBUG_ACL,
898 "send_search_entry: conn %lu "
899 "access to attribute %s, value #%d not allowed\n",
900 op->o_connid, desc->ad_cname.bv_val, i );
905 if ( op->o_vrFilter && e_flags[j][i] == 0 ){
912 if (( rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname )) == -1 ) {
913 Debug( LDAP_DEBUG_ANY,
914 "send_search_entry: conn %lu ber_printf failed\n",
915 op->o_connid, 0, 0 );
917 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
918 send_ldap_error( op, rs, LDAP_OTHER,
919 "encoding description error");
924 if (( rc = ber_printf( ber, "O", &a->a_vals[i] )) == -1 ) {
925 Debug( LDAP_DEBUG_ANY,
926 "send_search_entry: conn %lu "
927 "ber_printf failed.\n", op->o_connid, 0, 0 );
929 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
930 send_ldap_error( op, rs, LDAP_OTHER,
931 "encoding values error" );
938 if ( finish && ( rc = ber_printf( ber, /*{[*/ "]N}" )) == -1 ) {
939 Debug( LDAP_DEBUG_ANY,
940 "send_search_entry: conn %lu ber_printf failed\n",
941 op->o_connid, 0, 0 );
943 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
944 send_ldap_error( op, rs, LDAP_OTHER, "encode end error" );
950 /* NOTE: moved before overlays callback circling because
951 * they may modify entry and other stuff in rs */
952 if ( rs->sr_operational_attrs != NULL && op->o_vrFilter != NULL ) {
956 for ( a = rs->sr_operational_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
957 for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) k++;
960 size = i * sizeof(char *) + k;
962 char *a_flags, **tmp;
965 * Reuse previous memory - we likely need less space
966 * for operational attributes
968 tmp = slap_sl_realloc( e_flags, i * sizeof(char *) + k,
971 Debug( LDAP_DEBUG_ANY,
972 "send_search_entry: conn %lu "
974 "for matched values filtering\n",
975 op->o_connid, 0, 0 );
976 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
977 send_ldap_error( op, rs, LDAP_OTHER,
978 "not enough memory for matched values filtering" );
982 a_flags = (char *)(e_flags + i);
983 memset( a_flags, 0, k );
984 for ( a = rs->sr_operational_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
985 for ( j = 0; a->a_vals[j].bv_val != NULL; j++ );
986 e_flags[i] = a_flags;
989 rc = filter_matched_values(op, rs->sr_operational_attrs, &e_flags) ;
992 Debug( LDAP_DEBUG_ANY,
993 "send_search_entry: conn %lu "
994 "matched values filtering failed\n",
995 op->o_connid ? op->o_connid : 0, 0, 0);
996 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
997 send_ldap_error( op, rs, LDAP_OTHER,
998 "matched values filtering error" );
1005 for (a = rs->sr_operational_attrs, j=0; a != NULL; a = a->a_next, j++ ) {
1006 AttributeDescription *desc = a->a_desc;
1008 if ( rs->sr_attrs == NULL ) {
1009 /* all user attrs request, skip operational attributes */
1010 if( is_at_operational( desc->ad_type ) ) {
1015 /* specific attrs requested */
1016 if( is_at_operational( desc->ad_type ) ) {
1017 if ( !SLAP_OPATTRS( rs->sr_attr_flags ) &&
1018 !ad_inlist( desc, rs->sr_attrs ) )
1023 if ( !userattrs && !ad_inlist( desc, rs->sr_attrs ) ) {
1029 if ( ! access_allowed( op, rs->sr_entry, desc, NULL,
1030 ACL_READ, &acl_state ) )
1032 Debug( LDAP_DEBUG_ACL,
1033 "send_search_entry: conn %lu "
1034 "access to attribute %s not allowed\n",
1035 op->o_connid, desc->ad_cname.bv_val, 0 );
1040 rc = ber_printf( ber, "{O[" /*]}*/ , &desc->ad_cname );
1042 Debug( LDAP_DEBUG_ANY,
1043 "send_search_entry: conn %lu "
1044 "ber_printf failed\n", op->o_connid, 0, 0 );
1046 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1047 send_ldap_error( op, rs, LDAP_OTHER,
1048 "encoding description error" );
1053 if ( ! attrsonly ) {
1054 for ( i = 0; a->a_vals[i].bv_val != NULL; i++ ) {
1055 if ( ! access_allowed( op, rs->sr_entry,
1056 desc, &a->a_vals[i], ACL_READ, &acl_state ) )
1058 Debug( LDAP_DEBUG_ACL,
1059 "send_search_entry: conn %lu "
1060 "access to %s, value %d not allowed\n",
1061 op->o_connid, desc->ad_cname.bv_val, i );
1066 if ( op->o_vrFilter && e_flags[j][i] == 0 ){
1070 if (( rc = ber_printf( ber, "O", &a->a_vals[i] )) == -1 ) {
1071 Debug( LDAP_DEBUG_ANY,
1072 "send_search_entry: conn %lu ber_printf failed\n",
1073 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 "encoding values error" );
1084 if (( rc = ber_printf( ber, /*{[*/ "]N}" )) == -1 ) {
1085 Debug( LDAP_DEBUG_ANY,
1086 "send_search_entry: conn %lu ber_printf failed\n",
1087 op->o_connid, 0, 0 );
1089 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1090 send_ldap_error( op, rs, LDAP_OTHER, "encode end error" );
1098 slap_sl_free( e_flags, op->o_tmpmemctx );
1102 rc = ber_printf( ber, /*{{*/ "}N}" );
1105 rc = send_ldap_controls( op, ber, rs->sr_ctrls );
1109 #ifdef LDAP_CONNECTIONLESS
1110 if( op->o_conn && op->o_conn->c_is_udp ) {
1111 if ( op->o_protocol != LDAP_VERSION2 ) {
1112 rc = ber_printf( ber, /*{*/ "N}" );
1116 if ( op->o_res_ber == NULL ) {
1117 rc = ber_printf( ber, /*{*/ "N}" );
1122 Debug( LDAP_DEBUG_ANY, "ber_printf failed\n", 0, 0, 0 );
1124 if ( op->o_res_ber == NULL ) ber_free_buf( ber );
1125 send_ldap_error( op, rs, LDAP_OTHER, "encode entry end error" );
1130 if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
1131 be_entry_release_rw( op, rs->sr_entry, 0 );
1132 rs->sr_flags ^= REP_ENTRY_MUSTRELEASE;
1133 rs->sr_entry = NULL;
1136 if ( op->o_res_ber == NULL ) {
1137 bytes = send_ldap_ber( op->o_conn, ber );
1138 ber_free_buf( ber );
1141 Debug( LDAP_DEBUG_ANY,
1142 "send_search_entry: conn %lu ber write failed.\n",
1143 op->o_connid, 0, 0 );
1145 rc = LDAP_UNAVAILABLE;
1150 ldap_pvt_thread_mutex_lock( &slap_counters.sc_sent_mutex );
1151 ldap_pvt_mp_add_ulong( slap_counters.sc_bytes, (unsigned long)bytes );
1152 ldap_pvt_mp_add_ulong( slap_counters.sc_entries, 1 );
1153 ldap_pvt_mp_add_ulong( slap_counters.sc_pdu, 1 );
1154 ldap_pvt_thread_mutex_unlock( &slap_counters.sc_sent_mutex );
1157 Statslog( LDAP_DEBUG_STATS2, "%s ENTRY dn=\"%s\"\n",
1158 op->o_log_prefix, edn, 0, 0, 0 );
1160 Debug( LDAP_DEBUG_TRACE,
1161 "<= send_search_entry: conn %lu exit.\n", op->o_connid, 0, 0 );
1166 if ( op->o_callback ) {
1167 slap_callback *sc = op->o_callback, **sc_prev = &sc, *sc_next;
1169 for ( sc_next = op->o_callback; sc_next; op->o_callback = sc_next) {
1170 sc_next = op->o_callback->sc_next;
1171 if ( op->o_callback->sc_cleanup ) {
1172 slap_callback *sc2 = op->o_callback;
1173 (void)op->o_callback->sc_cleanup( op, rs );
1174 if ( op->o_callback != sc2 ) {
1175 *sc_prev = op->o_callback;
1177 if ( !op->o_callback ) break;
1178 if ( op->o_callback != sc2 ) continue;
1180 sc_prev = &op->o_callback->sc_next;
1182 op->o_callback = sc;
1186 slap_sl_free( e_flags, op->o_tmpmemctx );
1189 if ( rs->sr_operational_attrs ) {
1190 attrs_free( rs->sr_operational_attrs );
1191 rs->sr_operational_attrs = NULL;
1193 rs->sr_attr_flags = SLAP_ATTRS_UNDEFINED;
1195 /* FIXME: I think rs->sr_type should be explicitly set to
1196 * REP_SEARCH here. That's what it was when we entered this
1197 * function. send_ldap_error may have changed it, but we
1198 * should set it back so that the cleanup functions know
1199 * what they're doing.
1201 if ( op->o_tag == LDAP_REQ_SEARCH && rs->sr_type == REP_SEARCH
1203 && ( rs->sr_flags & REP_ENTRY_MUSTBEFREED ) )
1205 entry_free( rs->sr_entry );
1206 rs->sr_entry = NULL;
1207 rs->sr_flags &= ~REP_ENTRY_MUSTBEFREED;
1214 slap_send_search_reference( Operation *op, SlapReply *rs )
1216 BerElementBuffer berbuf;
1217 BerElement *ber = (BerElement *) &berbuf;
1221 AttributeDescription *ad_ref = slap_schema.si_ad_ref;
1222 AttributeDescription *ad_entry = slap_schema.si_ad_entry;
1224 rs->sr_type = REP_SEARCHREF;
1225 if ( op->o_callback ) {
1226 slap_callback *sc = op->o_callback, **sc_prev = &sc, *sc_next;
1228 rc = SLAP_CB_CONTINUE;
1229 for ( sc_next = op->o_callback; sc_next; op->o_callback = sc_next) {
1230 sc_next = op->o_callback->sc_next;
1231 if ( op->o_callback->sc_response ) {
1232 slap_callback *sc2 = op->o_callback;
1233 rc = op->o_callback->sc_response( op, rs );
1234 if ( op->o_callback != sc2 ) {
1235 *sc_prev = op->o_callback;
1237 if ( rc != SLAP_CB_CONTINUE || !op->o_callback ) break;
1238 if ( op->o_callback != sc2 ) continue;
1240 sc_prev = &op->o_callback->sc_next;
1243 op->o_callback = sc;
1244 if ( rc != SLAP_CB_CONTINUE ) goto rel;
1247 Debug( LDAP_DEBUG_TRACE,
1248 "=> send_search_reference: dn=\"%s\"\n",
1249 rs->sr_entry ? rs->sr_entry->e_name.bv_val : "(null)", 0, 0 );
1251 if ( rs->sr_entry && ! access_allowed( op, rs->sr_entry,
1252 ad_entry, NULL, ACL_READ, NULL ) )
1254 Debug( LDAP_DEBUG_ACL,
1255 "send_search_reference: access to entry not allowed\n",
1261 if ( rs->sr_entry && ! access_allowed( op, rs->sr_entry,
1262 ad_ref, NULL, ACL_READ, NULL ) )
1264 Debug( LDAP_DEBUG_ACL,
1265 "send_search_reference: access "
1266 "to reference not allowed\n",
1272 if( op->o_domain_scope ) {
1273 Debug( LDAP_DEBUG_ANY,
1274 "send_search_reference: domainScope control in (%s)\n",
1275 rs->sr_entry->e_dn, 0, 0 );
1280 if( rs->sr_ref == NULL ) {
1281 Debug( LDAP_DEBUG_ANY,
1282 "send_search_reference: null ref in (%s)\n",
1283 rs->sr_entry ? rs->sr_entry->e_dn : "(null)", 0, 0 );
1288 if( op->o_protocol < LDAP_VERSION3 ) {
1290 /* save the references for the result */
1291 if( rs->sr_ref[0].bv_val != NULL ) {
1292 if( value_add( &rs->sr_v2ref, rs->sr_ref ) )
1298 #ifdef LDAP_CONNECTIONLESS
1299 if( op->o_conn && op->o_conn->c_is_udp ) {
1300 ber = op->o_res_ber;
1304 ber_init_w_nullc( ber, LBER_USE_DER );
1305 ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
1308 rc = ber_printf( ber, "{it{W}" /*"}"*/ , op->o_msgid,
1309 LDAP_RES_SEARCH_REFERENCE, rs->sr_ref );
1312 rc = send_ldap_controls( op, ber, rs->sr_ctrls );
1316 rc = ber_printf( ber, /*"{"*/ "N}" );
1320 Debug( LDAP_DEBUG_ANY,
1321 "send_search_reference: ber_printf failed\n", 0, 0, 0 );
1323 #ifdef LDAP_CONNECTIONLESS
1324 if (!op->o_conn || op->o_conn->c_is_udp == 0)
1326 ber_free_buf( ber );
1327 send_ldap_error( op, rs, LDAP_OTHER, "encode DN error" );
1332 if ( rs->sr_flags & REP_ENTRY_MUSTRELEASE ) {
1333 be_entry_release_rw( op, rs->sr_entry, 0 );
1334 rs->sr_flags ^= REP_ENTRY_MUSTRELEASE;
1335 rs->sr_entry = NULL;
1338 #ifdef LDAP_CONNECTIONLESS
1339 if (!op->o_conn || op->o_conn->c_is_udp == 0) {
1341 bytes = send_ldap_ber( op->o_conn, ber );
1342 ber_free_buf( ber );
1344 ldap_pvt_thread_mutex_lock( &slap_counters.sc_sent_mutex );
1345 ldap_pvt_mp_add_ulong( slap_counters.sc_bytes, (unsigned long)bytes );
1346 ldap_pvt_mp_add_ulong( slap_counters.sc_refs, 1 );
1347 ldap_pvt_mp_add_ulong( slap_counters.sc_pdu, 1 );
1348 ldap_pvt_thread_mutex_unlock( &slap_counters.sc_sent_mutex );
1349 #ifdef LDAP_CONNECTIONLESS
1352 if ( rs->sr_ref != NULL ) {
1355 for ( r = 0; !BER_BVISNULL( &rs->sr_ref[ r ] ); r++ ) {
1356 Statslog( LDAP_DEBUG_STATS2, "%s REF #%d \"%s\"\n",
1357 op->o_log_prefix, r, rs->sr_ref[0].bv_val,
1362 Statslog( LDAP_DEBUG_STATS2, "%s REF \"(null)\"\n",
1363 op->o_log_prefix, 0, 0, 0, 0 );
1366 Debug( LDAP_DEBUG_TRACE, "<= send_search_reference\n", 0, 0, 0 );
1369 if ( op->o_callback ) {
1370 slap_callback *sc = op->o_callback, **sc_prev = &sc, *sc_next;
1372 for ( sc_next = op->o_callback; sc_next; op->o_callback = sc_next) {
1373 sc_next = op->o_callback->sc_next;
1374 if ( op->o_callback->sc_cleanup ) {
1375 slap_callback *sc2 = op->o_callback;
1376 (void)op->o_callback->sc_cleanup( op, rs );
1377 if ( op->o_callback != sc2 ) {
1378 *sc_prev = op->o_callback;
1380 if ( rc != SLAP_CB_CONTINUE || !op->o_callback ) break;
1381 if ( op->o_callback != sc2 ) continue;
1383 sc_prev = &op->o_callback->sc_next;
1385 op->o_callback = sc;
1401 *code = LDAP_SUCCESS;
1405 if ( strncasecmp( s, "RESULT", STRLENOF( "RESULT" ) ) != 0 ) {
1406 Debug( LDAP_DEBUG_ANY, "str2result (%s) expecting \"RESULT\"\n",
1413 while ( (s = strchr( s, '\n' )) != NULL ) {
1418 if ( (c = strchr( s, ':' )) != NULL ) {
1422 if ( strncasecmp( s, "code", STRLENOF( "code" ) ) == 0 ) {
1427 Debug( LDAP_DEBUG_ANY, "str2result (%s) missing value\n",
1433 while ( isspace( (unsigned char) c[ 0 ] ) ) c++;
1434 if ( c[ 0 ] == '\0' ) {
1435 Debug( LDAP_DEBUG_ANY, "str2result (%s) missing or empty value\n",
1441 retcode = strtol( c, &next, 10 );
1442 if ( next == NULL || next == c ) {
1443 Debug( LDAP_DEBUG_ANY, "str2result (%s) unable to parse value\n",
1449 while ( isspace( (unsigned char) next[ 0 ] ) ) next++;
1450 if ( next[ 0 ] != '\0' ) {
1451 Debug( LDAP_DEBUG_ANY, "str2result (%s) extra cruft after value\n",
1457 /* FIXME: what if it's larger that max int? */
1458 *code = (int)retcode;
1460 } else if ( strncasecmp( s, "matched", STRLENOF( "matched" ) ) == 0 ) {
1464 } else if ( strncasecmp( s, "info", STRLENOF( "info" ) ) == 0 ) {
1469 Debug( LDAP_DEBUG_ANY, "str2result (%s) unknown\n",
1479 int slap_read_controls(
1483 const struct berval *oid,
1484 LDAPControl **ctrl )
1488 BerElementBuffer berbuf;
1489 BerElement *ber = (BerElement *) &berbuf;
1493 Debug( LDAP_DEBUG_ANY, "slap_read_controls: (%s) %s\n",
1494 oid->bv_val, e->e_dn, 0 );
1497 rs->sr_attrs = ( oid == &slap_pre_read_bv ) ?
1498 op->o_preread_attrs : op->o_postread_attrs;
1500 bv.bv_len = entry_flatsize( rs->sr_entry, 0 );
1501 bv.bv_val = op->o_tmpalloc(bv.bv_len, op->o_tmpmemctx );
1503 ber_init2( ber, &bv, LBER_USE_DER );
1504 ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
1506 /* create new operation */
1509 myop.o_res_ber = ber;
1510 myop.o_callback = NULL;
1511 myop.ors_slimit = 1;
1513 rc = slap_send_search_entry( &myop, rs );
1516 rc = ber_flatten2( ber, &c.ldctl_value, 0 );
1518 if( rc == LBER_ERROR ) return LDAP_OTHER;
1520 c.ldctl_oid = oid->bv_val;
1521 c.ldctl_iscritical = 0;
1523 if ( *ctrl == NULL ) {
1525 *ctrl = (LDAPControl *) slap_sl_calloc( 1, sizeof(LDAPControl), NULL );
1527 /* retry: free previous try */
1528 slap_sl_free( (*ctrl)->ldctl_value.bv_val, op->o_tmpmemctx );
1532 return LDAP_SUCCESS;
1535 /* Map API errors to protocol errors... */
1537 slap_map_api2result( SlapReply *rs )
1539 switch(rs->sr_err) {
1540 case LDAP_SERVER_DOWN:
1541 return LDAP_UNAVAILABLE;
1542 case LDAP_LOCAL_ERROR:
1544 case LDAP_ENCODING_ERROR:
1545 case LDAP_DECODING_ERROR:
1546 return LDAP_PROTOCOL_ERROR;
1548 return LDAP_UNAVAILABLE;
1549 case LDAP_AUTH_UNKNOWN:
1550 return LDAP_AUTH_METHOD_NOT_SUPPORTED;
1551 case LDAP_FILTER_ERROR:
1552 rs->sr_text = "Filter error";
1554 case LDAP_USER_CANCELLED:
1555 rs->sr_text = "User cancelled";
1557 case LDAP_PARAM_ERROR:
1558 return LDAP_PROTOCOL_ERROR;
1559 case LDAP_NO_MEMORY:
1561 case LDAP_CONNECT_ERROR:
1562 return LDAP_UNAVAILABLE;
1563 case LDAP_NOT_SUPPORTED:
1564 return LDAP_UNWILLING_TO_PERFORM;
1565 case LDAP_CONTROL_NOT_FOUND:
1566 return LDAP_PROTOCOL_ERROR;
1567 case LDAP_NO_RESULTS_RETURNED:
1568 return LDAP_NO_SUCH_OBJECT;
1569 case LDAP_MORE_RESULTS_TO_RETURN:
1570 rs->sr_text = "More results to return";
1572 case LDAP_CLIENT_LOOP:
1573 case LDAP_REFERRAL_LIMIT_EXCEEDED:
1574 return LDAP_LOOP_DETECT;
1576 if ( LDAP_API_ERROR(rs->sr_err) ) return LDAP_OTHER;
1583 slap_attr_flags( AttributeName *an )
1585 slap_mask_t flags = SLAP_ATTRS_UNDEFINED;
1588 flags |= ( SLAP_OPATTRS_NO | SLAP_USERATTRS_YES );
1591 flags |= an_find( an, &AllOper )
1592 ? SLAP_OPATTRS_YES : SLAP_OPATTRS_NO;
1593 flags |= an_find( an, &AllUser )
1594 ? SLAP_USERATTRS_YES : SLAP_USERATTRS_NO;