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>
35 * use a fake listener when faking a connection,
36 * so it can be used in ACLs
38 static struct slap_listener slap_unknown_listener = {
39 BER_BVC("unknown"), /* FIXME: use a URI form? (e.g. slapi://) */
44 slapi_int_send_ldap_result_shim(
48 LDAPControl **controls = NULL;
50 plugin_result_callback prc = NULL;
51 void *callback_data = NULL;
52 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
56 slapi_pblock_get( pb, SLAPI_RESCONTROLS, (void **)&controls );
57 slapi_pblock_get( pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void **)&prc );
58 slapi_pblock_get( pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
60 assert( controls == NULL );
62 /* Copy these before they go out of scope */
63 if ( rs->sr_ctrls != NULL ) {
64 for ( i = 0; rs->sr_ctrls[i] != NULL; i++ )
67 controls = (LDAPControl **)slapi_ch_calloc( i + 1,
68 sizeof(LDAPControl ));
70 for ( i = 0; rs->sr_ctrls[i] != NULL; i++ )
71 controls[i] = slapi_dup_control( rs->sr_ctrls[i] );
76 slapi_pblock_set( pb, SLAPI_RESCONTROLS, (void *)controls );
77 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs->sr_err );
80 (*prc)( rs->sr_err, callback_data );
87 slapi_int_send_search_entry_shim(
91 plugin_search_entry_callback psec = NULL;
92 void *callback_data = NULL;
93 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
97 slapi_pblock_get( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, (void **)&psec );
98 slapi_pblock_get( pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
100 if ( psec != NULL ) {
101 return (*psec)( rs->sr_entry, callback_data );
108 slapi_int_send_ldap_extended_shim(
112 assert( SLAPI_OPERATION_PBLOCK( op ) != NULL );
118 slapi_int_send_search_reference_shim(
122 int i, rc = LDAP_SUCCESS;
123 plugin_referral_entry_callback prec = NULL;
124 void *callback_data = NULL;
125 Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
127 assert( pb != NULL );
129 slapi_pblock_get( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, (void **)&prec );
130 slapi_pblock_get( pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
132 if ( prec != NULL ) {
133 for ( i = 0; rs->sr_ref[i].bv_val != NULL; i++ ) {
134 rc = (*prec)( rs->sr_ref[i].bv_val, callback_data );
135 if ( rc != LDAP_SUCCESS ) {
145 slapi_int_get_ctrls( Operation *op, SlapReply *rs, LDAPControl **controls )
150 op->o_ctrls = controls;
151 if ( op->o_ctrls == NULL ) {
155 for ( c = op->o_ctrls; *c != NULL; c++ ) {
156 rc = slap_parse_ctrl( op, rs, *c, &rs->sr_text );
157 if ( rc != LDAP_SUCCESS )
165 * To allow plugins to forward frontend requests to internal operations,
166 * the internal operation and connection structures should import as
167 * much state as practicable from the supplied parameter block.
171 * Select the backend to be used for an internal operation, either
172 * from the operation target DN or from the parameter block.
175 slapi_int_pblock_get_backend( Slapi_PBlock *pb, Operation *op )
177 int manageDsaIt = 0, isCritical;
178 LDAPControl **controls = NULL;
181 slapi_pblock_get( pb, SLAPI_REQCONTROLS, (void **)&controls );
183 slapi_pblock_get( pb, SLAPI_MANAGEDSAIT, (void **)&manageDsaIt );
184 if ( manageDsaIt != 0 )
185 manageDsaIt = SLAP_CONTROL_CRITICAL;
186 else if ( slapi_control_present( controls, SLAPI_CONTROL_MANAGEDSAIT_OID,
188 manageDsaIt = isCritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL;
190 /* let caller force a specific backend */
191 slapi_pblock_get( pb, SLAPI_BACKEND, (void **)&op->o_bd );
192 if ( op->o_bd == NULL ) {
193 op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 1 );
194 if ( op->o_bd == NULL ) {
195 if ( op->o_tag == LDAP_REQ_SEARCH && manageDsaIt > SLAP_CONTROL_NONE )
196 rc = LDAP_NO_SUCH_OBJECT;
198 rc = LDAP_PARTIAL_RESULTS;
202 if ( op->o_bd != NULL ) {
210 slapi_int_pblock_get_connection( Slapi_PBlock *pb, Operation *op )
213 Connection *conn = op->o_conn;
215 slapi_pblock_get( pb, SLAPI_X_CONN_SSF, (void **)&conn->c_ssf );
216 slapi_pblock_get( pb, SLAPI_X_CONN_SASL_CONTEXT, (void **)&conn->c_sasl_authctx );
218 if ( slapi_pblock_get( pb, SLAPI_CONN_DN, (void **)&connDn ) != 0
221 /* default to operation DN */
222 conn->c_ndn = op->o_ndn;
223 conn->c_dn = op->o_ndn;
226 /* NB: conn DN must be normalized */
227 ber_str2bv( connDn, 0, 0, &conn->c_ndn );
228 conn->c_dn = conn->c_ndn;
235 slapi_int_pblock_get_operation( Slapi_PBlock *pb, Operation *op, SlapReply *rs )
239 char *requestorDn = NULL;
240 struct berval targetDn = BER_BVNULL;
241 LDAPControl **controls;
244 /* All internal operations must specify a target DN */
245 if ( slapi_pblock_get( pb, SLAPI_TARGET_DN, (void **)&targetDn.bv_val ) != 0
246 || targetDn.bv_val == NULL )
248 return LDAP_PARAM_ERROR;
251 targetDn.bv_len = strlen( targetDn.bv_val );
253 rc = dnPrettyNormal( NULL, &targetDn, &op->o_req_dn, &op->o_req_ndn, NULL );
254 if ( rc != LDAP_SUCCESS ) {
258 rc = slapi_int_pblock_get_backend( pb, op );
259 if ( rc != LDAP_SUCCESS ) {
263 slapi_pblock_get( pb, SLAPI_REQUESTOR_ISROOT, (void **)&isRoot );
264 slapi_pblock_get( pb, SLAPI_REQUESTOR_ISUPDATEDN, (void **)&isUpdateDn );
265 /* NB: requestor DN must be normalized */
266 slapi_pblock_get( pb, SLAPI_REQUESTOR_DN, (void **)&requestorDn );
268 /* Default authorization identity for internal operations is root DN */
269 if ( isRoot || requestorDn == NULL ) {
270 op->o_dn = op->o_bd->be_rootdn;
271 op->o_ndn = op->o_bd->be_rootndn;
274 ber_str2bv( requestorDn, 0, 0, &op->o_ndn );
275 op->o_dn = op->o_ndn;
279 slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, (void *)isRoot );
281 rc = slapi_int_pblock_get_connection( pb, op );
282 if ( rc != LDAP_SUCCESS ) {
286 slapi_pblock_get( pb, SLAPI_REQCONTROLS, (void **)&controls );
287 rc = slapi_int_get_ctrls( op, rs, controls );
288 if ( rc != LDAP_SUCCESS ) {
296 slapi_int_connection_init( Slapi_PBlock *pb,
303 ber_len_t max = sockbuf_max_incoming;
306 conn = (Connection *) slapi_ch_calloc(1, sizeof(Connection));
308 LDAP_STAILQ_INIT( &conn->c_pending_ops );
310 op = (Operation *) slapi_ch_calloc( 1, OPERATION_BUFFER_SIZE );
311 op->o_hdr = (Opheader *)(op + 1);
312 op->o_hdr->oh_extensions = NULL;
314 op->o_callback = (slap_callback *) slapi_ch_calloc( 1, sizeof(slap_callback) );
315 op->o_callback->sc_response = NULL;
316 op->o_callback->sc_cleanup = NULL;
317 op->o_callback->sc_private = pb;
318 op->o_callback->sc_next = NULL;
320 op->o_controls = (void **)(op->o_hdr + 1);
322 conn->c_pending_ops.stqh_first = op;
324 /* connection object authorization information */
325 conn->c_authtype = LDAP_AUTH_NONE;
326 BER_BVZERO( &conn->c_authmech );
327 BER_BVZERO( &conn->c_dn );
328 BER_BVZERO( &conn->c_ndn );
330 conn->c_listener = &slap_unknown_listener;
331 ber_dupbv( &conn->c_peer_domain, (struct berval *)&slap_unknown_bv );
332 ber_dupbv( &conn->c_peer_name, (struct berval *)&slap_unknown_bv );
334 LDAP_STAILQ_INIT( &conn->c_ops );
336 BER_BVZERO( &conn->c_sasl_bind_mech );
337 conn->c_sasl_authctx = NULL;
338 conn->c_sasl_sockctx = NULL;
339 conn->c_sasl_extra = NULL;
341 conn->c_sb = ber_sockbuf_alloc( );
343 ber_sockbuf_ctrl( conn->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max );
345 conn->c_currentber = NULL;
347 /* should check status of thread calls */
348 ldap_pvt_thread_mutex_init( &conn->c_mutex );
349 ldap_pvt_thread_mutex_init( &conn->c_write_mutex );
350 ldap_pvt_thread_cond_init( &conn->c_write_cv );
352 ldap_pvt_thread_mutex_lock( &conn->c_mutex );
354 conn->c_n_ops_received = 0;
355 conn->c_n_ops_executing = 0;
356 conn->c_n_ops_pending = 0;
357 conn->c_n_ops_completed = 0;
363 conn->c_protocol = LDAP_VERSION3;
365 conn->c_activitytime = conn->c_starttime = slap_get_time();
368 * A real connection ID is required, because syncrepl associates
369 * pending CSNs with unique ( connection, operation ) tuples.
370 * Setting a fake connection ID will cause slap_get_commit_csn()
371 * to return a stale value.
373 connection_assign_nextid( conn );
375 conn->c_conn_state = 0x01; /* SLAP_C_ACTIVE */
376 conn->c_struct_state = 0x02; /* SLAP_C_USED */
378 conn->c_ssf = conn->c_transport_ssf = 0;
381 backend_connection_init( conn );
383 conn->c_send_ldap_result = slapi_int_send_ldap_result_shim;
384 conn->c_send_search_entry = slapi_int_send_search_entry_shim;
385 conn->c_send_ldap_extended = slapi_int_send_ldap_extended_shim;
386 conn->c_send_search_reference = slapi_int_send_search_reference_shim;
388 /* operation object */
390 op->o_protocol = LDAP_VERSION3;
391 BER_BVZERO( &op->o_authmech );
392 op->o_time = slap_get_time();
393 op->o_do_not_cache = 1;
394 op->o_threadctx = ldap_pvt_thread_pool_context();
395 op->o_tmpmemctx = NULL;
396 op->o_tmpmfuncs = &ch_mfuncs;
398 op->o_connid = conn->c_connid;
400 rc = slapi_int_pblock_get_operation( pb, op, rs );
402 slapi_pblock_set( pb, SLAPI_OPERATION, op );
403 slapi_pblock_set( pb, SLAPI_CONNECTION, conn );
405 ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
407 if ( rc != LDAP_SUCCESS ) {
408 slapi_int_connection_destroy( &conn );
417 void slapi_int_connection_destroy( Connection **pConn )
419 Connection *conn = *pConn;
423 if ( conn == NULL ) {
427 op = (Operation *)conn->c_pending_ops.stqh_first;
428 pb = SLAPI_OPERATION_PBLOCK( op );
430 slap_graduate_commit_csn( op );
432 if ( op->o_req_dn.bv_val != NULL ) {
433 slapi_ch_free( (void **)&op->o_req_dn.bv_val );
435 if ( op->o_req_ndn.bv_val != NULL ) {
436 slapi_ch_free( (void **)&op->o_req_ndn.bv_val );
438 if ( op->o_callback != NULL ) {
439 slapi_ch_free( (void **)&op->o_callback );
441 if ( conn->c_sb != NULL ) {
442 ber_sockbuf_free( conn->c_sb );
445 slapi_pblock_set( pb, SLAPI_OPERATION, NULL );
446 slapi_pblock_set( pb, SLAPI_CONNECTION, NULL );
449 slapi_ch_free( (void **)&op );
452 slapi_ch_free( (void **)pConn );
456 * Function : values2obj
457 * Convert an array of strings into a BerVarray.
468 if ( ppValue == NULL ) {
473 for ( i = 0; ppValue[i] != NULL; i++ )
476 tmpberval = (BerVarray)slapi_ch_malloc( (i+1) * (sizeof(struct berval)) );
477 if ( tmpberval == NULL ) {
478 return LDAP_NO_MEMORY;
480 for ( i = 0; ppValue[i] != NULL; i++ ) {
481 size_t len = strlen( ppValue[i] );
483 tmpberval[i].bv_val = slapi_ch_malloc( len + 1 );
484 AC_MEMCPY( tmpberval[i].bv_val, ppValue[i], len + 1 );
485 tmpberval[i].bv_len = len;
487 tmpberval[i].bv_val = NULL;
488 tmpberval[i].bv_len = 0;
497 struct berval **bvptr,
503 if ( bvptr == NULL ) {
508 for ( i = 0; bvptr[i] != NULL; i++ )
511 tmpberval = (BerVarray)slapi_ch_malloc( (i + 1) * sizeof(struct berval));
512 if ( tmpberval == NULL ) {
513 return LDAP_NO_MEMORY;
516 for ( i = 0; bvptr[i] != NULL; i++ ) {
517 tmpberval[i].bv_val = slapi_ch_malloc( bvptr[i]->bv_len );
518 tmpberval[i].bv_len = bvptr[i]->bv_len;
519 AC_MEMCPY( tmpberval[i].bv_val, bvptr[i]->bv_val, bvptr[i]->bv_len );
522 tmpberval[i].bv_val = NULL;
523 tmpberval[i].bv_len = 0;
531 * Function : slapi_int_ldapmod_to_entry
532 * convert a dn plus an array of LDAPMod struct ptrs to an entry structure
533 * with a link list of the correspondent attributes.
534 * Return value : LDAP_SUCCESS
539 slapi_int_ldapmod_to_entry(
544 struct berval dn = BER_BVNULL;
550 Modifications *modlist = NULL;
551 Modifications **modtail = &modlist;
554 int rc = LDAP_SUCCESS;
557 const char *text = NULL;
559 op = (Operation *)pConn->c_pending_ops.stqh_first;
561 pEntry = (Entry *) ch_calloc( 1, sizeof(Entry) );
562 if ( pEntry == NULL) {
568 dn.bv_len = strlen( ldn );
570 rc = dnPrettyNormal( NULL, &dn, &pEntry->e_name, &pEntry->e_nname, NULL );
571 if ( rc != LDAP_SUCCESS ) {
575 if ( rc == LDAP_SUCCESS ) {
576 for ( i = 0, pMod = mods[0]; rc == LDAP_SUCCESS && pMod != NULL; pMod = mods[++i]) {
579 if ( (pMod->mod_op & LDAP_MOD_BVALUES) != 0 ) {
581 * Convert an array of pointers to bervals to
582 * an array of bervals. Note that we need to copy the
583 * values too, as the slap_mods_check() will free the
584 * original values after prettying; the modifications
585 * being passed in may not have been allocated on the
588 rc = bvptr2obj_copy( pMod->mod_bvalues, &bv );
589 if ( rc != LDAP_SUCCESS ) goto cleanup;
590 tmp.sml_type.bv_val = pMod->mod_type;
591 tmp.sml_type.bv_len = strlen( pMod->mod_type );
593 tmp.sml_nvalues = NULL;
595 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
597 mod->sml_op = LDAP_MOD_ADD;
599 mod->sml_next = NULL;
600 mod->sml_desc = NULL;
601 mod->sml_type = tmp.sml_type;
602 mod->sml_values = tmp.sml_values;
603 mod->sml_nvalues = tmp.sml_nvalues;
606 modtail = &mod->sml_next;
609 /* attr values are in string format, need to be converted */
610 /* to an array of bervals */
611 if ( pMod->mod_values == NULL ) {
614 rc = values2obj_copy( pMod->mod_values, &bv );
615 if ( rc != LDAP_SUCCESS ) goto cleanup;
616 tmp.sml_type.bv_val = pMod->mod_type;
617 tmp.sml_type.bv_len = strlen( pMod->mod_type );
619 tmp.sml_nvalues = NULL;
621 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
623 mod->sml_op = LDAP_MOD_ADD;
625 mod->sml_next = NULL;
626 mod->sml_desc = NULL;
627 mod->sml_type = tmp.sml_type;
628 mod->sml_values = tmp.sml_values;
629 mod->sml_nvalues = tmp.sml_nvalues;
632 modtail = &mod->sml_next;
635 } /* for each LDAPMod */
638 op->o_bd = select_backend( &pEntry->e_nname, 0, 0 );
639 if ( op->o_bd == NULL ) {
640 rc = LDAP_PARTIAL_RESULTS;
642 int repl_user = be_isupdate_dn( op->o_bd, &op->o_bd->be_rootdn );
643 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
644 int update = !BER_BVISNULL( &op->o_bd->be_update_ndn );
645 char textbuf[ SLAP_TEXT_BUFLEN ];
646 size_t textlen = sizeof( textbuf );
648 rc = slap_mods_check( modlist, &text,
649 textbuf, textlen, NULL );
651 if ( rc != LDAP_SUCCESS) {
656 rc = slap_mods_no_user_mod_check( op, modlist,
657 &text, textbuf, textlen );
658 if ( rc != LDAP_SUCCESS) {
664 rc = slap_mods_opattrs( op, modlist, modtail,
665 &text, textbuf, textlen, 1 );
666 if ( rc != LDAP_SUCCESS) {
671 rc = slap_mods2entry( modlist, &pEntry, repl_user,
672 0, &text, textbuf, textlen );
673 if (rc != LDAP_SUCCESS) {
683 if ( modlist != NULL )
684 slap_mods_free( modlist );
685 if ( rc != LDAP_SUCCESS ) {
686 if ( pEntry != NULL ) {
687 slapi_entry_free( pEntry );
696 slapi_delete_internal_pb( Slapi_PBlock *pb )
699 Connection *conn = NULL;
700 Operation *op = NULL;
701 int operation_flags = 0;
703 SlapReply rs = { REP_RESULT };
709 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, &operation_flags );
711 rs.sr_err = slapi_int_connection_init( pb, &rs, LDAP_REQ_DELETE, &conn );
712 if ( rs.sr_err != LDAP_SUCCESS ) {
716 op = conn->c_pending_ops.stqh_first;
718 if ( op->o_bd->be_delete != NULL ) {
719 int repl_user = be_isupdate( op );
720 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
721 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
722 if ( operation_flags & SLAPI_OP_FLAG_LOG_CHANGE )
723 op->o_callback = &cb;
725 op->o_bd->be_delete( op, &rs );
727 rs.sr_err = LDAP_REFERRAL;
730 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
734 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
735 slapi_int_connection_destroy( &conn );
740 #endif /* LDAP_SLAPI */
744 slapi_add_internal_pb( Slapi_PBlock *pb )
747 Connection *conn = NULL;
748 Slapi_Entry *entry = NULL;
749 Slapi_Entry *argEntry = NULL;
751 LDAPMod **mods = NULL;
752 int operation_flags = 0;
753 Operation *op = NULL;
756 SlapReply rs = { REP_RESULT };
762 slapi_pblock_get( pb, SLAPI_ADD_ENTRY, (void **)&argEntry );
763 slapi_pblock_get( pb, SLAPI_ADD_TARGET, (void **)&dn );
764 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&mods );
765 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, (void **)&operation_flags );
767 if ( argEntry != NULL ) {
769 * The caller can specify a new entry, or a target DN and set
770 * of modifications, but not both.
773 rs.sr_err = LDAP_PARAM_ERROR;
778 * Set the DN here so that slapi_int_init_backend() will select
781 dn = slapi_entry_get_dn( argEntry );
782 slapi_pblock_set( pb, SLAPI_ADD_TARGET, &entry->e_nname.bv_val );
785 rs.sr_err = slapi_int_connection_init( pb, &rs, LDAP_REQ_ADD, &conn );
786 if ( rs.sr_err != LDAP_SUCCESS ) {
790 if ( argEntry != NULL ) {
791 entry = slapi_entry_dup( argEntry );
793 if ( mods == NULL || dn == NULL ) {
794 rs.sr_err = LDAP_PARAM_ERROR;
798 for ( i = 0; mods[i] != NULL; i++ ) {
799 if ( (mods[i]->mod_op & LDAP_MOD_OP ) != LDAP_MOD_ADD ) {
800 rs.sr_err = LDAP_PARAM_ERROR;
805 entry = slapi_int_ldapmod_to_entry( conn, dn, mods );
806 if ( entry == NULL ) {
807 rs.sr_err = LDAP_OTHER;
812 op = (Operation *)conn->c_pending_ops.stqh_first;
813 op->oq_add.rs_e = entry;
815 if ( op->o_bd->be_add != NULL ) {
816 int repl_user = be_isupdate( op );
817 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
818 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
820 if ( operation_flags & SLAPI_OP_FLAG_LOG_CHANGE )
821 op->o_callback = &cb;
823 if ( op->o_bd->be_add( op, &rs ) == LDAP_SUCCESS ) {
824 be_entry_release_w( op, entry );
828 rs.sr_err = LDAP_REFERRAL;
831 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
835 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
837 if ( entry != NULL ) {
838 slapi_entry_free( entry );
840 if ( argEntry != NULL ) {
841 slapi_pblock_set( pb, SLAPI_ADD_TARGET, NULL );
844 slapi_int_connection_destroy( &conn );
849 #endif /* LDAP_SLAPI */
853 slapi_modrdn_internal_pb( Slapi_PBlock *pb )
856 struct berval dn = BER_BVNULL;
857 struct berval newrdn = BER_BVNULL;
858 struct berval newsupdn = BER_BVNULL;
859 struct berval newSuperiorPretty = BER_BVNULL;
860 struct berval newSuperiorNormalized = BER_BVNULL;
861 Connection *conn = NULL;
862 Operation *op = NULL;
863 int manageDsaIt = SLAP_CONTROL_NONE;
871 SlapReply rs = { REP_RESULT };
877 slapi_pblock_get( pb, SLAPI_MODRDN_NEWRDN, (void **)&lnewrdn );
878 slapi_pblock_get( pb, SLAPI_MODRDN_NEWSUPERIOR, (void **)&newsuperior );
879 slapi_pblock_get( pb, SLAPI_MODRDN_DELOLDRDN, (void **)&deloldrdn );
880 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, (void **)&operation_flags );
882 rs.sr_err = slapi_int_connection_init( pb, &rs, LDAP_REQ_MODRDN, &conn );
883 if ( rs.sr_err != LDAP_SUCCESS ) {
887 op = (Operation *)conn->c_pending_ops.stqh_first;
889 if ( op->o_req_dn.bv_len == 0 ) {
890 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
894 newrdn.bv_val = lnewrdn;
895 newrdn.bv_len = strlen( lnewrdn );
897 rs.sr_err = dnPrettyNormal( NULL, &newrdn, &op->oq_modrdn.rs_newrdn, &op->oq_modrdn.rs_nnewrdn, NULL );
898 if ( rs.sr_err != LDAP_SUCCESS ) {
902 if ( rdn_validate( &op->oq_modrdn.rs_nnewrdn ) != LDAP_SUCCESS ) {
906 if ( newsuperior != NULL ) {
907 newsupdn.bv_val = (char *)newsuperior;
908 newsupdn.bv_len = strlen( newsuperior );
910 rs.sr_err = dnPrettyNormal( NULL, &newsupdn, &newSuperiorPretty, &newSuperiorNormalized, NULL );
911 if ( rs.sr_err != LDAP_SUCCESS )
914 op->oq_modrdn.rs_newSup = &newSuperiorPretty;
915 op->oq_modrdn.rs_nnewSup = &newSuperiorNormalized;
917 op->oq_modrdn.rs_newSup = NULL;
918 op->oq_modrdn.rs_nnewSup = NULL;
921 op->oq_modrdn.rs_deleteoldrdn = deloldrdn;
923 if ( op->o_bd->be_modrdn != NULL ) {
924 int repl_user = be_isupdate( op );
925 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
926 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
928 if ( operation_flags & SLAPI_OP_FLAG_LOG_CHANGE )
929 op->o_callback = &cb;
931 op->o_bd->be_modrdn( op, &rs );
933 rs.sr_err = LDAP_REFERRAL;
936 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
940 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
942 if ( op->oq_modrdn.rs_newrdn.bv_val != NULL )
943 slapi_ch_free_string( &op->oq_modrdn.rs_newrdn.bv_val );
944 if ( op->oq_modrdn.rs_nnewrdn.bv_val != NULL )
945 slapi_ch_free_string( &op->oq_modrdn.rs_nnewrdn.bv_val );
946 if ( newSuperiorPretty.bv_val != NULL )
947 slapi_ch_free_string( &newSuperiorPretty.bv_val );
948 if ( newSuperiorNormalized.bv_val != NULL )
949 slapi_ch_free_string( &newSuperiorNormalized.bv_val );
951 slapi_int_connection_destroy( &conn );
956 #endif /* LDAP_SLAPI */
959 int slapi_modify_internal_pb( Slapi_PBlock *pb )
963 Connection *conn = NULL;
964 Operation *op = NULL;
966 struct berval dn = BER_BVNULL;
968 int manageDsaIt = SLAP_CONTROL_NONE;
973 Modifications *modlist = NULL;
974 Modifications **modtail = &modlist;
977 LDAPMod **mods = NULL;
978 int operation_flags = 0;
980 SlapReply rs = { REP_RESULT };
986 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&mods );
987 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, (void **)&operation_flags );
989 if ( mods == NULL || mods[0] == NULL ) {
990 rs.sr_err = LDAP_PARAM_ERROR ;
994 rs.sr_err = slapi_int_connection_init( pb, &rs, LDAP_REQ_MODIFY, &conn );
995 if ( rs.sr_err != LDAP_SUCCESS ) {
999 for ( i = 0, pMod = mods[0];
1000 rs.sr_err == LDAP_SUCCESS && pMod != NULL;
1005 if ( (pMod->mod_op & LDAP_MOD_BVALUES) != 0 ) {
1007 * attr values are in berval format
1008 * convert an array of pointers to bervals
1009 * to an array of bervals
1011 rs.sr_err = bvptr2obj_copy( pMod->mod_bvalues, &bv );
1012 if ( rs.sr_err != LDAP_SUCCESS )
1014 tmp.sml_type.bv_val = pMod->mod_type;
1015 tmp.sml_type.bv_len = strlen( pMod->mod_type );
1016 tmp.sml_values = bv;
1017 tmp.sml_nvalues = NULL;
1019 mod = (Modifications *)ch_malloc( sizeof(Modifications) );
1021 mod->sml_op = pMod->mod_op & LDAP_MOD_OP;
1023 mod->sml_next = NULL;
1024 mod->sml_desc = NULL;
1025 mod->sml_type = tmp.sml_type;
1026 mod->sml_values = tmp.sml_values;
1027 mod->sml_nvalues = tmp.sml_nvalues;
1029 rs.sr_err = values2obj_copy( pMod->mod_values, &bv );
1030 if ( rs.sr_err != LDAP_SUCCESS )
1032 tmp.sml_type.bv_val = pMod->mod_type;
1033 tmp.sml_type.bv_len = strlen( pMod->mod_type );
1034 tmp.sml_values = bv;
1035 tmp.sml_nvalues = NULL;
1037 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
1039 mod->sml_op = pMod->mod_op & LDAP_MOD_OP;
1041 mod->sml_next = NULL;
1042 mod->sml_desc = NULL;
1043 mod->sml_type = tmp.sml_type;
1044 mod->sml_values = tmp.sml_values;
1045 mod->sml_nvalues = tmp.sml_nvalues;
1048 modtail = &mod->sml_next;
1050 switch( pMod->mod_op & LDAP_MOD_OP ) {
1052 if ( mod->sml_values == NULL ) {
1053 rs.sr_err = LDAP_PROTOCOL_ERROR;
1058 case LDAP_MOD_DELETE:
1059 case LDAP_MOD_REPLACE:
1060 case LDAP_MOD_INCREMENT:
1064 rs.sr_err = LDAP_PROTOCOL_ERROR;
1070 op = (Operation *)conn->c_pending_ops.stqh_first;
1072 if ( op->o_req_ndn.bv_len == 0 ) {
1073 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
1077 op->oq_modify.rs_modlist = modlist;
1079 if ( op->o_bd->be_modify != NULL ) {
1080 int repl_user = be_isupdate( op );
1081 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
1082 int update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn );
1083 const char *text = NULL;
1084 char textbuf[ SLAP_TEXT_BUFLEN ];
1085 size_t textlen = sizeof( textbuf );
1086 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
1088 rs.sr_err = slap_mods_check( modlist,
1089 &text, textbuf, textlen, NULL );
1090 if ( rs.sr_err != LDAP_SUCCESS ) {
1095 rs.sr_err = slap_mods_no_user_mod_check( op, modlist,
1096 &text, textbuf, textlen );
1097 if ( rs.sr_err != LDAP_SUCCESS ) {
1103 rs.sr_err = slap_mods_opattrs( op, modlist,
1104 modtail, &text, textbuf,
1106 if ( rs.sr_err != LDAP_SUCCESS ) {
1111 if ( operation_flags & SLAPI_OP_FLAG_LOG_CHANGE )
1112 op->o_callback = &cb;
1114 op->o_bd->be_modify( op, &rs );
1116 rs.sr_err = LDAP_REFERRAL;
1119 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
1123 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
1125 if ( modlist != NULL )
1126 slap_mods_free( modlist );
1128 slapi_int_connection_destroy( &conn );
1133 #endif /* LDAP_SLAPI */
1138 slapi_int_search_entry_callback( Slapi_Entry *entry, void *callback_data )
1140 int nentries = 0, i = 0;
1141 Slapi_Entry **head = NULL, **tp;
1142 Slapi_PBlock *pb = (Slapi_PBlock *)callback_data;
1144 entry = slapi_entry_dup( entry );
1145 if ( entry == NULL ) {
1149 slapi_pblock_get( pb, SLAPI_NENTRIES, &nentries );
1150 slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &head );
1153 if ( nentries == 0 ) {
1154 tp = (Slapi_Entry **)slapi_ch_malloc( 2 * sizeof(Slapi_Entry *) );
1156 slapi_entry_free( entry );
1162 tp = (Slapi_Entry **)slapi_ch_realloc( (char *)head,
1163 sizeof(Slapi_Entry *) * ( i + 1 ) );
1165 slapi_entry_free( entry );
1168 tp[ i - 1 ] = entry;
1172 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, (void *)tp );
1173 slapi_pblock_set( pb, SLAPI_NENTRIES, (void *)i );
1175 return LDAP_SUCCESS;
1177 #endif /* LDAP_SLAPI */
1179 int slapi_search_internal_pb( Slapi_PBlock *pb )
1182 return slapi_search_internal_callback_pb( pb,
1185 slapi_int_search_entry_callback,
1192 int slapi_search_internal_callback_pb( Slapi_PBlock *pb,
1193 void *callback_data,
1194 plugin_result_callback prc,
1195 plugin_search_entry_callback psec,
1196 plugin_referral_entry_callback prec )
1199 Connection *conn = NULL;
1200 Operation *op = NULL;
1201 struct berval dn = BER_BVNULL;
1202 Filter *filter = NULL;
1203 struct berval fstr = BER_BVNULL;
1204 AttributeName *an = NULL;
1205 const char *text = NULL;
1207 int manageDsaIt = SLAP_CONTROL_NONE;
1211 int scope = LDAP_SCOPE_BASE;
1212 char *filStr = NULL;
1213 LDAPControl **controls = NULL;
1214 char **attrs = NULL;
1215 char *uniqueid = NULL;
1217 int operation_flags = 0;
1220 SlapReply rs = { REP_RESULT };
1226 slapi_pblock_get( pb, SLAPI_SEARCH_SCOPE, (void **)&scope );
1227 slapi_pblock_get( pb, SLAPI_SEARCH_FILTER, (void **)&filter );
1228 slapi_pblock_get( pb, SLAPI_SEARCH_STRFILTER, (void **)&filStr );
1229 slapi_pblock_get( pb, SLAPI_SEARCH_ATTRS, (void **)&attrs );
1230 slapi_pblock_get( pb, SLAPI_SEARCH_ATTRSONLY, (void **)&attrsonly );
1231 slapi_pblock_get( pb, SLAPI_REQCONTROLS, (void **)&controls );
1232 slapi_pblock_get( pb, SLAPI_TARGET_UNIQUEID, (void **)&uniqueid );
1233 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, (void **)&operation_flags );
1235 rs.sr_err = slapi_int_connection_init( pb, &rs, LDAP_REQ_SEARCH, &conn );
1236 if ( rs.sr_err != LDAP_SUCCESS ) {
1240 /* search callback and arguments */
1241 slapi_pblock_set( pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void *)prc );
1242 slapi_pblock_set( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, (void *)psec );
1243 slapi_pblock_set( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, (void *)prec );
1244 slapi_pblock_set( pb, SLAPI_X_INTOP_CALLBACK_DATA, (void *)callback_data );
1246 op = (Operation *)conn->c_pending_ops.stqh_first;
1249 case LDAP_SCOPE_BASE:
1250 case LDAP_SCOPE_ONELEVEL:
1251 case LDAP_SCOPE_SUBTREE:
1252 #ifdef LDAP_SCOPE_SUBORDINATE
1253 case LDAP_SCOPE_SUBORDINATE:
1257 rs.sr_err = LDAP_PROTOCOL_ERROR;
1261 if ( filter == NULL ) {
1262 if ( filStr == NULL ) {
1263 rs.sr_err = LDAP_PARAM_ERROR;
1267 filter = slapi_str2filter( filStr );
1268 if ( filter == NULL ) {
1269 rs.sr_err = LDAP_PROTOCOL_ERROR;
1276 filter2bv( filter, &fstr );
1278 for ( i = 0; attrs != NULL && attrs[i] != NULL; i++ ) {
1279 ; /* count the number of attributes */
1283 an = (AttributeName *)slapi_ch_calloc( (i + 1), sizeof(AttributeName) );
1284 for (i = 0; attrs[i] != 0; i++) {
1285 an[i].an_desc = NULL;
1287 an[i].an_oc_exclude = 0;
1288 an[i].an_name.bv_val = slapi_ch_strdup(attrs[i]);
1289 an[i].an_name.bv_len = strlen(attrs[i]);
1290 slap_bv2ad( &an[i].an_name, &an[i].an_desc, &text );
1292 an[i].an_name.bv_val = NULL;
1295 rs.sr_type = REP_RESULT;
1296 rs.sr_err = LDAP_SUCCESS;
1297 rs.sr_entry = NULL; /* paranoia */
1299 if ( scope == LDAP_SCOPE_BASE ) {
1302 if ( op->o_req_ndn.bv_len == 0 ) {
1303 rs.sr_err = root_dse_info( conn, &rs.sr_entry, &rs.sr_text );
1306 if( rs.sr_err != LDAP_SUCCESS ) {
1307 send_ldap_result( op, &rs );
1309 } else if ( rs.sr_entry != NULL ) {
1310 rs.sr_err = test_filter( op, rs.sr_entry, filter );
1312 if ( rs.sr_err == LDAP_COMPARE_TRUE ) {
1313 rs.sr_type = REP_SEARCH;
1314 rs.sr_err = LDAP_SUCCESS;
1316 rs.sr_operational_attrs = NULL;
1317 rs.sr_flags = REP_ENTRY_MODIFIABLE;
1319 send_search_entry( op, &rs );
1322 entry_free( rs.sr_entry );
1324 rs.sr_type = REP_RESULT;
1325 rs.sr_err = LDAP_SUCCESS;
1327 send_ldap_result( op, &rs );
1333 op->oq_search.rs_scope = scope;
1334 op->oq_search.rs_deref = 0;
1335 op->oq_search.rs_slimit = SLAP_NO_LIMIT;
1336 op->oq_search.rs_tlimit = SLAP_NO_LIMIT;
1337 op->oq_search.rs_attrsonly = attrsonly;
1338 op->oq_search.rs_attrs = an;
1339 op->oq_search.rs_filter = filter;
1340 op->oq_search.rs_filterstr = fstr;
1342 if ( BER_BVISEMPTY( &op->o_req_ndn ) &&
1343 !BER_BVISEMPTY( &default_search_nbase ) ) {
1344 slapi_ch_free( (void **)&op->o_req_dn.bv_val );
1345 slapi_ch_free( (void **)&op->o_req_ndn.bv_val );
1347 ber_dupbv( &op->o_req_dn, &default_search_base );
1348 ber_dupbv( &op->o_req_ndn, &default_search_nbase );
1350 rs.sr_err = slapi_int_pblock_get_backend( pb, op );
1351 if ( rs.sr_err != LDAP_SUCCESS )
1355 if ( op->o_bd->be_search != NULL ) {
1356 (*op->o_bd->be_search)( op, &rs );
1358 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
1362 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
1363 slapi_pblock_set( pb, SLAPI_X_INTOP_RESULT_CALLBACK, NULL );
1364 slapi_pblock_set( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, NULL );
1365 slapi_pblock_set( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, NULL );
1366 slapi_pblock_set( pb, SLAPI_X_INTOP_CALLBACK_DATA, NULL );
1368 if ( freeFilter && filter != NULL )
1369 slapi_filter_free( filter, 1 );
1371 slapi_ch_free( (void **)&fstr.bv_val );
1373 slapi_ch_free( (void **)&an );
1375 slapi_int_connection_destroy( &conn );
1380 #endif /* LDAP_SLAPI */
1383 /* Wrappers for old API */
1385 void slapi_search_internal_set_pb( Slapi_PBlock *pb,
1391 LDAPControl **controls,
1392 const char *uniqueid,
1393 Slapi_ComponentId *plugin_identity,
1394 int operation_flags )
1397 slapi_pblock_set( pb, SLAPI_SEARCH_TARGET, (void *)base );
1398 slapi_pblock_set( pb, SLAPI_SEARCH_SCOPE, (void *)scope );
1399 slapi_pblock_set( pb, SLAPI_SEARCH_FILTER, NULL );
1400 slapi_pblock_set( pb, SLAPI_SEARCH_STRFILTER, (void *)filter );
1401 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRS, (void *)attrs );
1402 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRSONLY, (void *)attrsonly );
1403 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1404 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
1405 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1406 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1407 #endif /* LDAP_SLAPI */
1411 slapi_search_internal(
1415 LDAPControl **controls,
1422 pb = slapi_pblock_new();
1427 slapi_search_internal_set_pb( pb, ldn, scope, filStr, attrs, attrsonly,
1428 controls, NULL, NULL, 0 );
1430 slapi_search_internal_pb( pb );
1435 #endif /* LDAP_SLAPI */
1438 void slapi_modify_internal_set_pb( Slapi_PBlock *pb,
1441 LDAPControl **controls,
1442 const char *uniqueid,
1443 Slapi_ComponentId *plugin_identity,
1444 int operation_flags )
1447 slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn );
1448 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)mods );
1449 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1450 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
1451 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1452 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1453 #endif /* LDAP_SLAPI */
1456 /* Function : slapi_modify_internal
1458 * Description: Plugin functions call this routine to modify an entry
1459 * in the backend directly
1460 * Return values : LDAP_SUCCESS
1464 * LDAP_UNWILLING_TO_PERFORM
1467 slapi_modify_internal(
1470 LDAPControl **controls,
1476 pb = slapi_pblock_new();
1481 slapi_modify_internal_set_pb( pb, ldn, mods, controls, NULL, NULL,
1482 log_change ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1484 slapi_modify_internal_pb( pb );
1489 #endif /* LDAP_SLAPI */
1492 int slapi_add_internal_set_pb( Slapi_PBlock *pb,
1495 LDAPControl **controls,
1496 Slapi_ComponentId *plugin_identity,
1497 int operation_flags )
1500 slapi_pblock_set( pb, SLAPI_ADD_TARGET, (void *)dn );
1501 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)attrs );
1502 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1503 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1504 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1509 #endif /* LDAP_SLAPI */
1512 Slapi_PBlock *slapi_add_internal(
1515 LDAPControl **controls,
1521 pb = slapi_pblock_new();
1525 slapi_add_internal_set_pb( pb, dn, attrs, controls, NULL,
1526 log_changes ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1528 slapi_add_internal_pb( pb );
1533 #endif /* LDAP_SLAPI */
1536 void slapi_add_entry_internal_set_pb( Slapi_PBlock *pb,
1538 LDAPControl **controls,
1539 Slapi_ComponentId *plugin_identity,
1540 int operation_flags )
1543 slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)e );
1544 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1545 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1546 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1547 #endif /* LDAP_SLAPI */
1551 slapi_add_entry_internal(
1553 LDAPControl **controls,
1559 pb = slapi_pblock_new();
1563 slapi_add_entry_internal_set_pb( pb, e, controls, NULL,
1564 log_changes ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1566 slapi_add_internal_pb( pb );
1571 #endif /* LDAP_SLAPI */
1574 void slapi_rename_internal_set_pb( Slapi_PBlock *pb,
1577 const char *newsuperior,
1579 LDAPControl **controls,
1580 const char *uniqueid,
1581 Slapi_ComponentId *plugin_identity,
1582 int operation_flags )
1585 slapi_pblock_set( pb, SLAPI_MODRDN_TARGET, (void *)olddn );
1586 slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)newrdn );
1587 slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR, (void *)newsuperior );
1588 slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)deloldrdn );
1589 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1590 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
1591 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1592 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1593 #endif /* LDAP_SLAPI */
1596 /* Function : slapi_modrdn_internal
1598 * Description : Plugin functions call this routine to modify the rdn
1599 * of an entry in the backend directly
1600 * Return values : LDAP_SUCCESS
1604 * LDAP_UNWILLING_TO_PERFORM
1606 * NOTE: This function does not support the "newSuperior" option from LDAP V3.
1609 slapi_modrdn_internal(
1613 LDAPControl **controls,
1619 pb = slapi_pblock_new();
1624 slapi_rename_internal_set_pb( pb, olddn, lnewrdn, NULL,
1625 deloldrdn, controls, NULL, NULL,
1626 log_change ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1628 slapi_modrdn_internal_pb( pb );
1633 #endif /* LDAP_SLAPI */
1636 void slapi_delete_internal_set_pb( Slapi_PBlock *pb,
1638 LDAPControl **controls,
1639 const char *uniqueid,
1640 Slapi_ComponentId *plugin_identity,
1641 int operation_flags )
1644 slapi_pblock_set( pb, SLAPI_TARGET_DN, (void *)dn );
1645 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1646 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
1647 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1648 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1649 #endif /* LDAP_SLAPI */
1652 /* Function : slapi_delete_internal
1654 * Description : Plugin functions call this routine to delete an entry
1655 * in the backend directly
1656 * Return values : LDAP_SUCCESS
1660 * LDAP_UNWILLING_TO_PERFORM
1663 slapi_delete_internal(
1665 LDAPControl **controls,
1671 pb = slapi_pblock_new();
1675 slapi_delete_internal_set_pb( pb, ldn, controls, NULL, NULL,
1676 log_change ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1678 slapi_delete_internal_pb( pb );
1683 #endif /* LDAP_SLAPI */