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_compute_output(
37 computed_attr_context *c,
38 Slapi_Attr *attribute,
44 AttributeDescription *desc;
45 Operation *op = c->cac_op;
46 SlapReply *rs = (SlapReply *)c->cac_private;
48 if ( c == NULL || attribute == NULL || entry == NULL ) {
52 assert( rs->sr_entry == entry );
54 desc = attribute->a_desc;
56 if ( rs->sr_attrs == NULL ) {
57 /* All attrs request, skip operational attributes */
58 if ( is_at_operational( desc->ad_type ) ) {
62 /* Specific attributes requested */
63 if ( is_at_operational( desc->ad_type ) ) {
64 if ( !SLAP_OPATTRS( rs->sr_attr_flags ) &&
65 !ad_inlist( desc, rs->sr_attrs ) ) {
69 if ( !SLAP_USERATTRS( rs->sr_attr_flags ) &&
70 !ad_inlist( desc, rs->sr_attrs ) ) {
76 if ( !access_allowed( op, entry, desc, NULL, ACL_READ, c->cac_acl_state) ) {
77 slapi_log_error( SLAPI_LOG_ACL, "slapi_over_compute_output",
78 "acl: access to attribute %s not allowed\n",
79 desc->ad_cname.bv_val );
83 /* XXX perhaps we should check for existing attributes and merge */
84 for ( a = &rs->sr_operational_attrs; *a != NULL; a = &(*a)->a_next )
87 *a = attr_dup( attribute );
93 slapi_over_aux_operational( Operation *op, SlapReply *rs )
95 /* Support for computed attribute plugins */
96 computed_attr_context ctx;
98 AccessControlState acl_state = ACL_STATE_INIT;
100 ctx.cac_pb = SLAPI_OPERATION_PBLOCK( op );
102 ctx.cac_private = rs;
103 ctx.cac_acl_state = &acl_state;
105 if ( rs->sr_entry != NULL ) {
107 * For each client requested attribute, call the plugins.
109 if ( rs->sr_attrs != NULL ) {
110 for ( anp = rs->sr_attrs; anp->an_name.bv_val != NULL; anp++ ) {
111 if ( compute_evaluator( &ctx, anp->an_name.bv_val,
112 rs->sr_entry, slapi_over_compute_output ) == 1 ) {
118 * Technically we shouldn't be returning operational attributes
119 * when the user requested only user attributes. We'll let the
120 * plugin decide whether to be naughty or not.
122 compute_evaluator( &ctx, "*", rs->sr_entry, slapi_over_compute_output );
126 return SLAP_CB_CONTINUE;
130 slapi_over_search( Operation *op, SlapReply *rs, int type )
135 assert( rs->sr_type == REP_SEARCH || rs->sr_type == REP_SEARCHREF );
137 pb = slapi_pblock_new(); /* create a new pblock to not trample on
141 slapi_int_pblock_set_operation( pb, op );
142 slapi_pblock_set( pb, SLAPI_RESCONTROLS, (void *)rs->sr_ctrls );
143 slapi_pblock_set( pb, SLAPI_SEARCH_RESULT_ENTRY, (void *)rs->sr_entry );
145 rc = slapi_int_call_plugins( op->o_bd, type, pb );
146 if ( rc >= 0 ) /* 1 means no plugins called */
147 rc = SLAP_CB_CONTINUE;
149 rc = LDAP_SUCCESS; /* confusing: don't abort, but don't send */
151 slapi_pblock_set( pb, SLAPI_RESCONTROLS, NULL ); /* don't free */
152 slapi_pblock_destroy(pb);
158 slapi_over_count_controls( LDAPControl **controls )
162 if ( controls == NULL )
165 for ( i = 0; controls[i] != NULL; i++ )
172 slapi_over_merge_controls( Operation *op, SlapReply *rs, Slapi_PBlock *pb)
174 LDAPControl **slapiControls = NULL, **mergedControls;
175 int nSlapiControls = 0;
176 int nResControls = 0;
179 nResControls = slapi_over_count_controls( rs->sr_ctrls );
181 slapi_pblock_get( pb, SLAPI_RESCONTROLS, (void **)&slapiControls );
182 nSlapiControls = slapi_over_count_controls( slapiControls );
184 if ( nResControls + nSlapiControls == 0 ) {
189 /* XXX this is a bit tricky, rs->sr_ctrls may have been allocated on stack */
190 mergedControls = (LDAPControl **)op->o_tmpalloc( ( nResControls + nSlapiControls + 1 ) *
191 sizeof( LDAPControl *), op->o_tmpmemctx );
192 if ( mergedControls == NULL ) {
193 return LDAP_NO_MEMORY;
196 if ( rs->sr_ctrls != NULL ) {
197 for ( i = 0; i < nResControls; i++ )
198 mergedControls[i] = rs->sr_ctrls[i];
200 if ( slapiControls != NULL ) {
201 for ( i = 0; i < nSlapiControls; i++ )
202 mergedControls[nResControls + i] = slapiControls[i];
204 mergedControls[nResControls + nSlapiControls] = NULL;
206 if ( slapiControls != NULL ) {
207 slapi_ch_free( (void **)&slapiControls );
208 slapi_pblock_set( pb, SLAPI_RESCONTROLS, NULL ); /* don't free */
211 rs->sr_ctrls = mergedControls;
217 * Call pre- and post-result plugins
220 slapi_over_result( Operation *op, SlapReply *rs, int type )
223 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
225 assert( rs->sr_type == REP_RESULT );
227 slapi_pblock_set( pb, SLAPI_RESULT_CODE, (void *)rs->sr_err );
228 slapi_pblock_set( pb, SLAPI_RESULT_TEXT, (void *)rs->sr_text );
229 slapi_pblock_set( pb, SLAPI_RESULT_MATCHED, (void *)rs->sr_matched );
231 rc = slapi_int_call_plugins( op->o_bd, type, pb );
233 slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rs->sr_err );
234 slapi_pblock_get( pb, SLAPI_RESULT_TEXT, (void **)&rs->sr_text );
235 slapi_pblock_get( pb, SLAPI_RESULT_MATCHED, (void **)&rs->sr_matched );
237 if ( type == SLAPI_PLUGIN_PRE_RESULT_FN ) {
238 rc = slapi_over_merge_controls( op, rs, pb );
241 return SLAP_CB_CONTINUE;
245 slapi_op_add_init( Operation *op, SlapReply *rs, Slapi_PBlock *pb )
247 slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)op->ora_e );
253 slapi_op_bind_preop_init( Operation *op, SlapReply *rs, Slapi_PBlock *pb )
255 slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)op->o_req_dn.bv_val );
256 slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)op->orb_method );
257 slapi_pblock_set( pb, SLAPI_BIND_CREDENTIALS, (void *)&op->orb_cred );
258 slapi_pblock_set( pb, SLAPI_CONN_DN, NULL );
264 slapi_op_bind_postop_init( Operation *op, SlapReply *rs, Slapi_PBlock *pb )
268 if ( rs->sr_err == LDAP_SUCCESS ) {
269 /* fix for ITS#2971 */
270 slapi_pblock_set( pb, SLAPI_CONN_DN, op->o_conn->c_authz.sai_dn.bv_val );
277 slapi_op_bind_callback( Operation *op, SlapReply *rs, Slapi_PBlock *pb )
282 case SLAPI_BIND_SUCCESS:
283 /* Continue with backend processing */
285 case SLAPI_BIND_FAIL:
286 /* Failure, frontend (that's us) sends result */
287 rs->sr_err = LDAP_INVALID_CREDENTIALS;
288 send_ldap_result( op, rs );
291 case SLAPI_BIND_ANONYMOUS: /* undocumented */
292 default: /* plugin sent result or no plugins called */
293 if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rs->sr_err ) != 0 ) {
294 rs->sr_err = LDAP_OTHER;
297 BER_BVZERO( &op->orb_edn );
299 if ( rs->sr_err == LDAP_SUCCESS ) {
300 slapi_pblock_get( pb, SLAPI_CONN_DN, (void *)&op->orb_edn.bv_val );
301 if ( BER_BVISNULL( &op->orb_edn ) ) {
303 /* No plugins were called; continue processing */
307 op->orb_edn.bv_len = strlen( op->orb_edn.bv_val );
309 rs->sr_err = dnPrettyNormal( NULL, &op->orb_edn,
310 &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx );
312 ldap_pvt_thread_mutex_lock( &op->o_conn->c_mutex );
313 ber_dupbv(&op->o_conn->c_dn, &op->o_req_dn);
314 ber_dupbv(&op->o_conn->c_ndn, &op->o_req_ndn);
315 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
316 BER_BVZERO( &op->o_req_dn );
317 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
318 BER_BVZERO( &op->o_req_ndn );
319 if ( !BER_BVISEMPTY( &op->o_conn->c_dn ) ) {
320 ber_len_t max = sockbuf_max_incoming_auth;
321 ber_sockbuf_ctrl( op->o_conn->c_sb,
322 LBER_SB_OPT_SET_MAX_INCOMING, &max );
325 /* log authorization identity */
326 Statslog( LDAP_DEBUG_STATS,
327 "%s BIND dn=\"%s\" mech=%s (SLAPI) ssf=0\n",
329 BER_BVISNULL( &op->o_conn->c_dn )
330 ? "<empty>" : op->o_conn->c_dn.bv_val,
331 op->orb_tmp_mech.bv_val, 0, 0 );
333 ldap_pvt_thread_mutex_unlock( &op->o_conn->c_mutex );
343 slapi_op_compare_init( Operation *op, SlapReply *rs, Slapi_PBlock *pb )
345 slapi_pblock_set( pb, SLAPI_COMPARE_TYPE, (void *)op->orc_ava->aa_desc->ad_cname.bv_val );
346 slapi_pblock_set( pb, SLAPI_COMPARE_VALUE, (void *)&op->orc_ava->aa_value );
352 slapi_op_modify_init( Operation *op, SlapReply *rs, Slapi_PBlock *pb )
354 LDAPMod **modv = NULL;
356 modv = slapi_int_modifications2ldapmods( &op->orm_modlist );
357 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv );
363 slapi_op_modify_callback( Operation *op, SlapReply *rs, Slapi_PBlock *pb )
365 LDAPMod **modv = NULL;
367 /* check preoperation result code */
368 if ( rs->sr_err < 0 ) {
369 slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rs->sr_err );
374 * NB: it is valid for the plugin to return no modifications
375 * (for example, a plugin might store some attributes elsewhere
376 * and remove them from the modification list; if only those
377 * attribute types were included in the modification request,
378 * then slapi_int_ldapmods2modifications() above will return
381 * However, the post-operation plugin should still be
385 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
386 op->orm_modlist = slapi_int_ldapmods2modifications( modv );
392 slapi_op_modify_cleanup( Operation *op, SlapReply *rs, Slapi_PBlock *pb )
394 LDAPMod **modv = NULL;
396 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
399 slapi_int_free_ldapmods( modv );
405 slapi_op_modrdn_init( Operation *op, SlapReply *rs, Slapi_PBlock *pb )
407 slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)op->orr_newrdn.bv_val );
408 slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR, (void *)op->orr_newSup->bv_val );
409 slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)op->orr_deleteoldrdn );
415 slapi_op_search_init( Operation *op, SlapReply *rs, Slapi_PBlock *pb )
419 attrs = anlist2charray_x( op->ors_attrs, 0, op->o_tmpmemctx );
421 slapi_pblock_set( pb, SLAPI_SEARCH_SCOPE, (void *)op->ors_scope );
422 slapi_pblock_set( pb, SLAPI_SEARCH_DEREF, (void *)op->ors_deref );
423 slapi_pblock_set( pb, SLAPI_SEARCH_SIZELIMIT, (void *)op->ors_slimit );
424 slapi_pblock_set( pb, SLAPI_SEARCH_TIMELIMIT, (void *)op->ors_tlimit );
425 slapi_pblock_set( pb, SLAPI_SEARCH_FILTER, (void *)op->ors_filter );
426 slapi_pblock_set( pb, SLAPI_SEARCH_STRFILTER, (void *)op->ors_filterstr.bv_val );
427 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRS, (void *)attrs );
428 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRSONLY, (void *)op->ors_attrsonly );
434 slapi_op_search_callback( Operation *op, SlapReply *rs, Slapi_PBlock *pb )
436 /* check preoperation result code */
437 if ( rs->sr_err < 0 ) {
438 slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rs->sr_err );
442 if ( slapi_int_call_plugins( op->o_bd, SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN, pb ) != 0 ) {
447 * The plugin can set the SLAPI_SEARCH_FILTER.
448 * SLAPI_SEARCH_STRFILER is not normative.
450 slapi_pblock_get( pb, SLAPI_SEARCH_FILTER, (void *)&op->ors_filter );
451 op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
452 filter2bv_x( op, op->ors_filter, &op->ors_filterstr );
454 slapi_pblock_get( pb, SLAPI_SEARCH_TARGET, (void **)&op->o_req_dn.bv_val );
455 op->o_req_dn.bv_len = strlen( op->o_req_dn.bv_val );
457 if( !BER_BVISNULL( &op->o_req_ndn ) ) {
458 slap_sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx );
460 rs->sr_err = dnNormalize( 0, NULL, NULL, &op->o_req_dn, &op->o_req_ndn,
462 if ( rs->sr_err != LDAP_SUCCESS ) {
463 send_ldap_result( op, rs );
467 slapi_pblock_get( pb, SLAPI_SEARCH_SCOPE, (void **)&op->ors_scope );
468 slapi_pblock_get( pb, SLAPI_SEARCH_DEREF, (void **)&op->ors_deref );
474 slapi_op_search_cleanup( Operation *op, SlapReply *rs, Slapi_PBlock *pb )
478 slapi_pblock_get( pb, SLAPI_SEARCH_ATTRS, (void *)&attrs );
481 op->o_tmpfree( attrs, op->o_tmpmemctx );
486 typedef int (slapi_over_callback)( Operation *, SlapReply *rs, Slapi_PBlock * );
488 struct slapi_op_info {
489 int soi_preop; /* preoperation plugin parameter */
490 int soi_postop; /* postoperation plugin parameter */
491 slapi_over_callback *soi_preop_init; /* preoperation pblock init function */
492 slapi_over_callback *soi_callback; /* preoperation result handler */
493 slapi_over_callback *soi_postop_init; /* postoperation pblock init function */
494 slapi_over_callback *soi_cleanup; /* cleanup function */
495 } slapi_op_dispatch_table[] = {
497 SLAPI_PLUGIN_PRE_BIND_FN,
498 SLAPI_PLUGIN_POST_BIND_FN,
499 slapi_op_bind_preop_init,
500 slapi_op_bind_callback,
501 slapi_op_bind_postop_init,
505 SLAPI_PLUGIN_PRE_UNBIND_FN, /* UNBIND */
506 SLAPI_PLUGIN_POST_UNBIND_FN,
513 SLAPI_PLUGIN_PRE_SEARCH_FN,
514 SLAPI_PLUGIN_POST_SEARCH_FN,
515 slapi_op_search_init,
516 slapi_op_search_callback,
518 slapi_op_search_cleanup
521 SLAPI_PLUGIN_PRE_COMPARE_FN,
522 SLAPI_PLUGIN_POST_COMPARE_FN,
523 slapi_op_compare_init,
529 SLAPI_PLUGIN_PRE_MODIFY_FN,
530 SLAPI_PLUGIN_POST_MODIFY_FN,
531 slapi_op_modify_init,
532 slapi_op_modify_callback,
534 slapi_op_modify_cleanup
537 SLAPI_PLUGIN_PRE_MODRDN_FN,
538 SLAPI_PLUGIN_POST_MODRDN_FN,
539 slapi_op_modrdn_init,
545 SLAPI_PLUGIN_PRE_ADD_FN,
546 SLAPI_PLUGIN_POST_ADD_FN,
553 SLAPI_PLUGIN_PRE_DELETE_FN,
554 SLAPI_PLUGIN_POST_DELETE_FN,
561 SLAPI_PLUGIN_PRE_ABANDON_FN,
562 SLAPI_PLUGIN_POST_ABANDON_FN,
579 slapi_tag2op( ber_tag_t tag )
590 case LDAP_REQ_DELETE:
593 case LDAP_REQ_MODRDN:
596 case LDAP_REQ_MODIFY:
599 case LDAP_REQ_COMPARE:
602 case LDAP_REQ_SEARCH:
605 case LDAP_REQ_UNBIND:
617 slapi_over_response( Operation *op, SlapReply *rs )
621 switch ( rs->sr_type ) {
623 rc = slapi_over_result( op, rs, SLAPI_PLUGIN_PRE_RESULT_FN );
626 rc = slapi_over_search( op, rs, SLAPI_PLUGIN_PRE_ENTRY_FN );
629 rc = slapi_over_search( op, rs, SLAPI_PLUGIN_PRE_REFERRAL_FN );
632 rc = SLAP_CB_CONTINUE;
640 slapi_over_cleanup( Operation *op, SlapReply *rs )
644 switch ( rs->sr_type ) {
646 rc = slapi_over_result( op, rs, SLAPI_PLUGIN_POST_RESULT_FN );
649 rc = slapi_over_search( op, rs, SLAPI_PLUGIN_POST_ENTRY_FN );
652 rc = slapi_over_search( op, rs, SLAPI_PLUGIN_POST_REFERRAL_FN );
655 rc = SLAP_CB_CONTINUE;
663 slapi_op_func( Operation *op, SlapReply *rs )
666 slap_operation_t which;
667 struct slapi_op_info *opinfo;
673 pb = SLAPI_OPERATION_PBLOCK( op );
676 * We check for op->o_extensions to verify that we are not
677 * processing a SLAPI internal operation. XXX
679 if ( pb == NULL || op->o_hdr->oh_extensions == NULL ) {
680 return SLAP_CB_CONTINUE;
684 * Find the SLAPI operation information for this LDAP
685 * operation; this will contain the preop and postop
686 * plugin types, as well as optional callbacks for
687 * setting up the SLAPI environment.
689 which = slapi_tag2op( op->o_tag );
690 if ( which >= op_last ) {
691 /* invalid operation, but let someone else deal with it */
692 return SLAP_CB_CONTINUE;
695 opinfo = &slapi_op_dispatch_table[which];
696 if ( opinfo == NULL || opinfo->soi_preop == 0 ) {
697 /* no SLAPI plugin types for this operation */
698 return SLAP_CB_CONTINUE;
701 slapi_int_pblock_set_operation( pb, op );
703 cb.sc_response = slapi_over_response; /* call pre-entry/result plugins */
704 cb.sc_cleanup = slapi_over_cleanup; /* call post-entry/result plugins */
705 cb.sc_private = opinfo;
706 cb.sc_next = op->o_callback;
707 op->o_callback = &cb;
710 * Call preoperation plugins
712 if ( opinfo->soi_preop_init != NULL ) {
713 rs->sr_err = (opinfo->soi_preop_init)( op, rs, pb );
714 if ( rs->sr_err != LDAP_SUCCESS )
718 rs->sr_err = slapi_int_call_plugins( op->o_bd, opinfo->soi_preop, pb );
721 * soi_callback is responsible for examining the result code
722 * of the preoperation plugin and determining whether to
723 * abort. This is needed because of special SLAPI behaviour
724 * with bind preoperation plugins.
726 * The soi_callback function is also used to reset any values
727 * returned from the preoperation plugin before calling the
728 * backend (for the success case).
730 if ( opinfo->soi_callback == NULL ) {
731 /* default behaviour is preop plugin can abort operation */
732 if ( rs->sr_err < 0 ) {
733 slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rs->sr_err );
737 rc = (opinfo->soi_callback)( op, rs, pb );
743 * Call actual backend (or next overlay in stack). We need to
744 * do this rather than returning SLAP_CB_CONTINUE and calling
745 * postoperation plugins in a response handler to match the
746 * behaviour of SLAPI in OpenLDAP 2.2, where postoperation
747 * plugins are called after the backend has completely
748 * finished processing the operation.
750 on = (slap_overinst *)op->o_bd->bd_info;
753 rs->sr_err = overlay_op_walk( op, rs, which, oi, on->on_next );
756 * Call postoperation plugins
758 slapi_pblock_set( pb, SLAPI_RESULT_CODE, (void *)rs->sr_err );
760 if ( opinfo->soi_postop_init != NULL ) {
761 (opinfo->soi_postop_init)( op, rs, pb );
764 slapi_int_call_plugins( op->o_bd, opinfo->soi_postop, pb );
767 if ( opinfo->soi_cleanup != NULL ) {
768 (opinfo->soi_cleanup)( op, rs, pb );
771 op->o_callback = cb.sc_next;
777 slapi_over_extended( Operation *op, SlapReply *rs )
783 struct berval reqdata = BER_BVNULL;
785 pb = SLAPI_OPERATION_PBLOCK( op );
787 return SLAP_CB_CONTINUE;
790 slapi_int_get_extop_plugin( &op->ore_reqoid, &callback );
791 if ( callback == NULL ) {
792 return SLAP_CB_CONTINUE;
795 slapi_int_pblock_set_operation( pb, op );
797 if ( op->ore_reqdata != NULL ) {
798 reqdata = *op->ore_reqdata;
801 slapi_pblock_set( pb, SLAPI_EXT_OP_REQ_OID, (void *)op->ore_reqoid.bv_val);
802 slapi_pblock_set( pb, SLAPI_EXT_OP_REQ_VALUE, (void *)&reqdata);
804 rc = (*callback)( pb );
805 if ( rc == SLAPI_PLUGIN_EXTENDED_SENT_RESULT ) {
807 } else if ( rc == SLAPI_PLUGIN_EXTENDED_NOT_HANDLED ) {
808 return SLAP_CB_CONTINUE;
811 slapi_pblock_get( pb, SLAPI_EXT_OP_RET_OID, (void **)&rs->sr_rspoid );
812 slapi_pblock_get( pb, SLAPI_EXT_OP_RET_VALUE, (void **)&rs->sr_rspdata );
815 send_ldap_extended( op, rs );
817 if ( rs->sr_rspoid != NULL )
818 slapi_ch_free_string( (char **)&rs->sr_rspoid );
820 if ( rs->sr_rspdata != NULL )
821 ber_bvfree( rs->sr_rspdata );
827 slapi_over_access_allowed(
830 AttributeDescription *desc,
832 slap_access_t access,
833 AccessControlState *state,
838 rc = slapi_int_access_allowed( op, e, desc, val, access, state );
840 rc = SLAP_CB_CONTINUE;
847 slapi_over_acl_group(
850 struct berval *gr_ndn,
851 struct berval *op_ndn,
852 ObjectClass *group_oc,
853 AttributeDescription *group_at )
857 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
858 BackendDB *be = NULL;
859 BackendDB *be_orig = op->o_bd;
862 return SLAP_CB_CONTINUE;
865 if ( target != NULL && dn_match( &target->e_nname, gr_ndn ) ) {
869 be = select_backend( gr_ndn, 0, 0 );
871 rc = LDAP_NO_SUCH_OBJECT;
874 rc = be_entry_get_rw( op, gr_ndn, group_oc, group_at, 0, &e );
880 return SLAP_CB_CONTINUE;
883 slapi_pblock_set( pb, SLAPI_X_GROUP_ENTRY, (void *)e );
884 slapi_pblock_set( pb, SLAPI_X_GROUP_OPERATION_DN, (void *)op_ndn->bv_val );
885 slapi_pblock_set( pb, SLAPI_X_GROUP_ATTRIBUTE, (void *)group_at->ad_cname.bv_val );
886 slapi_pblock_set( pb, SLAPI_X_GROUP_TARGET_ENTRY, (void *)target );
888 rc = slapi_int_call_plugins( op->o_bd, SLAPI_X_PLUGIN_PRE_GROUP_FN, pb );
890 rc = SLAP_CB_CONTINUE;
892 slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void **)&rc );
894 slapi_pblock_set( pb, SLAPI_X_GROUP_ENTRY, NULL );
895 slapi_pblock_set( pb, SLAPI_X_GROUP_OPERATION_DN, NULL );
896 slapi_pblock_set( pb, SLAPI_X_GROUP_ATTRIBUTE, NULL );
897 slapi_pblock_set( pb, SLAPI_X_GROUP_TARGET_ENTRY, NULL );
901 be_entry_release_r( op, e );
906 * XXX don't call POST_GROUP_FN, I have no idea what the point of
907 * that plugin function was anyway
913 slapi_int_overlay_init()
915 memset( &slapi, 0, sizeof(slapi) );
917 slapi.on_bi.bi_type = SLAPI_OVERLAY_NAME;
919 slapi.on_bi.bi_op_bind = slapi_op_func;
920 slapi.on_bi.bi_op_unbind = slapi_op_func;
921 slapi.on_bi.bi_op_search = slapi_op_func;
922 slapi.on_bi.bi_op_compare = slapi_op_func;
923 slapi.on_bi.bi_op_modify = slapi_op_func;
924 slapi.on_bi.bi_op_modrdn = slapi_op_func;
925 slapi.on_bi.bi_op_add = slapi_op_func;
926 slapi.on_bi.bi_op_delete = slapi_op_func;
927 slapi.on_bi.bi_op_abandon = slapi_op_func;
928 slapi.on_bi.bi_op_cancel = slapi_op_func;
930 slapi.on_bi.bi_extended = slapi_over_extended;
931 slapi.on_bi.bi_access_allowed = slapi_over_access_allowed;
932 slapi.on_bi.bi_operational = slapi_over_aux_operational;
933 slapi.on_bi.bi_acl_group = slapi_over_acl_group;
935 return overlay_register( &slapi );
938 #endif /* LDAP_SLAPI */