2 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 * Copyright 2002-2005 The OpenLDAP Foundation.
5 * Portions Copyright 1997,2002-2003 IBM Corporation.
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 IBM Corporation for use in
18 * IBM products and subsequently ported to OpenLDAP Software by
19 * Steve Omrani. Additional significant contributors include:
25 #include <ac/string.h>
26 #include <ac/stdarg.h>
28 #include <ac/unistd.h>
36 static struct slap_listener slapi_listener = {
42 slapi_int_dup_controls( LDAPControl **controls )
47 if ( controls == NULL )
50 for ( i = 0; controls[i] != NULL; i++ )
53 c = (LDAPControl **) slapi_ch_calloc( i + 1, sizeof(LDAPControl *) );
55 for ( i = 0; controls[i] != NULL; i++ ) {
56 c[i] = slapi_dup_control( controls[i] );
67 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
68 plugin_result_callback prc = NULL;
69 void *callback_data = NULL;
70 LDAPControl **ctrls = NULL;
74 slapi_pblock_get( pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void **)&prc );
75 slapi_pblock_get( pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
77 /* we need to duplicate controls because they might go out of scope */
78 ctrls = slapi_int_dup_controls( rs->sr_ctrls );
79 slapi_pblock_set( pb, SLAPI_RESCONTROLS, ctrls );
82 (*prc)( rs->sr_err, callback_data );
89 slapi_int_search_entry(
93 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
94 plugin_search_entry_callback psec = NULL;
95 void *callback_data = NULL;
96 int rc = LDAP_SUCCESS;
100 slapi_pblock_get( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, (void **)&psec );
101 slapi_pblock_get( pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
103 if ( psec != NULL ) {
104 rc = (*psec)( rs->sr_entry, callback_data );
111 slapi_int_search_reference(
115 int i, rc = LDAP_SUCCESS;
116 plugin_referral_entry_callback prec = NULL;
117 void *callback_data = NULL;
118 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
120 assert( pb != NULL );
122 slapi_pblock_get( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, (void **)&prec );
123 slapi_pblock_get( pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
125 if ( prec != NULL ) {
126 for ( i = 0; rs->sr_ref[i].bv_val != NULL; i++ ) {
127 rc = (*prec)( rs->sr_ref[i].bv_val, callback_data );
128 if ( rc != LDAP_SUCCESS ) {
138 slapi_int_response( Slapi_Operation *op, SlapReply *rs )
142 switch ( rs->sr_type ) {
144 rc = slapi_int_result( op, rs );
147 rc = slapi_int_search_entry( op, rs );
150 rc = slapi_int_search_reference( op, rs );
157 assert( rc != SLAP_CB_CONTINUE ); /* never try to send a wire response */
163 slapi_int_get_ctrls( Slapi_PBlock *pb )
166 int rc = LDAP_SUCCESS;
168 if ( pb->pb_op->o_ctrls != NULL ) {
169 for ( c = pb->pb_op->o_ctrls; *c != NULL; c++ ) {
170 rc = slap_parse_ctrl( pb->pb_op, pb->pb_rs, *c, &pb->pb_rs->sr_text );
171 if ( rc != LDAP_SUCCESS )
180 slapi_int_connection_init_pb( Slapi_PBlock *pb, ber_tag_t tag )
184 ber_len_t max = sockbuf_max_incoming;
186 conn = (Connection *) slapi_ch_calloc( 1, sizeof(Connection) );
188 LDAP_STAILQ_INIT( &conn->c_pending_ops );
190 op = (Operation *) slapi_ch_calloc( 1, OPERATION_BUFFER_SIZE );
191 op->o_hdr = (Opheader *)(op + 1);
192 op->o_controls = (void **)(op->o_hdr + 1);
194 op->o_callback = (slap_callback *) slapi_ch_calloc( 1, sizeof(slap_callback) );
195 op->o_callback->sc_response = slapi_int_response;
196 op->o_callback->sc_cleanup = NULL;
197 op->o_callback->sc_private = pb;
198 op->o_callback->sc_next = NULL;
200 conn->c_pending_ops.stqh_first = op;
202 /* connection object authorization information */
203 conn->c_authtype = LDAP_AUTH_NONE;
204 BER_BVZERO( &conn->c_authmech );
205 BER_BVZERO( &conn->c_dn );
206 BER_BVZERO( &conn->c_ndn );
208 conn->c_listener = &slapi_listener;
209 ber_dupbv( &conn->c_peer_domain, (struct berval *)&slap_unknown_bv );
210 ber_dupbv( &conn->c_peer_name, (struct berval *)&slap_unknown_bv );
212 LDAP_STAILQ_INIT( &conn->c_ops );
214 BER_BVZERO( &conn->c_sasl_bind_mech );
215 conn->c_sasl_authctx = NULL;
216 conn->c_sasl_sockctx = NULL;
217 conn->c_sasl_extra = NULL;
219 conn->c_sb = ber_sockbuf_alloc();
221 ber_sockbuf_ctrl( conn->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max );
223 conn->c_currentber = NULL;
225 /* should check status of thread calls */
226 ldap_pvt_thread_mutex_init( &conn->c_mutex );
227 ldap_pvt_thread_mutex_init( &conn->c_write_mutex );
228 ldap_pvt_thread_cond_init( &conn->c_write_cv );
230 ldap_pvt_thread_mutex_lock( &conn->c_mutex );
232 conn->c_n_ops_received = 0;
233 conn->c_n_ops_executing = 0;
234 conn->c_n_ops_pending = 0;
235 conn->c_n_ops_completed = 0;
241 conn->c_protocol = LDAP_VERSION3;
243 conn->c_activitytime = conn->c_starttime = slap_get_time();
246 * A real connection ID is required, because syncrepl associates
247 * pending CSNs with unique ( connection, operation ) tuples.
248 * Setting a fake connection ID will cause slap_get_commit_csn()
249 * to return a stale value.
251 connection_assign_nextid( conn );
253 conn->c_conn_state = 0x01; /* SLAP_C_ACTIVE */
254 conn->c_struct_state = 0x02; /* SLAP_C_USED */
256 conn->c_ssf = conn->c_transport_ssf = local_ssf;
259 backend_connection_init( conn );
261 conn->c_send_ldap_result = slap_send_ldap_result;
262 conn->c_send_search_entry = slap_send_search_entry;
263 conn->c_send_ldap_extended = slap_send_ldap_extended;
264 conn->c_send_search_reference = slap_send_search_reference;
266 /* operation object */
268 op->o_protocol = LDAP_VERSION3;
269 BER_BVZERO( &op->o_authmech );
270 op->o_time = slap_get_time();
271 op->o_do_not_cache = 1;
272 op->o_threadctx = ldap_pvt_thread_pool_context();
273 op->o_tmpmemctx = NULL;
274 op->o_tmpmfuncs = &ch_mfuncs;
276 op->o_connid = conn->c_connid;
277 op->o_bd = frontendDB;
280 slapi_int_create_object_extensions( SLAPI_X_EXT_OPERATION, op );
281 slapi_int_create_object_extensions( SLAPI_X_EXT_CONNECTION, conn );
283 pb->pb_rs = (SlapReply *)slapi_ch_calloc( 1, sizeof(SlapReply) );
288 ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
292 slapi_int_set_operation_dn( Slapi_PBlock *pb )
295 Operation *op = pb->pb_op;
297 if ( BER_BVISNULL( &op->o_ndn ) ) {
299 be = select_backend( &op->o_req_ndn, get_manageDSAit( op ), 1 );
301 ber_dupbv( &op->o_dn, &be->be_rootdn );
302 ber_dupbv( &op->o_ndn, &be->be_rootndn );
308 slapi_int_connection_done_pb( Slapi_PBlock *pb )
313 PBLOCK_ASSERT_INTOP( pb, 0 );
318 /* free allocated DNs */
319 if ( !BER_BVISNULL( &op->o_dn ) )
320 op->o_tmpfree( op->o_dn.bv_val, op->o_tmpmemctx );
321 if ( !BER_BVISNULL( &op->o_ndn ) )
322 op->o_tmpfree( op->o_ndn.bv_val, op->o_tmpmemctx );
324 if ( !BER_BVISNULL( &op->o_req_dn ) )
325 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
326 if ( !BER_BVISNULL( &op->o_req_ndn ) )
327 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
329 switch ( op->o_tag ) {
330 case LDAP_REQ_MODRDN:
331 if ( !BER_BVISNULL( &op->orr_newrdn ))
332 op->o_tmpfree( op->orr_newrdn.bv_val, op->o_tmpmemctx );
333 if ( !BER_BVISNULL( &op->orr_nnewrdn ))
334 op->o_tmpfree( op->orr_nnewrdn.bv_val, op->o_tmpmemctx );
335 if ( op->orr_newSup != NULL ) {
336 assert( !BER_BVISNULL( op->orr_newSup ) );
337 op->o_tmpfree( op->orr_newSup->bv_val, op->o_tmpmemctx );
338 op->o_tmpfree( op->orr_newSup, op->o_tmpmemctx );
340 if ( op->orr_nnewSup != NULL ) {
341 assert( !BER_BVISNULL( op->orr_nnewSup ) );
342 op->o_tmpfree( op->orr_nnewSup->bv_val, op->o_tmpmemctx );
343 op->o_tmpfree( op->orr_nnewSup, op->o_tmpmemctx );
345 slap_mods_free( op->orr_modlist, 1 );
348 slap_mods_free( op->ora_modlist, 0 );
350 case LDAP_REQ_MODIFY:
351 slap_mods_free( op->orm_modlist, 1 );
353 case LDAP_REQ_SEARCH:
354 if ( op->ors_attrs != NULL ) {
355 op->o_tmpfree( op->ors_attrs, op->o_tmpmemctx );
356 op->ors_attrs = NULL;
363 slapi_ch_free_string( &conn->c_authmech.bv_val );
364 slapi_ch_free_string( &conn->c_dn.bv_val );
365 slapi_ch_free_string( &conn->c_ndn.bv_val );
366 slapi_ch_free_string( &conn->c_peer_domain.bv_val );
367 slapi_ch_free_string( &conn->c_peer_name.bv_val );
369 if ( conn->c_sb != NULL ) {
370 ber_sockbuf_free( conn->c_sb );
373 slapi_int_free_object_extensions( SLAPI_X_EXT_OPERATION, op );
374 slapi_int_free_object_extensions( SLAPI_X_EXT_CONNECTION, conn );
376 slapi_ch_free( (void **)&pb->pb_op->o_callback );
377 slapi_ch_free( (void **)&pb->pb_op );
378 slapi_ch_free( (void **)&pb->pb_conn );
379 slapi_ch_free( (void **)&pb->pb_rs );
383 slapi_int_func_internal_pb( Slapi_PBlock *pb, slap_operation_t which )
386 SlapReply *rs = pb->pb_rs;
389 PBLOCK_ASSERT_INTOP( pb, 0 );
391 rc = slapi_int_get_ctrls( pb );
392 if ( rc != LDAP_SUCCESS ) {
397 pb->pb_op->o_bd = frontendDB;
398 func = &frontendDB->be_bind;
400 return func[which]( pb->pb_op, pb->pb_rs );
404 slapi_delete_internal_pb( Slapi_PBlock *pb )
410 PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_DELETE );
412 slapi_int_func_internal_pb( pb, op_delete );
418 slapi_add_internal_pb( Slapi_PBlock *pb )
421 Slapi_Entry *entry_orig = NULL;
427 PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_ADD );
431 entry_orig = pb->pb_op->ora_e;
432 pb->pb_op->ora_e = NULL;
435 * The caller can specify a new entry, or a target DN and set
436 * of modifications, but not both.
438 if ( entry_orig != NULL ) {
439 if ( pb->pb_op->ora_modlist != NULL || !BER_BVISNULL( &pb->pb_op->o_req_ndn )) {
440 rs->sr_err = LDAP_PARAM_ERROR;
444 assert( BER_BVISNULL( &pb->pb_op->o_req_dn ) ); /* shouldn't get set */
445 ber_dupbv( &pb->pb_op->o_req_dn, &entry_orig->e_name );
446 ber_dupbv( &pb->pb_op->o_req_ndn, &entry_orig->e_nname );
447 } else if ( pb->pb_op->ora_modlist == NULL || BER_BVISNULL( &pb->pb_op->o_req_ndn )) {
448 rs->sr_err = LDAP_PARAM_ERROR;
452 pb->pb_op->ora_e = (Entry *)slapi_ch_calloc( 1, sizeof(Entry) );
453 ber_dupbv( &pb->pb_op->ora_e->e_name, &pb->pb_op->o_req_dn );
454 ber_dupbv( &pb->pb_op->ora_e->e_nname, &pb->pb_op->o_req_ndn );
456 if ( entry_orig != NULL ) {
457 assert( pb->pb_op->ora_modlist == NULL );
459 rs->sr_err = slap_entry2mods( entry_orig, &pb->pb_op->ora_modlist,
460 &rs->sr_text, pb->pb_textbuf, sizeof( pb->pb_textbuf ) );
461 if ( rs->sr_err != LDAP_SUCCESS ) {
465 assert( pb->pb_op->ora_modlist != NULL );
468 rs->sr_err = slap_mods_check( pb->pb_op->ora_modlist, &rs->sr_text,
469 pb->pb_textbuf, sizeof( pb->pb_textbuf ), NULL );
470 if ( rs->sr_err != LDAP_SUCCESS ) {
474 /* Duplicate the values, because we may call slapi_entry_free() */
475 rs->sr_err = slap_mods2entry( pb->pb_op->ora_modlist, &pb->pb_op->ora_e,
476 1, 0, &rs->sr_text, pb->pb_textbuf, sizeof( pb->pb_textbuf ) );
477 if ( rs->sr_err != LDAP_SUCCESS ) {
481 if ( slapi_int_func_internal_pb( pb, op_add ) == 0 ) {
482 if ( pb->pb_op->ora_e != NULL && pb->pb_op->o_private != NULL ) {
483 BackendDB *bd = pb->pb_op->o_bd;
485 pb->pb_op->o_bd = (BackendDB *)pb->pb_op->o_private;
486 pb->pb_op->o_private = NULL;
487 be_entry_release_w( pb->pb_op, pb->pb_op->ora_e );
488 pb->pb_op->ora_e = NULL;
489 pb->pb_op->o_bd = bd;
490 pb->pb_op->o_private = NULL;
496 if ( pb->pb_op->ora_e != NULL ) {
497 slapi_entry_free( pb->pb_op->ora_e );
498 pb->pb_op->ora_e = NULL;
500 if ( entry_orig != NULL ) {
501 pb->pb_op->ora_e = entry_orig;
502 slap_mods_free( pb->pb_op->ora_modlist, 1 );
503 pb->pb_op->ora_modlist = NULL;
510 slapi_modrdn_internal_pb( Slapi_PBlock *pb )
516 PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_MODRDN );
518 if ( BER_BVISEMPTY( &pb->pb_op->o_req_ndn ) ) {
519 pb->pb_rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
523 slapi_int_func_internal_pb( pb, op_modrdn );
531 slapi_modify_internal_pb( Slapi_PBlock *pb )
539 PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_MODIFY );
543 if ( pb->pb_op->orm_modlist == NULL ) {
544 rs->sr_err = LDAP_PARAM_ERROR;
548 if ( BER_BVISEMPTY( &pb->pb_op->o_req_ndn ) ) {
549 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
553 rs->sr_err = slap_mods_check( pb->pb_op->orm_modlist,
554 &rs->sr_text, pb->pb_textbuf, sizeof( pb->pb_textbuf ), NULL );
555 if ( rs->sr_err != LDAP_SUCCESS ) {
559 slapi_int_func_internal_pb( pb, op_modify );
567 slapi_int_search_entry_callback( Slapi_Entry *entry, void *callback_data )
569 int nentries = 0, i = 0;
570 Slapi_Entry **head = NULL, **tp;
571 Slapi_PBlock *pb = (Slapi_PBlock *)callback_data;
573 PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_SEARCH );
575 entry = slapi_entry_dup( entry );
576 if ( entry == NULL ) {
577 return LDAP_NO_MEMORY;
580 slapi_pblock_get( pb, SLAPI_NENTRIES, &nentries );
581 slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &head );
584 if ( nentries == 0 ) {
585 tp = (Slapi_Entry **)slapi_ch_malloc( 2 * sizeof(Slapi_Entry *) );
587 slapi_entry_free( entry );
588 return LDAP_NO_MEMORY;
593 tp = (Slapi_Entry **)slapi_ch_realloc( (char *)head,
594 sizeof(Slapi_Entry *) * ( i + 1 ) );
596 slapi_entry_free( entry );
597 return LDAP_NO_MEMORY;
603 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, (void *)tp );
604 slapi_pblock_set( pb, SLAPI_NENTRIES, (void *)&i );
610 slapi_search_internal_pb( Slapi_PBlock *pb )
612 return slapi_search_internal_callback_pb( pb,
615 slapi_int_search_entry_callback,
620 slapi_search_internal_callback_pb( Slapi_PBlock *pb,
622 plugin_result_callback prc,
623 plugin_search_entry_callback psec,
624 plugin_referral_entry_callback prec )
633 PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_SEARCH );
637 /* search callback and arguments */
638 slapi_pblock_set( pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void *)prc );
639 slapi_pblock_set( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, (void *)psec );
640 slapi_pblock_set( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, (void *)prec );
641 slapi_pblock_set( pb, SLAPI_X_INTOP_CALLBACK_DATA, (void *)callback_data );
643 if ( BER_BVISEMPTY( &pb->pb_op->ors_filterstr )) {
644 rs->sr_err = LDAP_PARAM_ERROR;
648 if ( pb->pb_op->ors_filter == NULL ) {
649 pb->pb_op->ors_filter = slapi_str2filter( pb->pb_op->ors_filterstr.bv_val );
650 if ( pb->pb_op->ors_filter == NULL ) {
651 rs->sr_err = LDAP_PROTOCOL_ERROR;
658 slapi_int_func_internal_pb( pb, op_search );
662 slapi_filter_free( pb->pb_op->ors_filter, 1 );
663 pb->pb_op->ors_filter = NULL;
666 slapi_pblock_delete_param( pb, SLAPI_X_INTOP_RESULT_CALLBACK );
667 slapi_pblock_delete_param( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK );
668 slapi_pblock_delete_param( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK );
669 slapi_pblock_delete_param( pb, SLAPI_X_INTOP_CALLBACK_DATA );
674 /* Wrappers for old API */
677 slapi_search_internal_set_pb( Slapi_PBlock *pb,
683 LDAPControl **controls,
684 const char *uniqueid,
685 Slapi_ComponentId *plugin_identity,
686 int operation_flags )
688 int no_limit = SLAP_NO_LIMIT;
689 int deref = LDAP_DEREF_NEVER;
691 slapi_int_connection_init_pb( pb, LDAP_REQ_SEARCH );
692 slapi_pblock_set( pb, SLAPI_SEARCH_TARGET, (void *)base );
693 slapi_pblock_set( pb, SLAPI_SEARCH_SCOPE, (void *)&scope );
694 slapi_pblock_set( pb, SLAPI_SEARCH_FILTER, (void *)0 );
695 slapi_pblock_set( pb, SLAPI_SEARCH_STRFILTER, (void *)filter );
696 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRS, (void *)attrs );
697 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRSONLY, (void *)&attrsonly );
698 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
699 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
700 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
701 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags );
702 slapi_pblock_set( pb, SLAPI_SEARCH_DEREF, (void *)&deref );
703 slapi_pblock_set( pb, SLAPI_SEARCH_SIZELIMIT, (void *)&no_limit );
704 slapi_pblock_set( pb, SLAPI_SEARCH_TIMELIMIT, (void *)&no_limit );
706 slapi_int_set_operation_dn( pb );
710 slapi_search_internal(
714 LDAPControl **controls,
720 pb = slapi_pblock_new();
722 slapi_search_internal_set_pb( pb, ldn, scope, filStr,
724 controls, NULL, NULL, 0 );
726 slapi_search_internal_pb( pb );
732 slapi_modify_internal_set_pb( Slapi_PBlock *pb,
735 LDAPControl **controls,
736 const char *uniqueid,
737 Slapi_ComponentId *plugin_identity,
738 int operation_flags )
740 slapi_int_connection_init_pb( pb, LDAP_REQ_MODIFY );
741 slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn );
742 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)mods );
743 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
744 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
745 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
746 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags );
747 slapi_int_set_operation_dn( pb );
750 /* Function : slapi_modify_internal
752 * Description: Plugin functions call this routine to modify an entry
753 * in the backend directly
754 * Return values : LDAP_SUCCESS
758 * LDAP_UNWILLING_TO_PERFORM
761 slapi_modify_internal(
764 LDAPControl **controls,
769 pb = slapi_pblock_new();
771 slapi_modify_internal_set_pb( pb, ldn, mods, controls, NULL, NULL, 0 );
772 slapi_pblock_set( pb, SLAPI_LOG_OPERATION, (void *)&log_change );
773 slapi_modify_internal_pb( pb );
779 slapi_add_internal_set_pb( Slapi_PBlock *pb,
782 LDAPControl **controls,
783 Slapi_ComponentId *plugin_identity,
784 int operation_flags )
786 slapi_int_connection_init_pb( pb, LDAP_REQ_ADD );
787 slapi_pblock_set( pb, SLAPI_ADD_TARGET, (void *)dn );
788 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)attrs );
789 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
790 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
791 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags );
792 slapi_int_set_operation_dn( pb );
801 LDAPControl **controls,
806 pb = slapi_pblock_new();
808 slapi_add_internal_set_pb( pb, dn, attrs, controls, NULL, 0);
809 slapi_pblock_set( pb, SLAPI_LOG_OPERATION, (void *)&log_change );
810 slapi_add_internal_pb( pb );
816 slapi_add_entry_internal_set_pb( Slapi_PBlock *pb,
818 LDAPControl **controls,
819 Slapi_ComponentId *plugin_identity,
820 int operation_flags )
822 slapi_int_connection_init_pb( pb, LDAP_REQ_ADD );
823 slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)e );
824 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
825 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
826 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags );
827 slapi_int_set_operation_dn( pb );
831 slapi_add_entry_internal(
833 LDAPControl **controls,
838 pb = slapi_pblock_new();
840 slapi_add_entry_internal_set_pb( pb, e, controls, NULL, 0 );
841 slapi_pblock_set( pb, SLAPI_LOG_OPERATION, (void *)&log_change );
842 slapi_add_internal_pb( pb );
848 slapi_rename_internal_set_pb( Slapi_PBlock *pb,
851 const char *newsuperior,
853 LDAPControl **controls,
854 const char *uniqueid,
855 Slapi_ComponentId *plugin_identity,
856 int operation_flags )
858 slapi_int_connection_init_pb( pb, LDAP_REQ_MODRDN );
859 slapi_pblock_set( pb, SLAPI_MODRDN_TARGET, (void *)olddn );
860 slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)newrdn );
861 slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR, (void *)newsuperior );
862 slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)&deloldrdn );
863 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
864 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
865 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
866 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags );
867 slap_modrdn2mods( pb->pb_op, pb->pb_rs );
868 slapi_int_set_operation_dn( pb );
871 /* Function : slapi_modrdn_internal
873 * Description : Plugin functions call this routine to modify the rdn
874 * of an entry in the backend directly
875 * Return values : LDAP_SUCCESS
879 * LDAP_UNWILLING_TO_PERFORM
881 * NOTE: This function does not support the "newSuperior" option from LDAP V3.
884 slapi_modrdn_internal(
888 LDAPControl **controls,
893 pb = slapi_pblock_new ();
895 slapi_rename_internal_set_pb( pb, olddn, lnewrdn, NULL,
896 deloldrdn, controls, NULL, NULL, 0 );
897 slapi_pblock_set( pb, SLAPI_LOG_OPERATION, (void *)&log_change );
898 slapi_modrdn_internal_pb( pb );
904 slapi_delete_internal_set_pb( Slapi_PBlock *pb,
906 LDAPControl **controls,
907 const char *uniqueid,
908 Slapi_ComponentId *plugin_identity,
909 int operation_flags )
911 slapi_int_connection_init_pb( pb, LDAP_REQ_DELETE );
912 slapi_pblock_set( pb, SLAPI_TARGET_DN, (void *)dn );
913 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
914 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
915 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
916 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags );
917 slapi_int_set_operation_dn( pb );
920 /* Function : slapi_delete_internal
922 * Description : Plugin functions call this routine to delete an entry
923 * in the backend directly
924 * Return values : LDAP_SUCCESS
928 * LDAP_UNWILLING_TO_PERFORM
931 slapi_delete_internal(
933 LDAPControl **controls,
938 pb = slapi_pblock_new();
940 slapi_delete_internal_set_pb( pb, ldn, controls, NULL, NULL, 0 );
941 slapi_pblock_set( pb, SLAPI_LOG_OPERATION, (void *)&log_change );
942 slapi_delete_internal_pb( pb );
947 #endif /* LDAP_SLAPI */