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->pop->o_ctrls != NULL ) {
169 for ( c = pb->pop->o_ctrls; *c != NULL; c++ ) {
170 rc = slap_parse_ctrl( pb->pop, &pb->rs, *c, &pb->rs.sr_text );
171 if ( rc != LDAP_SUCCESS )
180 slapi_int_connection_init_pb( Slapi_PBlock *pb, ber_tag_t OpType )
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_hdr->oh_extensions = NULL;
193 op->o_controls = (void **)(op->o_hdr + 1);
195 op->o_callback = (slap_callback *) slapi_ch_calloc( 1, sizeof(slap_callback) );
196 op->o_callback->sc_response = slapi_int_response;
197 op->o_callback->sc_cleanup = NULL;
198 op->o_callback->sc_private = pb;
199 op->o_callback->sc_next = NULL;
201 conn->c_pending_ops.stqh_first = op;
203 /* connection object authorization information */
204 conn->c_authtype = LDAP_AUTH_NONE;
205 BER_BVZERO( &conn->c_authmech );
206 BER_BVZERO( &conn->c_dn );
207 BER_BVZERO( &conn->c_ndn );
209 conn->c_listener = &slapi_listener;
210 ber_dupbv( &conn->c_peer_domain, (struct berval *)&slap_unknown_bv );
211 ber_dupbv( &conn->c_peer_name, (struct berval *)&slap_unknown_bv );
213 LDAP_STAILQ_INIT( &conn->c_ops );
215 BER_BVZERO( &conn->c_sasl_bind_mech );
216 conn->c_sasl_authctx = NULL;
217 conn->c_sasl_sockctx = NULL;
218 conn->c_sasl_extra = NULL;
220 conn->c_sb = ber_sockbuf_alloc();
222 ber_sockbuf_ctrl( conn->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max );
224 conn->c_currentber = NULL;
226 /* should check status of thread calls */
227 ldap_pvt_thread_mutex_init( &conn->c_mutex );
228 ldap_pvt_thread_mutex_init( &conn->c_write_mutex );
229 ldap_pvt_thread_cond_init( &conn->c_write_cv );
231 ldap_pvt_thread_mutex_lock( &conn->c_mutex );
233 conn->c_n_ops_received = 0;
234 conn->c_n_ops_executing = 0;
235 conn->c_n_ops_pending = 0;
236 conn->c_n_ops_completed = 0;
242 conn->c_protocol = LDAP_VERSION3;
244 conn->c_activitytime = conn->c_starttime = slap_get_time();
247 * A real connection ID is required, because syncrepl associates
248 * pending CSNs with unique ( connection, operation ) tuples.
249 * Setting a fake connection ID will cause slap_get_commit_csn()
250 * to return a stale value.
252 connection_assign_nextid( conn );
254 conn->c_conn_state = 0x01; /* SLAP_C_ACTIVE */
255 conn->c_struct_state = 0x02; /* SLAP_C_USED */
257 conn->c_ssf = conn->c_transport_ssf = 0;
260 backend_connection_init( conn );
262 conn->c_send_ldap_result = slap_send_ldap_result;
263 conn->c_send_search_entry = slap_send_search_entry;
264 conn->c_send_ldap_extended = slap_send_ldap_extended;
265 conn->c_send_search_reference = slap_send_search_reference;
267 /* operation object */
269 op->o_protocol = LDAP_VERSION3;
270 BER_BVZERO( &op->o_authmech );
271 op->o_time = slap_get_time();
272 op->o_do_not_cache = 1;
273 op->o_threadctx = ldap_pvt_thread_pool_context();
274 op->o_tmpmemctx = NULL;
275 op->o_tmpmfuncs = &ch_mfuncs;
277 op->o_connid = conn->c_connid;
278 op->o_bd = frontendDB;
284 ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
288 slapi_int_set_operation_dn( Slapi_PBlock *pb )
291 Operation *op = pb->pop;
293 if ( BER_BVISNULL( &op->o_ndn ) ) {
295 be = select_backend( &op->o_req_ndn, 0, 0 );
296 assert( be != NULL );
297 ber_dupbv( &op->o_dn, &be->be_rootdn );
298 ber_dupbv( &op->o_ndn, &be->be_rootndn );
303 slapi_int_connection_done_pb( Slapi_PBlock *pb )
308 PBLOCK_ASSERT_INTOP( pb, 0 );
313 /* free allocated DNs */
314 if ( !BER_BVISNULL( &op->o_dn ) )
315 op->o_tmpfree( op->o_dn.bv_val, op->o_tmpmemctx );
316 if ( !BER_BVISNULL( &op->o_ndn ) )
317 op->o_tmpfree( op->o_ndn.bv_val, op->o_tmpmemctx );
319 if ( !BER_BVISNULL( &op->o_req_dn ) )
320 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
321 if ( !BER_BVISNULL( &op->o_req_ndn ) )
322 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
324 switch ( op->o_tag ) {
325 case LDAP_REQ_MODRDN:
326 if ( !BER_BVISNULL( &op->orr_newrdn ))
327 op->o_tmpfree( op->orr_newrdn.bv_val, op->o_tmpmemctx );
328 if ( !BER_BVISNULL( &op->orr_nnewrdn ))
329 op->o_tmpfree( op->orr_nnewrdn.bv_val, op->o_tmpmemctx );
330 if ( op->orr_newSup != NULL ) {
331 assert( !BER_BVISNULL( op->orr_newSup ) );
332 op->o_tmpfree( op->orr_newSup->bv_val, op->o_tmpmemctx );
333 op->o_tmpfree( op->orr_newSup, op->o_tmpmemctx );
335 if ( op->orr_nnewSup != NULL ) {
336 assert( !BER_BVISNULL( op->orr_nnewSup ) );
337 op->o_tmpfree( op->orr_nnewSup->bv_val, op->o_tmpmemctx );
338 op->o_tmpfree( op->orr_nnewSup, op->o_tmpmemctx );
342 slapi_int_mods_free( op->ora_modlist );
344 case LDAP_REQ_MODIFY:
345 slapi_int_mods_free( op->orm_modlist );
347 case LDAP_REQ_SEARCH:
348 if ( op->ors_attrs != NULL ) {
349 op->o_tmpfree( op->ors_attrs, op->o_tmpmemctx );
350 op->ors_attrs = NULL;
357 if ( conn->c_sb != NULL ) {
358 ber_sockbuf_free( conn->c_sb );
361 slapi_ch_free( (void **)&pb->pop->o_callback );
362 slapi_ch_free( (void **)&pb->pop );
363 slapi_ch_free( (void **)&pb->pconn );
367 slapi_int_func_internal_pb( Slapi_PBlock *pb, slap_operation_t which )
370 SlapReply *rs = &pb->rs;
372 PBLOCK_ASSERT_INTOP( pb, 0 );
374 rs->sr_err = slapi_int_get_ctrls( pb );
375 if ( rs->sr_err != LDAP_SUCCESS ) {
379 func = &pb->pop->o_bd->be_bind;
381 rs->sr_err = func[which]( pb->pop, &pb->rs );
387 slapi_delete_internal_pb( Slapi_PBlock *pb )
393 PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_DELETE );
395 slapi_int_func_internal_pb( pb, op_delete );
396 slap_graduate_commit_csn( pb->pop );
402 slapi_add_internal_pb( Slapi_PBlock *pb )
405 Slapi_Entry *entry_orig = NULL;
411 PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_ADD );
415 entry_orig = pb->pop->ora_e;
416 pb->pop->ora_e = NULL;
418 if ( entry_orig != NULL ) {
419 if ( pb->pop->ora_modlist != NULL || !BER_BVISNULL( &pb->pop->o_req_ndn )) {
420 rs->sr_err = LDAP_PARAM_ERROR;
424 assert( BER_BVISNULL( &pb->pop->o_req_dn ) ); /* shouldn't get set */
425 ber_dupbv( &pb->pop->o_req_dn, &entry_orig->e_name );
426 ber_dupbv( &pb->pop->o_req_ndn, &entry_orig->e_nname );
427 } else if ( pb->pop->ora_modlist == NULL || BER_BVISNULL( &pb->pop->o_req_ndn )) {
428 rs->sr_err = LDAP_PARAM_ERROR;
433 * The caller can specify a new entry, or a target DN and set
434 * of modifications, but not both.
436 pb->pop->ora_e = (Entry *)slapi_ch_calloc( 1, sizeof(Entry) );
437 ber_dupbv( &pb->pop->ora_e->e_name, &pb->pop->o_req_dn );
438 ber_dupbv( &pb->pop->ora_e->e_nname, &pb->pop->o_req_ndn );
440 if ( entry_orig != NULL ) {
441 assert( pb->pop->ora_modlist == NULL );
443 rs->sr_err = slap_entry2mods( entry_orig, &pb->pop->ora_modlist,
444 &rs->sr_text, pb->textbuf, sizeof( pb->textbuf ) );
445 if ( rs->sr_err != LDAP_SUCCESS ) {
449 assert( pb->pop->ora_modlist != NULL );
452 rs->sr_err = slap_mods_check( pb->pop->ora_modlist, &rs->sr_text,
453 pb->textbuf, sizeof( pb->textbuf ), NULL );
454 if ( rs->sr_err != LDAP_SUCCESS ) {
458 if ( slapi_int_func_internal_pb( pb, op_add ) == 0 ) {
459 if ( pb->pop->ora_e != NULL && pb->pop->o_private != NULL ) {
460 BackendDB *bd = pb->pop->o_bd;
462 /* could we use SLAPI_BACKEND instead? */
463 pb->pop->o_bd = (BackendDB *)pb->pop->o_private;
464 pb->pop->o_private = NULL;
465 be_entry_release_w( pb->pop, pb->pop->ora_e );
466 pb->pop->ora_e = NULL;
468 pb->pop->o_private = NULL;
473 slap_graduate_commit_csn( pb->pop );
475 if ( pb->pop->ora_e != NULL ) {
476 slapi_entry_free( pb->pop->ora_e );
477 pb->pop->ora_e = NULL;
479 if ( entry_orig != NULL ) {
480 pb->pop->ora_e = entry_orig;
481 slapi_int_mods_free( pb->pop->ora_modlist );
482 pb->pop->ora_modlist = NULL;
489 slapi_modrdn_internal_pb( Slapi_PBlock *pb )
495 PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_MODRDN );
497 if ( BER_BVISEMPTY( &pb->pop->o_req_ndn ) ) {
498 pb->rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
502 slapi_int_func_internal_pb( pb, op_modrdn );
505 slap_graduate_commit_csn( pb->pop );
511 slapi_modify_internal_pb( Slapi_PBlock *pb )
519 PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_MODIFY );
523 if ( pb->pop->orm_modlist == NULL ) {
524 rs->sr_err = LDAP_PARAM_ERROR;
528 if ( BER_BVISEMPTY( &pb->pop->o_req_ndn ) ) {
529 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
533 rs->sr_err = slap_mods_check( pb->pop->orm_modlist,
534 &rs->sr_text, pb->textbuf, sizeof( pb->textbuf ), NULL );
535 if ( rs->sr_err != LDAP_SUCCESS ) {
539 slapi_int_func_internal_pb( pb, op_modify );
542 slap_graduate_commit_csn( pb->pop );
548 slapi_int_search_entry_callback( Slapi_Entry *entry, void *callback_data )
550 int nentries = 0, i = 0;
551 Slapi_Entry **head = NULL, **tp;
552 Slapi_PBlock *pb = (Slapi_PBlock *)callback_data;
554 PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_SEARCH );
556 entry = slapi_entry_dup( entry );
557 if ( entry == NULL ) {
558 return LDAP_NO_MEMORY;
561 slapi_pblock_get( pb, SLAPI_NENTRIES, &nentries );
562 slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &head );
565 if ( nentries == 0 ) {
566 tp = (Slapi_Entry **)slapi_ch_malloc( 2 * sizeof(Slapi_Entry *) );
568 slapi_entry_free( entry );
569 return LDAP_NO_MEMORY;
574 tp = (Slapi_Entry **)slapi_ch_realloc( (char *)head,
575 sizeof(Slapi_Entry *) * ( i + 1 ) );
577 slapi_entry_free( entry );
578 return LDAP_NO_MEMORY;
584 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, (void *)tp );
585 slapi_pblock_set( pb, SLAPI_NENTRIES, (void *)i );
591 slapi_search_internal_pb( Slapi_PBlock *pb )
593 return slapi_search_internal_callback_pb( pb,
596 slapi_int_search_entry_callback,
601 slapi_search_internal_callback_pb( Slapi_PBlock *pb,
603 plugin_result_callback prc,
604 plugin_search_entry_callback psec,
605 plugin_referral_entry_callback prec )
614 PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_SEARCH );
618 /* search callback and arguments */
619 slapi_pblock_set( pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void *)prc );
620 slapi_pblock_set( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, (void *)psec );
621 slapi_pblock_set( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, (void *)prec );
622 slapi_pblock_set( pb, SLAPI_X_INTOP_CALLBACK_DATA, (void *)callback_data );
624 if ( BER_BVISEMPTY( &pb->pop->ors_filterstr )) {
625 rs->sr_err = LDAP_PARAM_ERROR;
629 if ( pb->pop->ors_filter == NULL ) {
630 pb->pop->ors_filter = slapi_str2filter( pb->pop->ors_filterstr.bv_val );
631 if ( pb->pop->ors_filter == NULL ) {
632 rs->sr_err = LDAP_PROTOCOL_ERROR;
639 slapi_int_func_internal_pb( pb, op_search );
643 slapi_filter_free( pb->pop->ors_filter, 1 );
644 pb->pop->ors_filter = NULL;
647 slapi_pblock_set( pb, SLAPI_X_INTOP_RESULT_CALLBACK, NULL );
648 slapi_pblock_set( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, NULL );
649 slapi_pblock_set( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, NULL );
650 slapi_pblock_set( pb, SLAPI_X_INTOP_CALLBACK_DATA, NULL );
655 /* Wrappers for old API */
658 slapi_search_internal_set_pb( Slapi_PBlock *pb,
664 LDAPControl **controls,
665 const char *uniqueid,
666 Slapi_ComponentId *plugin_identity,
667 int operation_flags )
669 slapi_int_connection_init_pb( pb, LDAP_REQ_SEARCH );
670 slapi_pblock_set( pb, SLAPI_SEARCH_TARGET, (void *)base );
671 slapi_pblock_set( pb, SLAPI_SEARCH_SCOPE, (void *)scope );
672 slapi_pblock_set( pb, SLAPI_SEARCH_FILTER, NULL );
673 slapi_pblock_set( pb, SLAPI_SEARCH_STRFILTER, (void *)filter );
674 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRS, (void *)attrs );
675 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRSONLY, (void *)attrsonly );
676 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
677 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
678 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
679 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
680 slapi_pblock_set( pb, SLAPI_SEARCH_DEREF, (void *)0 );
681 slapi_pblock_set( pb, SLAPI_SEARCH_SIZELIMIT, (void *)SLAP_NO_LIMIT );
682 slapi_pblock_set( pb, SLAPI_SEARCH_TIMELIMIT, (void *)SLAP_NO_LIMIT );
684 slapi_int_set_operation_dn( pb );
688 slapi_search_internal(
692 LDAPControl **controls,
698 pb = slapi_pblock_new();
700 slapi_search_internal_set_pb( pb, ldn, scope, filStr,
702 controls, NULL, NULL, 0 );
704 slapi_search_internal_pb( pb );
710 slapi_modify_internal_set_pb( Slapi_PBlock *pb,
713 LDAPControl **controls,
714 const char *uniqueid,
715 Slapi_ComponentId *plugin_identity,
716 int operation_flags )
718 slapi_int_connection_init_pb( pb, LDAP_REQ_MODIFY );
719 slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn );
720 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)mods );
721 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
722 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
723 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
724 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
725 slapi_int_set_operation_dn( pb );
728 /* Function : slapi_modify_internal
730 * Description: Plugin functions call this routine to modify an entry
731 * in the backend directly
732 * Return values : LDAP_SUCCESS
736 * LDAP_UNWILLING_TO_PERFORM
739 slapi_modify_internal(
742 LDAPControl **controls,
747 pb = slapi_pblock_new();
749 slapi_modify_internal_set_pb( pb, ldn, mods, controls, NULL, NULL,
750 log_change ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
752 slapi_modify_internal_pb( pb );
758 slapi_add_internal_set_pb( Slapi_PBlock *pb,
761 LDAPControl **controls,
762 Slapi_ComponentId *plugin_identity,
763 int operation_flags )
765 slapi_int_connection_init_pb( pb, LDAP_REQ_ADD );
766 slapi_pblock_set( pb, SLAPI_ADD_TARGET, (void *)dn );
767 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)attrs );
768 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
769 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
770 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
771 slapi_int_set_operation_dn( pb );
780 LDAPControl **controls,
785 pb = slapi_pblock_new();
787 slapi_add_internal_set_pb( pb, dn, attrs, controls, NULL,
788 log_changes ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
790 slapi_add_internal_pb( pb );
796 slapi_add_entry_internal_set_pb( Slapi_PBlock *pb,
798 LDAPControl **controls,
799 Slapi_ComponentId *plugin_identity,
800 int operation_flags )
802 slapi_int_connection_init_pb( pb, LDAP_REQ_ADD );
803 slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)e );
804 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
805 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
806 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
807 slapi_int_set_operation_dn( pb );
811 slapi_add_entry_internal(
813 LDAPControl **controls,
818 pb = slapi_pblock_new();
820 slapi_add_entry_internal_set_pb( pb, e, controls, NULL,
821 log_changes ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
823 slapi_add_internal_pb( pb );
829 slapi_rename_internal_set_pb( Slapi_PBlock *pb,
832 const char *newsuperior,
834 LDAPControl **controls,
835 const char *uniqueid,
836 Slapi_ComponentId *plugin_identity,
837 int operation_flags )
839 slapi_int_connection_init_pb( pb, LDAP_REQ_MODRDN );
840 slapi_pblock_set( pb, SLAPI_MODRDN_TARGET, (void *)olddn );
841 slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)newrdn );
842 slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR, (void *)newsuperior );
843 slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)deloldrdn );
844 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
845 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
846 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
847 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
848 slapi_int_set_operation_dn( pb );
851 /* Function : slapi_modrdn_internal
853 * Description : Plugin functions call this routine to modify the rdn
854 * of an entry in the backend directly
855 * Return values : LDAP_SUCCESS
859 * LDAP_UNWILLING_TO_PERFORM
861 * NOTE: This function does not support the "newSuperior" option from LDAP V3.
864 slapi_modrdn_internal(
868 LDAPControl **controls,
873 pb = slapi_pblock_new ();
875 slapi_rename_internal_set_pb( pb, olddn, lnewrdn, NULL,
876 deloldrdn, controls, NULL, NULL,
877 log_change ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
879 slapi_modrdn_internal_pb( pb );
885 slapi_delete_internal_set_pb( Slapi_PBlock *pb,
887 LDAPControl **controls,
888 const char *uniqueid,
889 Slapi_ComponentId *plugin_identity,
890 int operation_flags )
892 slapi_int_connection_init_pb( pb, LDAP_REQ_DELETE );
893 slapi_pblock_set( pb, SLAPI_TARGET_DN, (void *)dn );
894 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
895 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
896 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
897 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
898 slapi_int_set_operation_dn( pb );
901 /* Function : slapi_delete_internal
903 * Description : Plugin functions call this routine to delete an entry
904 * in the backend directly
905 * Return values : LDAP_SUCCESS
909 * LDAP_UNWILLING_TO_PERFORM
912 slapi_delete_internal(
914 LDAPControl **controls,
919 pb = slapi_pblock_new();
921 slapi_delete_internal_set_pb( pb, ldn, controls, NULL, NULL,
922 log_change ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
924 slapi_delete_internal_pb( pb );
929 #endif /* LDAP_SLAPI */