1 /* slapi_overlay.c - SLAPI overlay */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 * Copyright 2001-2005 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>.
17 * This work was initially developed by Luke Howard for inclusion
18 * in OpenLDAP Software.
25 #include <ac/string.h>
26 #include <ac/socket.h>
33 static slap_overinst slapi;
36 slapi_over_pblock_new ( Operation *op )
40 pb = slapi_pblock_new();
44 slapi_int_pblock_set_operation( pb, op );
50 slapi_over_compute_output(
51 computed_attr_context *c,
52 Slapi_Attr *attribute,
58 AttributeDescription *desc;
59 Operation *op = c->cac_op;
60 SlapReply *rs = (SlapReply *)c->cac_private;
62 if ( c == NULL || attribute == NULL || entry == NULL ) {
66 assert( rs->sr_entry == entry );
68 desc = attribute->a_desc;
70 if ( rs->sr_attrs == NULL ) {
71 /* All attrs request, skip operational attributes */
72 if ( is_at_operational( desc->ad_type ) ) {
76 /* Specific attributes requested */
77 if ( is_at_operational( desc->ad_type ) ) {
78 if ( !SLAP_OPATTRS( rs->sr_attr_flags ) &&
79 !ad_inlist( desc, rs->sr_attrs ) ) {
83 if ( !SLAP_USERATTRS( rs->sr_attr_flags ) &&
84 !ad_inlist( desc, rs->sr_attrs ) ) {
90 /* XXX perhaps we should check for existing attributes and merge */
91 for ( a = &rs->sr_operational_attrs; *a != NULL; a = &(*a)->a_next )
94 *a = attr_dup( attribute );
100 slapi_over_aux_operational( Operation *op, SlapReply *rs )
102 /* Support for computed attribute plugins */
103 computed_attr_context ctx;
105 AccessControlState acl_state = ACL_STATE_INIT;
107 ctx.cac_pb = slapi_over_pblock_new( op );
109 ctx.cac_private = rs;
110 ctx.cac_acl_state = &acl_state;
112 if ( rs->sr_entry != NULL ) {
114 * For each client requested attribute, call the plugins.
116 if ( rs->sr_attrs != NULL ) {
117 for ( anp = rs->sr_attrs; anp->an_name.bv_val != NULL; anp++ ) {
118 if ( compute_evaluator( &ctx, anp->an_name.bv_val,
119 rs->sr_entry, slapi_over_compute_output ) == 1 ) {
125 * Technically we shouldn't be returning operational attributes
126 * when the user requested only user attributes. We'll let the
127 * plugin decide whether to be naughty or not.
129 compute_evaluator( &ctx, "*", rs->sr_entry, slapi_over_compute_output );
133 slapi_pblock_destroy( ctx.cac_pb );
135 return SLAP_CB_CONTINUE;
139 slapi_over_search( Operation *op, SlapReply *rs, int type )
144 assert( rs->sr_type == REP_SEARCH || rs->sr_type == REP_SEARCHREF );
146 /* create a new pblock to not trample on result controls */
147 pb = slapi_over_pblock_new( op );
149 slapi_pblock_set( pb, SLAPI_RESCONTROLS, (void *)rs->sr_ctrls );
150 slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_ENTRY, (void *)rs->sr_entry );
152 rc = slapi_int_call_plugins( op->o_bd, type, pb );
153 if ( rc >= 0 ) /* 1 means no plugins called */
154 rc = SLAP_CB_CONTINUE;
156 rc = LDAP_SUCCESS; /* confusing: don't abort, but don't send */
158 slapi_pblock_set( pb, SLAPI_RESCONTROLS, NULL ); /* don't free */
159 slapi_pblock_destroy(pb);
165 slapi_over_count_controls( LDAPControl **controls )
169 if ( controls == NULL )
172 for ( i = 0; controls[i] != NULL; i++ )
179 slapi_over_merge_controls( Operation *op, SlapReply *rs )
181 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
182 LDAPControl **slapiControls = NULL, **mergedControls;
183 int nSlapiControls = 0;
184 int nResControls = 0;
187 slapi_pblock_get( pb, SLAPI_RESCONTROLS, (void **)&slapiControls );
188 nSlapiControls = slapi_over_count_controls( slapiControls );
190 if ( nSlapiControls == 0 ) {
195 nResControls = slapi_over_count_controls( rs->sr_ctrls );
197 /* XXX this is a bit tricky, rs->sr_ctrls may have been allocated on stack */
198 mergedControls = (LDAPControl **)op->o_tmpalloc( ( nResControls + nSlapiControls + 1 ) *
199 sizeof( LDAPControl *), op->o_tmpmemctx );
200 if ( mergedControls == NULL ) {
201 return LDAP_NO_MEMORY;
204 if ( rs->sr_ctrls != NULL ) {
205 for ( i = 0; i < nResControls; i++ )
206 mergedControls[i] = rs->sr_ctrls[i];
208 if ( slapiControls != NULL ) {
209 for ( i = 0; i < nSlapiControls; i++ )
210 mergedControls[nResControls + i] = slapiControls[i];
212 mergedControls[nResControls + nSlapiControls] = NULL;
214 if ( slapiControls != NULL ) {
215 slapi_ch_free( (void **)&slapiControls );
216 slapi_pblock_set( pb, SLAPI_RESCONTROLS, NULL ); /* don't free */
219 rs->sr_ctrls = mergedControls;
225 * Call pre- and post-result plugins
228 slapi_over_result( Operation *op, SlapReply *rs, int type )
231 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
233 assert( rs->sr_type == REP_RESULT );
235 slapi_pblock_set( pb, SLAPI_RESULT_CODE, (void *)rs->sr_err );
236 slapi_pblock_set( pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text );
237 slapi_pblock_set( pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched );
239 rc = slapi_int_call_plugins( op->o_bd, type, pb );
241 slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rs->sr_err );
242 slapi_pblock_get( pb, SLAPI_RESULT_TEXT, (void **)&rs->sr_text );
243 slapi_pblock_get( pb, SLAPI_RESULT_MATCHED, (void **)&rs->sr_matched );
245 if ( type == SLAPI_PLUGIN_PRE_RESULT_FN ) {
246 rc = slapi_over_merge_controls( op, rs );
249 return SLAP_CB_CONTINUE;
253 slapi_op_add_init( Operation *op, SlapReply *rs )
255 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
257 slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)op->ora_e );
263 slapi_op_bind_preop_init( Operation *op, SlapReply *rs )
265 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
267 slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)op->o_req_dn.bv_val );
268 slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)op->orb_method );
269 slapi_pblock_set( pb, SLAPI_BIND_CREDENTIALS, (void *)&op->orb_cred );
270 slapi_pblock_set( pb, SLAPI_CONN_DN, NULL );
276 slapi_op_bind_postop_init( Operation *op, SlapReply *rs )
278 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
281 if ( rs->sr_err == LDAP_SUCCESS ) {
282 /* fix for ITS#2971 */
283 slapi_pblock_set( pb, SLAPI_CONN_DN, op->o_conn->c_authz.sai_dn.bv_val );
290 slapi_op_bind_callback( Operation *op, SlapReply *rs )
292 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
296 case SLAPI_BIND_SUCCESS:
297 /* Continue with backend processing */
299 case SLAPI_BIND_FAIL:
300 /* Failure, frontend (that's us) sends result */
301 rs->sr_err = LDAP_INVALID_CREDENTIALS;
302 send_ldap_result( op, rs );
305 case SLAPI_BIND_ANONYMOUS: /* undocumented */
306 default: /* plugin sent result or no plugins called */
307 if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rs->sr_err ) != 0 ) {
308 rs->sr_err = LDAP_OTHER;
311 BER_BVZERO( &op->orb_edn );
313 if ( rs->sr_err == LDAP_SUCCESS ) {
314 slapi_pblock_get( pb, SLAPI_CONN_DN, (void *)&op->orb_edn.bv_val );
315 if ( BER_BVISNULL( &op->orb_edn ) ) {
317 /* No plugins were called; continue processing */
321 op->orb_edn.bv_len = strlen( op->orb_edn.bv_val );
323 rs->sr_err = dnPrettyNormal( NULL, &op->orb_edn,
324 &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx );
326 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
327 ber_dupbv(&op->o_conn->c_dn, &op->o_req_dn);
328 ber_dupbv(&op->o_conn->c_ndn, &op->o_req_ndn);
329 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
330 BER_BVZERO( &op->o_req_dn );
331 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
332 BER_BVZERO( &op->o_req_ndn );
333 if ( !BER_BVISEMPTY( &op->o_conn->c_dn ) ) {
334 ber_len_t max = sockbuf_max_incoming_auth;
335 ber_sockbuf_ctrl( op->o_conn->c_sb,
336 LBER_SB_OPT_SET_MAX_INCOMING, &max );
339 /* log authorization identity */
340 Statslog( LDAP_DEBUG_STATS,
341 "%s BIND dn=\"%s\" mech=%s (SLAPI) ssf=0\n",
343 BER_BVISNULL( &op->o_conn->c_dn )
344 ? "<empty>" : op->o_conn->c_dn.bv_val,
345 op->orb_tmp_mech.bv_val, 0, 0 );
347 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
357 slapi_op_compare_init( Operation *op, SlapReply *rs )
359 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
361 slapi_pblock_set( pb, SLAPI_COMPARE_TYPE, (void *)op->orc_ava->aa_desc->ad_cname.bv_val );
362 slapi_pblock_set( pb, SLAPI_COMPARE_VALUE, (void *)&op->orc_ava->aa_value );
368 slapi_op_modify_init( Operation *op, SlapReply *rs )
370 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
371 LDAPMod **modv = NULL;
373 modv = slapi_int_modifications2ldapmods( &op->orm_modlist );
374 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv );
380 slapi_op_modify_callback( Operation *op, SlapReply *rs )
382 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
383 LDAPMod **modv = NULL;
385 /* check preoperation result code */
386 if ( rs->sr_err < 0 ) {
387 slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rs->sr_err );
392 * NB: it is valid for the plugin to return no modifications
393 * (for example, a plugin might store some attributes elsewhere
394 * and remove them from the modification list; if only those
395 * attribute types were included in the modification request,
396 * then slapi_int_ldapmods2modifications() above will return
399 * However, the post-operation plugin should still be
403 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
404 op->orm_modlist = slapi_int_ldapmods2modifications( modv );
410 slapi_op_modify_cleanup( Operation *op, SlapReply *rs )
412 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
413 LDAPMod **modv = NULL;
415 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
418 slapi_int_free_ldapmods( modv );
424 slapi_op_modrdn_init( Operation *op, SlapReply *rs )
426 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
428 slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)op->orr_newrdn.bv_val );
429 slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR, (void *)op->orr_newSup->bv_val );
430 slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)op->orr_deleteoldrdn );
436 slapi_op_search_init( Operation *op, SlapReply *rs )
438 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
441 attrs = anlist2charray_x( op->ors_attrs, 0, op->o_tmpmemctx );
443 slapi_pblock_set( pb, SLAPI_SEARCH_SCOPE, (void *)op->ors_scope );
444 slapi_pblock_set( pb, SLAPI_SEARCH_DEREF, (void *)op->ors_deref );
445 slapi_pblock_set( pb, SLAPI_SEARCH_SIZELIMIT, (void *)op->ors_slimit );
446 slapi_pblock_set( pb, SLAPI_SEARCH_TIMELIMIT, (void *)op->ors_tlimit );
447 slapi_pblock_set( pb, SLAPI_SEARCH_FILTER, (void *)op->ors_filter );
448 slapi_pblock_set( pb, SLAPI_SEARCH_STRFILTER, (void *)op->ors_filterstr.bv_val );
449 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRS, (void *)attrs );
450 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRSONLY, (void *)op->ors_attrsonly );
456 slapi_op_search_callback( Operation *op, SlapReply *rs )
458 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
460 /* check preoperation result code */
461 if ( rs->sr_err < 0 ) {
462 slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rs->sr_err );
466 if ( slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN, pb ) != 0 ) {
471 * The plugin can set the SLAPI_SEARCH_FILTER.
472 * SLAPI_SEARCH_STRFILER is not normative.
474 slapi_pblock_get( pb, SLAPI_SEARCH_FILTER, (void *)&op->ors_filter );
475 op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
476 filter2bv_x( op, op->ors_filter, &op->ors_filterstr );
478 slapi_pblock_get( pb, SLAPI_SEARCH_TARGET, (void **)&op->o_req_dn.bv_val );
479 op->o_req_dn.bv_len = strlen( op->o_req_dn.bv_val );
481 if( !BER_BVISNULL( &op->o_req_ndn ) ) {
482 slap_sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx );
484 rs->sr_err = dnNormalize( 0, NULL, NULL, &op->o_req_dn, &op->o_req_ndn,
486 if ( rs->sr_err != LDAP_SUCCESS ) {
487 send_ldap_result( op, rs );
491 slapi_pblock_get( pb, SLAPI_SEARCH_SCOPE, (void **)&op->ors_scope );
492 slapi_pblock_get( pb, SLAPI_SEARCH_DEREF, (void **)&op->ors_deref );
498 slapi_op_search_cleanup( Operation *op, SlapReply *rs )
500 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
503 slapi_pblock_get( pb, SLAPI_SEARCH_ATTRS, (void *)&attrs );
506 op->o_tmpfree( attrs, op->o_tmpmemctx );
511 struct slapi_op_info {
512 int soi_preop; /* preoperation plugin parameter */
513 int soi_postop; /* postoperation plugin parameter */
514 slap_response *soi_preop_init; /* preoperation pblock init function */
515 slap_response *soi_callback; /* preoperation result handler */
516 slap_response *soi_postop_init; /* postoperation pblock init function */
517 slap_response *soi_cleanup; /* cleanup function */
518 } slapi_op_dispatch_table[] = {
520 SLAPI_PLUGIN_PRE_BIND_FN,
521 SLAPI_PLUGIN_POST_BIND_FN,
522 slapi_op_bind_preop_init,
523 slapi_op_bind_callback,
524 slapi_op_bind_postop_init,
528 SLAPI_PLUGIN_PRE_UNBIND_FN, /* UNBIND */
529 SLAPI_PLUGIN_POST_UNBIND_FN,
536 SLAPI_PLUGIN_PRE_SEARCH_FN,
537 SLAPI_PLUGIN_POST_SEARCH_FN,
538 slapi_op_search_init,
539 slapi_op_search_callback,
541 slapi_op_search_cleanup
544 SLAPI_PLUGIN_PRE_COMPARE_FN,
545 SLAPI_PLUGIN_POST_COMPARE_FN,
546 slapi_op_compare_init,
552 SLAPI_PLUGIN_PRE_MODIFY_FN,
553 SLAPI_PLUGIN_POST_MODIFY_FN,
554 slapi_op_modify_init,
555 slapi_op_modify_callback,
557 slapi_op_modify_cleanup
560 SLAPI_PLUGIN_PRE_MODRDN_FN,
561 SLAPI_PLUGIN_POST_MODRDN_FN,
562 slapi_op_modrdn_init,
568 SLAPI_PLUGIN_PRE_ADD_FN,
569 SLAPI_PLUGIN_POST_ADD_FN,
576 SLAPI_PLUGIN_PRE_DELETE_FN,
577 SLAPI_PLUGIN_POST_DELETE_FN,
584 SLAPI_PLUGIN_PRE_ABANDON_FN,
585 SLAPI_PLUGIN_POST_ABANDON_FN,
602 slapi_tag2op( ber_tag_t tag )
613 case LDAP_REQ_DELETE:
616 case LDAP_REQ_MODRDN:
619 case LDAP_REQ_MODIFY:
622 case LDAP_REQ_COMPARE:
625 case LDAP_REQ_SEARCH:
628 case LDAP_REQ_UNBIND:
640 slapi_over_response( Operation *op, SlapReply *rs )
644 switch ( rs->sr_type ) {
646 rc = slapi_over_result( op, rs, SLAPI_PLUGIN_PRE_RESULT_FN );
649 rc = slapi_over_search( op, rs, SLAPI_PLUGIN_PRE_ENTRY_FN );
652 rc = slapi_over_search( op, rs, SLAPI_PLUGIN_PRE_REFERRAL_FN );
655 rc = SLAP_CB_CONTINUE;
663 slapi_over_cleanup( Operation *op, SlapReply *rs )
667 switch ( rs->sr_type ) {
669 rc = slapi_over_result( op, rs, SLAPI_PLUGIN_POST_RESULT_FN );
672 rc = slapi_over_search( op, rs, SLAPI_PLUGIN_POST_ENTRY_FN );
675 rc = slapi_over_search( op, rs, SLAPI_PLUGIN_POST_REFERRAL_FN );
678 rc = SLAP_CB_CONTINUE;
686 slapi_op_func( Operation *op, SlapReply *rs )
689 slap_operation_t which;
690 struct slapi_op_info *opinfo;
697 * We check for op->o_extensions to verify that we are not
698 * processing a SLAPI internal operation. XXX
700 if ( op->o_hdr->oh_extensions == NULL ) {
701 return SLAP_CB_CONTINUE;
705 * Find the SLAPI operation information for this LDAP
706 * operation; this will contain the preop and postop
707 * plugin types, as well as optional callbacks for
708 * setting up the SLAPI environment.
710 which = slapi_tag2op( op->o_tag );
711 if ( which >= op_last ) {
712 /* invalid operation, but let someone else deal with it */
713 return SLAP_CB_CONTINUE;
716 opinfo = &slapi_op_dispatch_table[which];
717 if ( opinfo == NULL || opinfo->soi_preop == 0 ) {
718 /* no SLAPI plugin types for this operation */
719 return SLAP_CB_CONTINUE;
722 pb = slapi_over_pblock_new( op );
724 /* XXX we need to fill this out for MMR support */
725 slapi_pblock_set( pb, SLAPI_TARGET_ADDRESS, NULL );
726 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, NULL );
727 slapi_pblock_set( pb, SLAPI_TARGET_DN, (void *)op->o_req_dn.bv_val );
729 cb.sc_response = slapi_over_response; /* call pre-entry/result plugins */
730 cb.sc_cleanup = slapi_over_cleanup; /* call post-entry/result plugins */
732 cb.sc_next = op->o_callback;
733 op->o_callback = &cb;
736 * Call preoperation plugins
738 if ( opinfo->soi_preop_init != NULL ) {
739 rs->sr_err = (opinfo->soi_preop_init)( op, rs );
740 if ( rs->sr_err != LDAP_SUCCESS )
744 rs->sr_err = slapi_int_call_plugins( op->o_bd, opinfo->soi_preop, pb );
747 * soi_callback is responsible for examining the result code
748 * of the preoperation plugin and determining whether to
749 * abort. This is needed because of special SLAPI behaviour
750 * with bind preoperation plugins.
752 * The soi_callback function is also used to reset any values
753 * returned from the preoperation plugin before calling the
754 * backend (for the success case).
756 if ( opinfo->soi_callback == NULL ) {
757 /* default behaviour is preop plugin can abort operation */
758 if ( rs->sr_err < 0 ) {
759 slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rs->sr_err );
763 rc = (opinfo->soi_callback)( op, rs );
769 * Call actual backend (or next overlay in stack). We need to
770 * do this rather than returning SLAP_CB_CONTINUE and calling
771 * postoperation plugins in a response handler to match the
772 * behaviour of SLAPI in OpenLDAP 2.2, where postoperation
773 * plugins are called after the backend has completely
774 * finished processing the operation.
776 on = (slap_overinst *)op->o_bd->bd_info;
779 rs->sr_err = overlay_op_walk( op, rs, which, oi, on->on_next );
782 * Call postoperation plugins
784 slapi_pblock_set( pb, SLAPI_RESULT_CODE, (void *)rs->sr_err );
786 if ( opinfo->soi_postop_init != NULL ) {
787 (opinfo->soi_postop_init)( op, rs );
790 slapi_int_call_plugins( op->o_bd, opinfo->soi_postop, pb );
793 if ( opinfo->soi_cleanup != NULL ) {
794 (opinfo->soi_cleanup)( op, rs );
797 op->o_callback = cb.sc_next;
798 slapi_pblock_destroy(pb);
804 slapi_over_extended( Operation *op, SlapReply *rs )
810 struct berval reqdata = BER_BVNULL;
812 slapi_int_get_extop_plugin( &op->ore_reqoid, &callback );
813 if ( callback == NULL ) {
814 return SLAP_CB_CONTINUE;
817 pb = slapi_over_pblock_new( op );
819 if ( op->ore_reqdata != NULL ) {
820 reqdata = *op->ore_reqdata;
823 slapi_pblock_set( pb, SLAPI_EXT_OP_REQ_OID, (void *)op->ore_reqoid.bv_val);
824 slapi_pblock_set( pb, SLAPI_EXT_OP_REQ_VALUE, (void *)&reqdata);
826 rc = (*callback)( pb );
827 if ( rc == SLAPI_PLUGIN_EXTENDED_SENT_RESULT ) {
828 slapi_pblock_destroy( pb );
830 } else if ( rc == SLAPI_PLUGIN_EXTENDED_NOT_HANDLED ) {
831 slapi_pblock_destroy( pb );
832 return SLAP_CB_CONTINUE;
835 slapi_pblock_get( pb, SLAPI_EXT_OP_RET_OID, (void **)&rs->sr_rspoid );
836 slapi_pblock_get( pb, SLAPI_EXT_OP_RET_VALUE, (void **)&rs->sr_rspdata );
839 send_ldap_extended( op, rs );
841 if ( rs->sr_rspoid != NULL )
842 slapi_ch_free_string( (char **)&rs->sr_rspoid );
844 if ( rs->sr_rspdata != NULL )
845 ber_bvfree( rs->sr_rspdata );
847 slapi_pblock_destroy( pb );
853 slapi_over_access_allowed(
856 AttributeDescription *desc,
858 slap_access_t access,
859 AccessControlState *state,
866 pb = slapi_over_pblock_new( op );
868 cb.sc_response = NULL;
869 cb.sc_cleanup = NULL;
871 cb.sc_next = op->o_callback;
872 op->o_callback = &cb;
874 rc = slapi_int_access_allowed( op, e, desc, val, access, state );
876 rc = SLAP_CB_CONTINUE;
879 op->o_callback = cb.sc_next;
880 slapi_pblock_destroy( pb );
886 slapi_over_acl_group(
889 struct berval *gr_ndn,
890 struct berval *op_ndn,
891 ObjectClass *group_oc,
892 AttributeDescription *group_at )
897 BackendDB *be = op->o_bd;
900 op->o_bd = select_backend( gr_ndn, 0, 0 );
902 for ( g = op->o_groups; g; g = g->ga_next ) {
903 if ( g->ga_be != op->o_bd || g->ga_oc != group_oc ||
904 g->ga_at != group_at || g->ga_len != gr_ndn->bv_len )
908 if ( strcmp( g->ga_ndn, gr_ndn->bv_val ) == 0 ) {
917 if ( target != NULL && dn_match( &target->e_nname, gr_ndn ) ) {
921 rc = be_entry_get_rw( op, gr_ndn, group_oc, group_at, 0, &e );
924 pb = slapi_over_pblock_new( op );
926 slapi_pblock_set( pb, SLAPI_X_GROUP_ENTRY, (void *)e );
927 slapi_pblock_set( pb, SLAPI_X_GROUP_OPERATION_DN, (void *)op_ndn->bv_val );
928 slapi_pblock_set( pb, SLAPI_X_GROUP_ATTRIBUTE, (void *)group_at->ad_cname.bv_val );
929 slapi_pblock_set( pb, SLAPI_X_GROUP_TARGET_ENTRY, (void *)target );
931 rc = slapi_int_call_plugins( op->o_bd, SLAPI_X_PLUGIN_PRE_GROUP_FN, pb );
932 if ( rc >= 0 ) /* 1 means no plugins called */
933 rc = SLAP_CB_CONTINUE;
935 slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rc );
937 slapi_pblock_destroy( pb );
940 be_entry_release_r( op, e );
943 rc = LDAP_NO_SUCH_OBJECT; /* return SLAP_CB_CONTINUE for correctness? */
946 if ( op->o_tag != LDAP_REQ_BIND && !op->o_do_not_cache &&
947 rc != SLAP_CB_CONTINUE ) {
948 g = op->o_tmpalloc( sizeof( GroupAssertion ) + gr_ndn->bv_len,
954 g->ga_len = gr_ndn->bv_len;
955 strcpy( g->ga_ndn, gr_ndn->bv_val );
956 g->ga_next = op->o_groups;
960 * XXX don't call POST_GROUP_FN, I have no idea what the point of
961 * that plugin function was anyway
969 slapi_int_overlay_init()
971 memset( &slapi, 0, sizeof(slapi) );
973 slapi.on_bi.bi_type = SLAPI_OVERLAY_NAME;
975 slapi.on_bi.bi_op_bind = slapi_op_func;
976 slapi.on_bi.bi_op_unbind = slapi_op_func;
977 slapi.on_bi.bi_op_search = slapi_op_func;
978 slapi.on_bi.bi_op_compare = slapi_op_func;
979 slapi.on_bi.bi_op_modify = slapi_op_func;
980 slapi.on_bi.bi_op_modrdn = slapi_op_func;
981 slapi.on_bi.bi_op_add = slapi_op_func;
982 slapi.on_bi.bi_op_delete = slapi_op_func;
983 slapi.on_bi.bi_op_abandon = slapi_op_func;
984 slapi.on_bi.bi_op_cancel = slapi_op_func;
986 slapi.on_bi.bi_extended = slapi_over_extended;
987 slapi.on_bi.bi_access_allowed = slapi_over_access_allowed;
988 slapi.on_bi.bi_operational = slapi_over_aux_operational;
989 slapi.on_bi.bi_acl_group = slapi_over_acl_group;
991 return overlay_register( &slapi );
994 #endif /* LDAP_SLAPI */