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 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_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 slapi_ch_free_string( &conn->c_authmech.bv_val );
358 slapi_ch_free_string( &conn->c_dn.bv_val );
359 slapi_ch_free_string( &conn->c_ndn.bv_val );
361 if ( conn->c_sb != NULL ) {
362 ber_sockbuf_free( conn->c_sb );
365 slapi_ch_free( (void **)&pb->pop->o_callback );
366 slapi_ch_free( (void **)&pb->pop );
367 slapi_ch_free( (void **)&pb->pconn );
371 slapi_int_func_internal_pb( Slapi_PBlock *pb, slap_operation_t which )
374 SlapReply *rs = &pb->rs;
377 PBLOCK_ASSERT_INTOP( pb, 0 );
379 rc = slapi_int_get_ctrls( pb );
380 if ( rc != LDAP_SUCCESS ) {
385 func = &pb->pop->o_bd->be_bind;
387 rc = func[which]( pb->pop, &pb->rs );
393 slapi_delete_internal_pb( Slapi_PBlock *pb )
399 PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_DELETE );
401 slapi_int_func_internal_pb( pb, op_delete );
402 slap_graduate_commit_csn( pb->pop );
408 slapi_add_internal_pb( Slapi_PBlock *pb )
411 Slapi_Entry *entry_orig = NULL;
417 PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_ADD );
421 entry_orig = pb->pop->ora_e;
422 pb->pop->ora_e = NULL;
424 if ( entry_orig != NULL ) {
425 if ( pb->pop->ora_modlist != NULL || !BER_BVISNULL( &pb->pop->o_req_ndn )) {
426 rs->sr_err = LDAP_PARAM_ERROR;
430 assert( BER_BVISNULL( &pb->pop->o_req_dn ) ); /* shouldn't get set */
431 ber_dupbv( &pb->pop->o_req_dn, &entry_orig->e_name );
432 ber_dupbv( &pb->pop->o_req_ndn, &entry_orig->e_nname );
433 } else if ( pb->pop->ora_modlist == NULL || BER_BVISNULL( &pb->pop->o_req_ndn )) {
434 rs->sr_err = LDAP_PARAM_ERROR;
439 * The caller can specify a new entry, or a target DN and set
440 * of modifications, but not both.
442 pb->pop->ora_e = (Entry *)slapi_ch_calloc( 1, sizeof(Entry) );
443 ber_dupbv( &pb->pop->ora_e->e_name, &pb->pop->o_req_dn );
444 ber_dupbv( &pb->pop->ora_e->e_nname, &pb->pop->o_req_ndn );
446 if ( entry_orig != NULL ) {
447 assert( pb->pop->ora_modlist == NULL );
449 rs->sr_err = slap_entry2mods( entry_orig, &pb->pop->ora_modlist,
450 &rs->sr_text, pb->textbuf, sizeof( pb->textbuf ) );
451 if ( rs->sr_err != LDAP_SUCCESS ) {
455 assert( pb->pop->ora_modlist != NULL );
458 rs->sr_err = slap_mods_check( pb->pop->ora_modlist, &rs->sr_text,
459 pb->textbuf, sizeof( pb->textbuf ), NULL );
460 if ( rs->sr_err != LDAP_SUCCESS ) {
464 if ( slapi_int_func_internal_pb( pb, op_add ) == 0 ) {
465 if ( pb->pop->ora_e != NULL && pb->pop->o_private != NULL ) {
466 BackendDB *bd = pb->pop->o_bd;
468 /* could we use SLAPI_BACKEND instead? */
469 pb->pop->o_bd = (BackendDB *)pb->pop->o_private;
470 pb->pop->o_private = NULL;
471 be_entry_release_w( pb->pop, pb->pop->ora_e );
472 pb->pop->ora_e = NULL;
474 pb->pop->o_private = NULL;
479 slap_graduate_commit_csn( pb->pop );
481 if ( pb->pop->ora_e != NULL ) {
482 slapi_entry_free( pb->pop->ora_e );
483 pb->pop->ora_e = NULL;
485 if ( entry_orig != NULL ) {
486 pb->pop->ora_e = entry_orig;
487 slapi_int_mods_free( pb->pop->ora_modlist );
488 pb->pop->ora_modlist = NULL;
495 slapi_modrdn_internal_pb( Slapi_PBlock *pb )
501 PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_MODRDN );
503 if ( BER_BVISEMPTY( &pb->pop->o_req_ndn ) ) {
504 pb->rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
508 slapi_int_func_internal_pb( pb, op_modrdn );
511 slap_graduate_commit_csn( pb->pop );
517 slapi_modify_internal_pb( Slapi_PBlock *pb )
525 PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_MODIFY );
529 if ( pb->pop->orm_modlist == NULL ) {
530 rs->sr_err = LDAP_PARAM_ERROR;
534 if ( BER_BVISEMPTY( &pb->pop->o_req_ndn ) ) {
535 rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
539 rs->sr_err = slap_mods_check( pb->pop->orm_modlist,
540 &rs->sr_text, pb->textbuf, sizeof( pb->textbuf ), NULL );
541 if ( rs->sr_err != LDAP_SUCCESS ) {
545 slapi_int_func_internal_pb( pb, op_modify );
548 slap_graduate_commit_csn( pb->pop );
554 slapi_int_search_entry_callback( Slapi_Entry *entry, void *callback_data )
556 int nentries = 0, i = 0;
557 Slapi_Entry **head = NULL, **tp;
558 Slapi_PBlock *pb = (Slapi_PBlock *)callback_data;
560 PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_SEARCH );
562 entry = slapi_entry_dup( entry );
563 if ( entry == NULL ) {
564 return LDAP_NO_MEMORY;
567 slapi_pblock_get( pb, SLAPI_NENTRIES, &nentries );
568 slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &head );
571 if ( nentries == 0 ) {
572 tp = (Slapi_Entry **)slapi_ch_malloc( 2 * sizeof(Slapi_Entry *) );
574 slapi_entry_free( entry );
575 return LDAP_NO_MEMORY;
580 tp = (Slapi_Entry **)slapi_ch_realloc( (char *)head,
581 sizeof(Slapi_Entry *) * ( i + 1 ) );
583 slapi_entry_free( entry );
584 return LDAP_NO_MEMORY;
590 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, (void *)tp );
591 slapi_pblock_set( pb, SLAPI_NENTRIES, (void *)i );
597 slapi_search_internal_pb( Slapi_PBlock *pb )
599 return slapi_search_internal_callback_pb( pb,
602 slapi_int_search_entry_callback,
607 slapi_search_internal_callback_pb( Slapi_PBlock *pb,
609 plugin_result_callback prc,
610 plugin_search_entry_callback psec,
611 plugin_referral_entry_callback prec )
620 PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_SEARCH );
624 /* search callback and arguments */
625 slapi_pblock_set( pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void *)prc );
626 slapi_pblock_set( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, (void *)psec );
627 slapi_pblock_set( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, (void *)prec );
628 slapi_pblock_set( pb, SLAPI_X_INTOP_CALLBACK_DATA, (void *)callback_data );
630 if ( BER_BVISEMPTY( &pb->pop->ors_filterstr )) {
631 rs->sr_err = LDAP_PARAM_ERROR;
635 if ( pb->pop->ors_filter == NULL ) {
636 pb->pop->ors_filter = slapi_str2filter( pb->pop->ors_filterstr.bv_val );
637 if ( pb->pop->ors_filter == NULL ) {
638 rs->sr_err = LDAP_PROTOCOL_ERROR;
645 slapi_int_func_internal_pb( pb, op_search );
649 slapi_filter_free( pb->pop->ors_filter, 1 );
650 pb->pop->ors_filter = NULL;
653 slapi_pblock_delete_param( pb, SLAPI_X_INTOP_RESULT_CALLBACK );
654 slapi_pblock_delete_param( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK );
655 slapi_pblock_delete_param( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK );
656 slapi_pblock_delete_param( pb, SLAPI_X_INTOP_CALLBACK_DATA );
661 /* Wrappers for old API */
664 slapi_search_internal_set_pb( Slapi_PBlock *pb,
670 LDAPControl **controls,
671 const char *uniqueid,
672 Slapi_ComponentId *plugin_identity,
673 int operation_flags )
675 slapi_int_connection_init_pb( pb, LDAP_REQ_SEARCH );
676 slapi_pblock_set( pb, SLAPI_SEARCH_TARGET, (void *)base );
677 slapi_pblock_set( pb, SLAPI_SEARCH_SCOPE, (void *)scope );
678 slapi_pblock_set( pb, SLAPI_SEARCH_FILTER, NULL );
679 slapi_pblock_set( pb, SLAPI_SEARCH_STRFILTER, (void *)filter );
680 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRS, (void *)attrs );
681 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRSONLY, (void *)attrsonly );
682 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
683 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
684 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
685 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
686 slapi_pblock_set( pb, SLAPI_SEARCH_DEREF, (void *)0 );
687 slapi_pblock_set( pb, SLAPI_SEARCH_SIZELIMIT, (void *)SLAP_NO_LIMIT );
688 slapi_pblock_set( pb, SLAPI_SEARCH_TIMELIMIT, (void *)SLAP_NO_LIMIT );
690 slapi_int_set_operation_dn( pb );
694 slapi_search_internal(
698 LDAPControl **controls,
704 pb = slapi_pblock_new();
706 slapi_search_internal_set_pb( pb, ldn, scope, filStr,
708 controls, NULL, NULL, 0 );
710 slapi_search_internal_pb( pb );
716 slapi_modify_internal_set_pb( Slapi_PBlock *pb,
719 LDAPControl **controls,
720 const char *uniqueid,
721 Slapi_ComponentId *plugin_identity,
722 int operation_flags )
724 slapi_int_connection_init_pb( pb, LDAP_REQ_MODIFY );
725 slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn );
726 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)mods );
727 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
728 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
729 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
730 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
731 slapi_int_set_operation_dn( pb );
734 /* Function : slapi_modify_internal
736 * Description: Plugin functions call this routine to modify an entry
737 * in the backend directly
738 * Return values : LDAP_SUCCESS
742 * LDAP_UNWILLING_TO_PERFORM
745 slapi_modify_internal(
748 LDAPControl **controls,
753 pb = slapi_pblock_new();
755 slapi_modify_internal_set_pb( pb, ldn, mods, controls, NULL, NULL,
756 log_change ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
758 slapi_modify_internal_pb( pb );
764 slapi_add_internal_set_pb( Slapi_PBlock *pb,
767 LDAPControl **controls,
768 Slapi_ComponentId *plugin_identity,
769 int operation_flags )
771 slapi_int_connection_init_pb( pb, LDAP_REQ_ADD );
772 slapi_pblock_set( pb, SLAPI_ADD_TARGET, (void *)dn );
773 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)attrs );
774 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
775 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
776 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
777 slapi_int_set_operation_dn( pb );
786 LDAPControl **controls,
791 pb = slapi_pblock_new();
793 slapi_add_internal_set_pb( pb, dn, attrs, controls, NULL,
794 log_changes ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
796 slapi_add_internal_pb( pb );
802 slapi_add_entry_internal_set_pb( Slapi_PBlock *pb,
804 LDAPControl **controls,
805 Slapi_ComponentId *plugin_identity,
806 int operation_flags )
808 slapi_int_connection_init_pb( pb, LDAP_REQ_ADD );
809 slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)e );
810 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
811 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
812 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
813 slapi_int_set_operation_dn( pb );
817 slapi_add_entry_internal(
819 LDAPControl **controls,
824 pb = slapi_pblock_new();
826 slapi_add_entry_internal_set_pb( pb, e, controls, NULL,
827 log_changes ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
829 slapi_add_internal_pb( pb );
835 slapi_rename_internal_set_pb( Slapi_PBlock *pb,
838 const char *newsuperior,
840 LDAPControl **controls,
841 const char *uniqueid,
842 Slapi_ComponentId *plugin_identity,
843 int operation_flags )
845 slapi_int_connection_init_pb( pb, LDAP_REQ_MODRDN );
846 slapi_pblock_set( pb, SLAPI_MODRDN_TARGET, (void *)olddn );
847 slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)newrdn );
848 slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR, (void *)newsuperior );
849 slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)deloldrdn );
850 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
851 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
852 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
853 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
854 slapi_int_set_operation_dn( pb );
857 /* Function : slapi_modrdn_internal
859 * Description : Plugin functions call this routine to modify the rdn
860 * of an entry in the backend directly
861 * Return values : LDAP_SUCCESS
865 * LDAP_UNWILLING_TO_PERFORM
867 * NOTE: This function does not support the "newSuperior" option from LDAP V3.
870 slapi_modrdn_internal(
874 LDAPControl **controls,
879 pb = slapi_pblock_new ();
881 slapi_rename_internal_set_pb( pb, olddn, lnewrdn, NULL,
882 deloldrdn, controls, NULL, NULL,
883 log_change ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
885 slapi_modrdn_internal_pb( pb );
891 slapi_delete_internal_set_pb( Slapi_PBlock *pb,
893 LDAPControl **controls,
894 const char *uniqueid,
895 Slapi_ComponentId *plugin_identity,
896 int operation_flags )
898 slapi_int_connection_init_pb( pb, LDAP_REQ_DELETE );
899 slapi_pblock_set( pb, SLAPI_TARGET_DN, (void *)dn );
900 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
901 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
902 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
903 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
904 slapi_int_set_operation_dn( pb );
907 /* Function : slapi_delete_internal
909 * Description : Plugin functions call this routine to delete an entry
910 * in the backend directly
911 * Return values : LDAP_SUCCESS
915 * LDAP_UNWILLING_TO_PERFORM
918 slapi_delete_internal(
920 LDAPControl **controls,
925 pb = slapi_pblock_new();
927 slapi_delete_internal_set_pb( pb, ldn, controls, NULL, NULL,
928 log_change ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
930 slapi_delete_internal_pb( pb );
935 #endif /* LDAP_SLAPI */