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;
53 assert( op->o_pb != NULL );
55 slapi_pblock_get( op->o_pb, SLAPI_RESCONTROLS, (void **)&controls );
56 slapi_pblock_get( op->o_pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void **)&prc );
57 slapi_pblock_get( op->o_pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
59 assert( controls == NULL );
61 /* Copy these before they go out of scope */
62 if ( rs->sr_ctrls != NULL ) {
63 for ( i = 0; rs->sr_ctrls[i] != NULL; i++ )
66 controls = (LDAPControl **)slapi_ch_calloc( i + 1,
67 sizeof(LDAPControl ));
69 for ( i = 0; rs->sr_ctrls[i] != NULL; i++ )
70 controls[i] = slapi_dup_control( rs->sr_ctrls[i] );
75 slapi_pblock_set( op->o_pb, SLAPI_RESCONTROLS, (void *)controls );
76 slapi_pblock_set( op->o_pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs->sr_err );
79 (*prc)( rs->sr_err, callback_data );
86 slapi_int_send_search_entry_shim(
90 plugin_search_entry_callback psec = NULL;
91 void *callback_data = NULL;
93 assert( op->o_pb != NULL );
95 slapi_pblock_get( op->o_pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, &psec );
96 slapi_pblock_get( op->o_pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
99 return (*psec)( rs->sr_entry, callback_data );
106 slapi_int_send_ldap_extended_shim(
110 assert( op->o_pb != NULL );
116 slapi_int_send_search_reference_shim(
120 int i, rc = LDAP_SUCCESS;
121 plugin_referral_entry_callback prec = NULL;
122 void *callback_data = NULL;
124 assert( op->o_pb != NULL );
126 slapi_pblock_get( op->o_pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, &prec );
127 slapi_pblock_get( op->o_pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
129 if ( prec != NULL ) {
130 for ( i = 0; rs->sr_ref[i].bv_val != NULL; i++ ) {
131 rc = (*prec)( rs->sr_ref[i].bv_val, callback_data );
132 if ( rc != LDAP_SUCCESS ) {
142 slapi_int_init_connection(
148 ber_len_t max = sockbuf_max_incoming;
150 pConn = (Connection *) slapi_ch_calloc(1, sizeof(Connection));
152 LDAP_STAILQ_INIT( &pConn->c_pending_ops );
154 op = (Operation *) slapi_ch_calloc( 1, OPERATION_BUFFER_SIZE );
155 op->o_hdr = (Opheader *)(op + 1);
156 op->o_controls = (void **)(op->o_hdr + 1);
158 pConn->c_pending_ops.stqh_first = op;
159 pConn->c_pending_ops.stqh_first->o_pb = NULL;
160 pConn->c_pending_ops.stqh_first->o_extensions = NULL;
162 /* connection object */
163 pConn->c_authmech.bv_val = NULL;
164 pConn->c_authmech.bv_len = 0;
165 pConn->c_dn.bv_val = NULL;
166 pConn->c_dn.bv_len = 0;
167 pConn->c_ndn.bv_val = NULL;
168 pConn->c_ndn.bv_len = 0;
170 pConn->c_listener = &slap_unknown_listener;
171 ber_dupbv( &pConn->c_peer_domain, (struct berval *)&slap_unknown_bv );
172 ber_dupbv( &pConn->c_peer_name, (struct berval *)&slap_unknown_bv );
174 LDAP_STAILQ_INIT( &pConn->c_ops );
176 pConn->c_sasl_bind_mech.bv_val = NULL;
177 pConn->c_sasl_bind_mech.bv_len = 0;
178 pConn->c_sasl_authctx = NULL;
179 pConn->c_sasl_sockctx = NULL;
180 pConn->c_sasl_extra = NULL;
182 pConn->c_sb = ber_sockbuf_alloc( );
184 ber_sockbuf_ctrl( pConn->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max );
186 pConn->c_currentber = NULL;
188 /* should check status of thread calls */
189 ldap_pvt_thread_mutex_init( &pConn->c_mutex );
190 ldap_pvt_thread_mutex_init( &pConn->c_write_mutex );
191 ldap_pvt_thread_cond_init( &pConn->c_write_cv );
193 ldap_pvt_thread_mutex_lock( &pConn->c_mutex );
195 pConn->c_n_ops_received = 0;
196 pConn->c_n_ops_executing = 0;
197 pConn->c_n_ops_pending = 0;
198 pConn->c_n_ops_completed = 0;
202 pConn->c_n_write = 0;
204 pConn->c_protocol = LDAP_VERSION3;
206 pConn->c_activitytime = pConn->c_starttime = slap_get_time();
209 * A real connection ID is required, because syncrepl associates
210 * pending CSNs with unique ( connection, operation ) tuples.
211 * Setting a fake connection ID will cause slap_get_commit_csn()
212 * to return a stale value.
214 connection_assign_nextid( pConn );
216 pConn->c_conn_state = 0x01; /* SLAP_C_ACTIVE */
217 pConn->c_struct_state = 0x02; /* SLAP_C_USED */
219 pConn->c_ssf = pConn->c_transport_ssf = 0;
220 pConn->c_tls_ssf = 0;
222 backend_connection_init( pConn );
224 pConn->c_send_ldap_result = slapi_int_send_ldap_result_shim;
225 pConn->c_send_search_entry = slapi_int_send_search_entry_shim;
226 pConn->c_send_ldap_extended = slapi_int_send_ldap_extended_shim;
227 pConn->c_send_search_reference = slapi_int_send_search_reference_shim;
229 /* operation object */
230 pConn->c_pending_ops.stqh_first->o_tag = OpType;
231 pConn->c_pending_ops.stqh_first->o_protocol = LDAP_VERSION3;
232 pConn->c_pending_ops.stqh_first->o_authmech.bv_val = NULL;
233 pConn->c_pending_ops.stqh_first->o_authmech.bv_len = 0;
234 pConn->c_pending_ops.stqh_first->o_time = slap_get_time();
235 pConn->c_pending_ops.stqh_first->o_do_not_cache = 1;
236 pConn->c_pending_ops.stqh_first->o_threadctx = ldap_pvt_thread_pool_context();
237 pConn->c_pending_ops.stqh_first->o_tmpmemctx = NULL;
238 pConn->c_pending_ops.stqh_first->o_tmpmfuncs = &ch_mfuncs;
239 pConn->c_pending_ops.stqh_first->o_conn = pConn;
240 pConn->c_pending_ops.stqh_first->o_connid = pConn->c_connid;
242 ldap_pvt_thread_mutex_unlock( &pConn->c_mutex );
247 void slapi_int_connection_destroy( Connection **pConn )
249 Connection *conn = *pConn;
252 if ( pConn == NULL ) {
256 op = (Operation *)conn->c_pending_ops.stqh_first;
258 slap_graduate_commit_csn( op );
260 if ( op->o_req_dn.bv_val != NULL ) {
261 slapi_ch_free( (void **)&op->o_req_dn.bv_val );
263 if ( op->o_req_ndn.bv_val != NULL ) {
264 slapi_ch_free( (void **)&op->o_req_ndn.bv_val );
267 if ( conn->c_sb != NULL ) {
268 ber_sockbuf_free( conn->c_sb );
271 slapi_ch_free( (void **)&op );
273 slapi_ch_free( (void **)pConn );
277 * Function : values2obj
278 * Convert an array of strings into a BerVarray.
289 if ( ppValue == NULL ) {
294 for ( i = 0; ppValue[i] != NULL; i++ )
297 tmpberval = (BerVarray)slapi_ch_malloc( (i+1) * (sizeof(struct berval)) );
298 if ( tmpberval == NULL ) {
299 return LDAP_NO_MEMORY;
301 for ( i = 0; ppValue[i] != NULL; i++ ) {
302 size_t len = strlen( ppValue[i] );
304 tmpberval[i].bv_val = slapi_ch_malloc( len + 1 );
305 AC_MEMCPY( tmpberval[i].bv_val, ppValue[i], len + 1 );
306 tmpberval[i].bv_len = len;
308 tmpberval[i].bv_val = NULL;
309 tmpberval[i].bv_len = 0;
318 struct berval **bvptr,
324 if ( bvptr == NULL ) {
329 for ( i = 0; bvptr[i] != NULL; i++ )
332 tmpberval = (BerVarray)slapi_ch_malloc( (i + 1) * sizeof(struct berval));
333 if ( tmpberval == NULL ) {
334 return LDAP_NO_MEMORY;
337 for ( i = 0; bvptr[i] != NULL; i++ ) {
338 tmpberval[i].bv_val = slapi_ch_malloc( bvptr[i]->bv_len );
339 tmpberval[i].bv_len = bvptr[i]->bv_len;
340 AC_MEMCPY( tmpberval[i].bv_val, bvptr[i]->bv_val, bvptr[i]->bv_len );
343 tmpberval[i].bv_val = NULL;
344 tmpberval[i].bv_len = 0;
352 * Function : slapi_int_ldapmod_to_entry
353 * convert a dn plus an array of LDAPMod struct ptrs to an entry structure
354 * with a link list of the correspondent attributes.
355 * Return value : LDAP_SUCCESS
360 slapi_int_ldapmod_to_entry(
365 struct berval dn = BER_BVNULL;
371 Modifications *modlist = NULL;
372 Modifications **modtail = &modlist;
375 int rc = LDAP_SUCCESS;
378 const char *text = NULL;
380 op = (Operation *)pConn->c_pending_ops.stqh_first;
382 pEntry = (Entry *) ch_calloc( 1, sizeof(Entry) );
383 if ( pEntry == NULL) {
389 dn.bv_len = strlen(ldn);
391 rc = dnPrettyNormal( NULL, &dn, &pEntry->e_name, &pEntry->e_nname, NULL );
392 if ( rc != LDAP_SUCCESS ) {
396 if ( rc == LDAP_SUCCESS ) {
397 for ( i = 0, pMod = mods[0]; rc == LDAP_SUCCESS && pMod != NULL; pMod = mods[++i]) {
400 if ( (pMod->mod_op & LDAP_MOD_BVALUES) != 0 ) {
402 * Convert an array of pointers to bervals to
403 * an array of bervals. Note that we need to copy the
404 * values too, as the slap_mods_check() will free the
405 * original values after prettying; the modifications
406 * being passed in may not have been allocated on the
409 rc = bvptr2obj_copy( pMod->mod_bvalues, &bv );
410 if ( rc != LDAP_SUCCESS ) goto cleanup;
411 tmp.sml_type.bv_val = pMod->mod_type;
412 tmp.sml_type.bv_len = strlen( pMod->mod_type );
414 tmp.sml_nvalues = NULL;
416 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
418 mod->sml_op = LDAP_MOD_ADD;
420 mod->sml_next = NULL;
421 mod->sml_desc = NULL;
422 mod->sml_type = tmp.sml_type;
423 mod->sml_values = tmp.sml_values;
424 mod->sml_nvalues = tmp.sml_nvalues;
427 modtail = &mod->sml_next;
430 /* attr values are in string format, need to be converted */
431 /* to an array of bervals */
432 if ( pMod->mod_values == NULL ) {
435 rc = values2obj_copy( pMod->mod_values, &bv );
436 if ( rc != LDAP_SUCCESS ) goto cleanup;
437 tmp.sml_type.bv_val = pMod->mod_type;
438 tmp.sml_type.bv_len = strlen( pMod->mod_type );
440 tmp.sml_nvalues = NULL;
442 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
444 mod->sml_op = LDAP_MOD_ADD;
446 mod->sml_next = NULL;
447 mod->sml_desc = NULL;
448 mod->sml_type = tmp.sml_type;
449 mod->sml_values = tmp.sml_values;
450 mod->sml_nvalues = tmp.sml_nvalues;
453 modtail = &mod->sml_next;
456 } /* for each LDAPMod */
459 op->o_bd = select_backend( &pEntry->e_nname, 0, 0 );
460 if ( op->o_bd == NULL ) {
461 rc = LDAP_PARTIAL_RESULTS;
463 int repl_user = be_isupdate_dn( op->o_bd, &op->o_bd->be_rootdn );
464 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
465 int update = !BER_BVISNULL( &op->o_bd->be_update_ndn );
466 char textbuf[ SLAP_TEXT_BUFLEN ];
467 size_t textlen = sizeof( textbuf );
469 rc = slap_mods_check( modlist, &text,
470 textbuf, textlen, NULL );
472 if ( rc != LDAP_SUCCESS) {
477 rc = slap_mods_no_user_mod_check( op, modlist,
478 &text, textbuf, textlen );
479 if ( rc != LDAP_SUCCESS) {
485 rc = slap_mods_opattrs( op, modlist, modtail,
486 &text, textbuf, textlen, 1 );
487 if ( rc != LDAP_SUCCESS) {
492 rc = slap_mods2entry( modlist, &pEntry, repl_user,
493 0, &text, textbuf, textlen );
494 if (rc != LDAP_SUCCESS) {
504 if ( modlist != NULL )
505 slap_mods_free( modlist );
506 if ( rc != LDAP_SUCCESS ) {
507 if ( pEntry != NULL ) {
508 slapi_entry_free( pEntry );
517 slapi_int_get_ctrls( Operation *op, SlapReply *rs, LDAPControl **controls )
522 op->o_ctrls = controls;
523 if ( op->o_ctrls == NULL ) {
527 for ( c = op->o_ctrls; *c != NULL; c++ ) {
528 rc = slap_parse_ctrl( op, rs, *c, &rs->sr_text );
529 if ( rc != LDAP_SUCCESS )
537 slapi_delete_internal_pb( Slapi_PBlock *pb )
540 Connection *pConn = NULL;
541 Operation *op = NULL;
542 struct berval dn = BER_BVNULL;
544 LDAPControl **controls = NULL;
545 int manageDsaIt = SLAP_CONTROL_NONE;
546 int operation_flags = 0;
549 SlapReply rs = { REP_RESULT };
555 slapi_pblock_get( pb, SLAPI_TARGET_DN, &ldn );
556 slapi_pblock_get( pb, SLAPI_REQCONTROLS, &controls );
557 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, &operation_flags );
560 rs.sr_err = LDAP_PARAM_ERROR;
564 pConn = slapi_int_init_connection( NULL, LDAP_REQ_DELETE );
566 rs.sr_err = LDAP_NO_MEMORY;
570 op = (Operation *)pConn->c_pending_ops.stqh_first;
573 rs.sr_err = slapi_int_get_ctrls( op, &rs, controls );
574 if ( rs.sr_err != LDAP_SUCCESS )
578 dn.bv_len = strlen(ldn);
580 rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL );
581 if ( rs.sr_err != LDAP_SUCCESS )
584 if ( slapi_control_present( controls,
585 SLAPI_CONTROL_MANAGEDSAIT_OID, NULL, &isCritical) ) {
586 manageDsaIt = isCritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL;
589 op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 1 );
590 if ( op->o_bd == NULL ) {
591 rs.sr_err = LDAP_PARTIAL_RESULTS;
595 op->o_dn = pConn->c_dn = op->o_bd->be_rootdn;
596 op->o_ndn = pConn->c_ndn = op->o_bd->be_rootndn;
598 if ( op->o_bd->be_delete ) {
599 int repl_user = be_isupdate( op );
600 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
601 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
602 if ( operation_flags & SLAPI_OP_FLAG_LOG_CHANGE )
603 op->o_callback = &cb;
605 op->o_bd->be_delete( op, &rs );
607 rs.sr_err = LDAP_REFERRAL;
610 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
614 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
616 slapi_int_connection_destroy( &pConn );
621 #endif /* LDAP_SLAPI */
625 slapi_add_internal_pb( Slapi_PBlock *pb )
628 Connection *pConn = NULL;
629 Slapi_Entry *entry = NULL;
630 Slapi_Entry *argEntry = NULL;
632 LDAPMod **mods = NULL;
633 LDAPControl **controls = NULL;
634 int operation_flags = 0;
635 Operation *op = NULL;
637 int manageDsaIt = SLAP_CONTROL_NONE;
642 SlapReply rs = { REP_RESULT };
648 pConn = slapi_int_init_connection( NULL, LDAP_REQ_ADD );
649 if ( pConn == NULL ) {
650 rs.sr_err = LDAP_OTHER;
654 slapi_pblock_get( pb, SLAPI_ADD_TARGET, &dn );
655 slapi_pblock_get( pb, SLAPI_ADD_ENTRY, &argEntry );
656 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
657 slapi_pblock_get( pb, SLAPI_REQCONTROLS, &controls );
658 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, &operation_flags );
660 if ( argEntry != NULL ) {
661 entry = slapi_entry_dup( argEntry );
662 dn = slapi_entry_get_dn( argEntry );
664 if ( mods == NULL || dn == NULL ) {
665 rs.sr_err = LDAP_PARAM_ERROR;
669 for ( i = 0; mods[i] != NULL; i++ ) {
670 if ( (mods[i]->mod_op & LDAP_MOD_OP ) != LDAP_MOD_ADD ) {
671 rs.sr_err = LDAP_OTHER;
676 entry = slapi_int_ldapmod_to_entry( pConn, dn, mods );
677 if ( entry == NULL ) {
678 rs.sr_err = LDAP_OTHER;
683 if ( slapi_control_present( controls, LDAP_CONTROL_MANAGEDSAIT,
684 NULL, &isCritical ) ) {
685 manageDsaIt = isCritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL;
688 op = (Operation *)pConn->c_pending_ops.stqh_first;
691 rs.sr_err = slapi_int_get_ctrls( op, &rs, controls );
692 if ( rs.sr_err != LDAP_SUCCESS )
695 op->o_bd = select_backend( &entry->e_nname, manageDsaIt, 1 );
696 if ( op->o_bd == NULL ) {
697 rs.sr_err = LDAP_PARTIAL_RESULTS;
701 op->o_dn = pConn->c_dn = op->o_bd->be_rootdn;
702 op->o_ndn = pConn->c_ndn = op->o_bd->be_rootndn;
703 op->oq_add.rs_e = entry;
705 if ( op->o_bd->be_add ) {
706 int repl_user = be_isupdate( op );
707 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
708 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
710 if ( operation_flags & SLAPI_OP_FLAG_LOG_CHANGE )
711 op->o_callback = &cb;
713 if ( op->o_bd->be_add( op, &rs ) == LDAP_SUCCESS ) {
714 be_entry_release_w( op, entry );
718 rs.sr_err = LDAP_REFERRAL;
721 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
725 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
727 if ( entry != NULL ) {
728 slapi_entry_free( entry );
731 slapi_int_connection_destroy( &pConn );
736 #endif /* LDAP_SLAPI */
740 slapi_modrdn_internal_pb( Slapi_PBlock *pb )
743 struct berval dn = BER_BVNULL;
744 struct berval newrdn = BER_BVNULL;
745 struct berval newsupdn = BER_BVNULL;
746 struct berval newSuperiorPretty = BER_BVNULL;
747 struct berval newSuperiorNormalized = BER_BVNULL;
748 Connection *pConn = NULL;
749 Operation *op = NULL;
750 int manageDsaIt = SLAP_CONTROL_NONE;
757 LDAPControl **controls;
760 SlapReply rs = { REP_RESULT };
766 slapi_pblock_get( pb, SLAPI_MODRDN_TARGET, &olddn );
767 slapi_pblock_get( pb, SLAPI_MODRDN_NEWRDN, &lnewrdn );
768 slapi_pblock_get( pb, SLAPI_MODRDN_NEWSUPERIOR, &newsuperior );
769 slapi_pblock_get( pb, SLAPI_MODRDN_DELOLDRDN, &deloldrdn );
770 slapi_pblock_get( pb, SLAPI_REQCONTROLS, &controls );
772 slapi_pblock_get( pb, SLAPI_TARGET_UNIQUEID, uniqueid );
773 slapi_pblock_get( pb, SLAPI_PLUGIN_IDENTITY, plugin_identity );
775 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, &operation_flags );
777 pConn = slapi_int_init_connection( NULL, LDAP_REQ_MODRDN );
778 if ( pConn == NULL) {
779 rs.sr_err = LDAP_NO_MEMORY;
783 op = (Operation *)pConn->c_pending_ops.stqh_first;
786 rs.sr_err = slapi_int_get_ctrls( op, &rs, controls );
787 if ( rs.sr_err != LDAP_SUCCESS )
790 if ( slapi_control_present( controls,
791 SLAPI_CONTROL_MANAGEDSAIT_OID, NULL, &isCritical ) ) {
792 manageDsaIt = isCritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL;
795 op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 1 );
796 if ( op->o_bd == NULL ) {
797 rs.sr_err = LDAP_PARTIAL_RESULTS;
801 op->o_dn = pConn->c_dn = op->o_bd->be_rootdn;
802 op->o_ndn = pConn->c_ndn = op->o_bd->be_rootndn;
804 dn.bv_val = (char *)olddn;
805 dn.bv_len = strlen( olddn );
807 rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL );
808 if ( rs.sr_err != LDAP_SUCCESS ) {
812 if ( op->o_req_dn.bv_len == 0 ) {
813 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
817 newrdn.bv_val = (char *)lnewrdn;
818 newrdn.bv_len = strlen( lnewrdn );
820 rs.sr_err = dnPrettyNormal( NULL, &newrdn, &op->oq_modrdn.rs_newrdn, &op->oq_modrdn.rs_nnewrdn, NULL );
821 if ( rs.sr_err != LDAP_SUCCESS ) {
825 if ( rdn_validate( &op->oq_modrdn.rs_nnewrdn ) != LDAP_SUCCESS ) {
829 if ( newsuperior != NULL ) {
830 newsupdn.bv_val = (char *)newsuperior;
831 newsupdn.bv_len = strlen( newsuperior );
833 rs.sr_err = dnPrettyNormal( NULL, &newsupdn, &newSuperiorPretty, &newSuperiorNormalized, NULL );
834 if ( rs.sr_err != LDAP_SUCCESS )
837 op->oq_modrdn.rs_newSup = &newSuperiorPretty;
838 op->oq_modrdn.rs_nnewSup = &newSuperiorNormalized;
840 op->oq_modrdn.rs_newSup = NULL;
841 op->oq_modrdn.rs_nnewSup = NULL;
844 op->oq_modrdn.rs_deleteoldrdn = deloldrdn;
846 if ( op->o_bd->be_modrdn ) {
847 int repl_user = be_isupdate( op );
848 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
849 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
851 if ( operation_flags & SLAPI_OP_FLAG_LOG_CHANGE )
852 op->o_callback = &cb;
854 op->o_bd->be_modrdn( op, &rs );
856 rs.sr_err = LDAP_REFERRAL;
859 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
864 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
866 if ( op->oq_modrdn.rs_newrdn.bv_val != NULL )
867 slapi_ch_free( (void **)&op->oq_modrdn.rs_newrdn.bv_val );
868 if ( op->oq_modrdn.rs_nnewrdn.bv_val != NULL )
869 slapi_ch_free( (void **)&op->oq_modrdn.rs_nnewrdn.bv_val );
870 if ( newSuperiorPretty.bv_val != NULL )
871 slapi_ch_free( (void **)&newSuperiorPretty.bv_val );
872 if ( newSuperiorNormalized.bv_val != NULL )
873 slapi_ch_free( (void **)&newSuperiorNormalized.bv_val );
875 slapi_int_connection_destroy( &pConn );
880 #endif /* LDAP_SLAPI */
883 int slapi_modify_internal_pb( Slapi_PBlock *pb )
887 Connection *pConn = NULL;
888 Operation *op = NULL;
890 struct berval dn = BER_BVNULL;
892 int manageDsaIt = SLAP_CONTROL_NONE;
897 Modifications *modlist = NULL;
898 Modifications **modtail = &modlist;
902 LDAPMod **mods = NULL;
903 LDAPControl **controls = NULL;
904 int operation_flags = 0;
906 SlapReply rs = { REP_RESULT };
912 slapi_pblock_get( pb, SLAPI_MODIFY_TARGET, &ldn );
913 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods );
914 slapi_pblock_get( pb, SLAPI_REQCONTROLS, &controls );
916 slapi_pblock_get( pb, SLAPI_TARGET_UNIQUEID, uniqueid );
917 slapi_pblock_get( pb, SLAPI_PLUGIN_IDENTITY, plugin_identity );
919 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, &operation_flags );
921 if ( mods == NULL || *mods == NULL || ldn == NULL ) {
922 rs.sr_err = LDAP_PARAM_ERROR ;
926 pConn = slapi_int_init_connection( NULL, LDAP_REQ_MODIFY );
927 if ( pConn == NULL ) {
928 rs.sr_err = LDAP_NO_MEMORY;
932 op = (Operation *)pConn->c_pending_ops.stqh_first;
935 rs.sr_err = slapi_int_get_ctrls( op, &rs, controls );
936 if ( rs.sr_err != LDAP_SUCCESS )
940 dn.bv_len = strlen( ldn );
942 rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL );
943 if ( rs.sr_err != LDAP_SUCCESS ) {
947 if ( slapi_control_present( controls,
948 SLAPI_CONTROL_MANAGEDSAIT_OID, NULL, &isCritical ) ) {
949 manageDsaIt = isCritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL;
952 op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 1 );
953 if ( op->o_bd == NULL ) {
954 rs.sr_err = LDAP_PARTIAL_RESULTS;
958 op->o_dn = pConn->c_dn = op->o_bd->be_rootdn;
959 op->o_ndn = pConn->c_ndn = op->o_bd->be_rootndn;
961 for ( i = 0, pMod = mods[0];
962 rs.sr_err == LDAP_SUCCESS && pMod != NULL;
967 if ( (pMod->mod_op & LDAP_MOD_BVALUES) != 0 ) {
969 * attr values are in berval format
970 * convert an array of pointers to bervals
971 * to an array of bervals
973 rs.sr_err = bvptr2obj_copy( pMod->mod_bvalues, &bv );
974 if ( rs.sr_err != LDAP_SUCCESS )
976 tmp.sml_type.bv_val = pMod->mod_type;
977 tmp.sml_type.bv_len = strlen( pMod->mod_type );
979 tmp.sml_nvalues = NULL;
981 mod = (Modifications *)ch_malloc( sizeof(Modifications) );
983 mod->sml_op = pMod->mod_op & LDAP_MOD_OP;
985 mod->sml_next = NULL;
986 mod->sml_desc = NULL;
987 mod->sml_type = tmp.sml_type;
988 mod->sml_values = tmp.sml_values;
989 mod->sml_nvalues = tmp.sml_nvalues;
991 rs.sr_err = values2obj_copy( pMod->mod_values, &bv );
992 if ( rs.sr_err != LDAP_SUCCESS )
994 tmp.sml_type.bv_val = pMod->mod_type;
995 tmp.sml_type.bv_len = strlen( pMod->mod_type );
997 tmp.sml_nvalues = NULL;
999 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
1001 mod->sml_op = pMod->mod_op & LDAP_MOD_OP;
1003 mod->sml_next = NULL;
1004 mod->sml_desc = NULL;
1005 mod->sml_type = tmp.sml_type;
1006 mod->sml_values = tmp.sml_values;
1007 mod->sml_nvalues = tmp.sml_nvalues;
1010 modtail = &mod->sml_next;
1012 switch( pMod->mod_op & LDAP_MOD_OP ) {
1014 if ( mod->sml_values == NULL ) {
1015 rs.sr_err = LDAP_PROTOCOL_ERROR;
1020 case LDAP_MOD_DELETE:
1021 case LDAP_MOD_REPLACE:
1022 case LDAP_MOD_INCREMENT:
1026 rs.sr_err = LDAP_PROTOCOL_ERROR;
1032 if ( op->o_req_ndn.bv_len == 0 ) {
1033 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
1037 op->oq_modify.rs_modlist = modlist;
1039 if ( op->o_bd->be_modify ) {
1040 int repl_user = be_isupdate( op );
1041 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
1042 int update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn );
1043 const char *text = NULL;
1044 char textbuf[ SLAP_TEXT_BUFLEN ];
1045 size_t textlen = sizeof( textbuf );
1046 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
1048 rs.sr_err = slap_mods_check( modlist,
1049 &text, textbuf, textlen, NULL );
1050 if ( rs.sr_err != LDAP_SUCCESS ) {
1055 rs.sr_err = slap_mods_no_user_mod_check( op, modlist,
1056 &text, textbuf, textlen );
1057 if ( rs.sr_err != LDAP_SUCCESS ) {
1063 rs.sr_err = slap_mods_opattrs( op, modlist,
1064 modtail, &text, textbuf,
1066 if ( rs.sr_err != LDAP_SUCCESS ) {
1071 if ( operation_flags & SLAPI_OP_FLAG_LOG_CHANGE )
1072 op->o_callback = &cb;
1074 op->o_bd->be_modify( op, &rs );
1076 rs.sr_err = LDAP_REFERRAL;
1079 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
1083 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
1085 if ( modlist != NULL )
1086 slap_mods_free( modlist );
1088 slapi_int_connection_destroy( &pConn );
1093 #endif /* LDAP_SLAPI */
1098 slapi_int_search_entry_callback( Slapi_Entry *entry, void *callback_data )
1100 int nentries = 0, i = 0;
1101 Slapi_Entry **head = NULL, **tp;
1102 Slapi_PBlock *pb = (Slapi_PBlock *)callback_data;
1104 entry = slapi_entry_dup( entry );
1105 if ( entry == NULL ) {
1109 slapi_pblock_get( pb, SLAPI_NENTRIES, &nentries );
1110 slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &head );
1113 if ( nentries == 0 ) {
1114 tp = (Slapi_Entry **)slapi_ch_malloc( 2 * sizeof(Slapi_Entry *) );
1116 slapi_entry_free( entry );
1122 tp = (Slapi_Entry **)slapi_ch_realloc( (char *)head,
1123 sizeof(Slapi_Entry *) * ( i + 1 ) );
1125 slapi_entry_free( entry );
1128 tp[ i - 1 ] = entry;
1132 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, (void *)tp );
1133 slapi_pblock_set( pb, SLAPI_NENTRIES, (void *)i );
1135 return LDAP_SUCCESS;
1137 #endif /* LDAP_SLAPI */
1139 int slapi_search_internal_pb( Slapi_PBlock *pb )
1142 return slapi_search_internal_callback_pb( pb,
1145 slapi_int_search_entry_callback,
1152 int slapi_search_internal_callback_pb( Slapi_PBlock *pb,
1153 void *callback_data,
1154 plugin_result_callback prc,
1155 plugin_search_entry_callback psec,
1156 plugin_referral_entry_callback prec )
1160 Operation *op = NULL;
1161 struct berval dn = BER_BVNULL;
1162 Filter *filter = NULL;
1163 struct berval fstr = BER_BVNULL;
1164 AttributeName *an = NULL;
1165 const char *text = NULL;
1167 int manageDsaIt = SLAP_CONTROL_NONE;
1172 int scope = LDAP_SCOPE_BASE;
1173 char *filStr = NULL;
1174 LDAPControl **controls = NULL;
1175 char **attrs = NULL;
1176 char *uniqueid = NULL;
1178 int operation_flags = 0;
1181 SlapReply rs = { REP_RESULT };
1187 slapi_pblock_get( pb, SLAPI_SEARCH_TARGET, &ldn );
1188 slapi_pblock_get( pb, SLAPI_SEARCH_SCOPE, &scope );
1189 slapi_pblock_get( pb, SLAPI_SEARCH_FILTER, &filter );
1190 slapi_pblock_get( pb, SLAPI_SEARCH_STRFILTER, &filStr );
1191 slapi_pblock_get( pb, SLAPI_SEARCH_ATTRS, &attrs );
1192 slapi_pblock_get( pb, SLAPI_SEARCH_ATTRSONLY, &attrsonly );
1193 slapi_pblock_get( pb, SLAPI_REQCONTROLS, &controls );
1194 slapi_pblock_get( pb, SLAPI_TARGET_UNIQUEID, &uniqueid );
1195 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, &operation_flags );
1197 c = slapi_int_init_connection( NULL, LDAP_REQ_SEARCH );
1199 rs.sr_err = LDAP_NO_MEMORY;
1203 op = (Operation *)c->c_pending_ops.stqh_first;
1206 /* callback and arguments */
1207 slapi_pblock_set( pb, SLAPI_X_INTOP_RESULT_CALLBACK, prc );
1208 slapi_pblock_set( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, psec );
1209 slapi_pblock_set( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, prec );
1210 slapi_pblock_set( pb, SLAPI_X_INTOP_CALLBACK_DATA, callback_data );
1212 rs.sr_err = slapi_int_get_ctrls( op, &rs, controls );
1213 if ( rs.sr_err != LDAP_SUCCESS )
1216 if ( ldn != NULL ) {
1218 dn.bv_len = strlen(ldn);
1221 rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL );
1222 if ( rs.sr_err != LDAP_SUCCESS ) {
1226 if ( scope != LDAP_SCOPE_BASE &&
1227 scope != LDAP_SCOPE_ONELEVEL &&
1228 scope != LDAP_SCOPE_SUBTREE ) {
1229 rs.sr_err = LDAP_PROTOCOL_ERROR;
1233 if ( filter == NULL ) {
1234 if ( filStr == NULL ) {
1235 rs.sr_err = LDAP_PARAM_ERROR;
1239 filter = slapi_str2filter( filStr );
1240 if ( filter == NULL ) {
1241 rs.sr_err = LDAP_PROTOCOL_ERROR;
1248 filter2bv( filter, &fstr );
1250 for ( i = 0; attrs != NULL && attrs[i] != NULL; i++ ) {
1251 ; /* count the number of attributes */
1255 an = (AttributeName *)slapi_ch_calloc( (i + 1), sizeof(AttributeName) );
1256 for (i = 0; attrs[i] != 0; i++) {
1257 an[i].an_desc = NULL;
1259 an[i].an_oc_exclude = 0;
1260 an[i].an_name.bv_val = slapi_ch_strdup(attrs[i]);
1261 an[i].an_name.bv_len = strlen(attrs[i]);
1262 slap_bv2ad( &an[i].an_name, &an[i].an_desc, &text );
1264 an[i].an_name.bv_val = NULL;
1267 memset( &rs, 0, sizeof(rs) );
1268 rs.sr_type = REP_RESULT;
1269 rs.sr_err = LDAP_SUCCESS;
1270 rs.sr_entry = NULL; /* paranoia */
1272 if ( scope == LDAP_SCOPE_BASE ) {
1275 if ( op->o_req_ndn.bv_len == 0 ) {
1276 rs.sr_err = root_dse_info( c, &rs.sr_entry, &rs.sr_text );
1279 if( rs.sr_err != LDAP_SUCCESS ) {
1280 send_ldap_result( op, &rs );
1282 } else if ( rs.sr_entry != NULL ) {
1283 rs.sr_err = test_filter( op, rs.sr_entry, filter );
1285 if ( rs.sr_err == LDAP_COMPARE_TRUE ) {
1286 rs.sr_type = REP_SEARCH;
1287 rs.sr_err = LDAP_SUCCESS;
1289 rs.sr_operational_attrs = NULL;
1290 rs.sr_flags = REP_ENTRY_MODIFIABLE;
1292 send_search_entry( op, &rs );
1295 entry_free( rs.sr_entry );
1297 rs.sr_type = REP_RESULT;
1298 rs.sr_err = LDAP_SUCCESS;
1300 send_ldap_result( op, &rs );
1306 if ( !op->o_req_ndn.bv_len && default_search_nbase.bv_len ) {
1307 slapi_ch_free( (void **)&op->o_req_dn.bv_val );
1308 slapi_ch_free( (void **)&op->o_req_ndn.bv_val );
1310 ber_dupbv( &op->o_req_dn, &default_search_base );
1311 ber_dupbv( &op->o_req_ndn, &default_search_nbase );
1314 if ( slapi_control_present( controls,
1315 LDAP_CONTROL_MANAGEDSAIT, NULL, &isCritical ) ) {
1316 manageDsaIt = isCritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL;
1319 op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 1 );
1320 if ( op->o_bd == NULL ) {
1321 if ( manageDsaIt > SLAP_CONTROL_NONE ) {
1322 rs.sr_err = LDAP_NO_SUCH_OBJECT;
1324 rs.sr_err = LDAP_PARTIAL_RESULTS;
1329 op->o_dn = c->c_dn = op->o_bd->be_rootdn;
1330 op->o_ndn = c->c_ndn = op->o_bd->be_rootndn;
1332 op->oq_search.rs_scope = scope;
1333 op->oq_search.rs_deref = 0;
1334 op->oq_search.rs_slimit = SLAP_NO_LIMIT;
1335 op->oq_search.rs_tlimit = SLAP_NO_LIMIT;
1336 op->oq_search.rs_attrsonly = attrsonly;
1337 op->oq_search.rs_attrs = an;
1338 op->oq_search.rs_filter = filter;
1339 op->oq_search.rs_filterstr = fstr;
1341 if ( op->o_bd->be_search != NULL ) {
1342 (*op->o_bd->be_search)( op, &rs );
1344 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
1348 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
1349 slapi_pblock_set( pb, SLAPI_X_INTOP_RESULT_CALLBACK, NULL );
1350 slapi_pblock_set( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, NULL );
1351 slapi_pblock_set( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, NULL );
1352 slapi_pblock_set( pb, SLAPI_X_INTOP_CALLBACK_DATA, NULL );
1354 if ( freeFilter && filter != NULL )
1355 slapi_filter_free( filter, 1 );
1357 slapi_ch_free( (void **)&fstr.bv_val );
1359 slapi_ch_free( (void **)&an );
1361 slapi_int_connection_destroy( &c );
1366 #endif /* LDAP_SLAPI */
1369 /* Wrappers for old API */
1371 void slapi_search_internal_set_pb( Slapi_PBlock *pb,
1377 LDAPControl **controls,
1378 const char *uniqueid,
1379 Slapi_ComponentId *plugin_identity,
1380 int operation_flags )
1383 slapi_pblock_set( pb, SLAPI_SEARCH_TARGET, (void *)base );
1384 slapi_pblock_set( pb, SLAPI_SEARCH_SCOPE, (void *)scope );
1385 slapi_pblock_set( pb, SLAPI_SEARCH_FILTER, NULL );
1386 slapi_pblock_set( pb, SLAPI_SEARCH_STRFILTER, (void *)filter );
1387 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRS, (void *)attrs );
1388 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRSONLY, (void *)attrsonly );
1389 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1390 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
1391 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1392 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1393 #endif /* LDAP_SLAPI */
1397 slapi_search_internal(
1401 LDAPControl **controls,
1408 pb = slapi_pblock_new();
1413 slapi_search_internal_set_pb( pb, ldn, scope, filStr, attrs, attrsonly,
1414 controls, NULL, NULL, 0 );
1416 slapi_search_internal_pb( pb );
1421 #endif /* LDAP_SLAPI */
1424 void slapi_modify_internal_set_pb( Slapi_PBlock *pb,
1427 LDAPControl **controls,
1428 const char *uniqueid,
1429 Slapi_ComponentId *plugin_identity,
1430 int operation_flags )
1433 slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn );
1434 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)mods );
1435 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1436 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
1437 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1438 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1439 #endif /* LDAP_SLAPI */
1442 /* Function : slapi_modify_internal
1444 * Description: Plugin functions call this routine to modify an entry
1445 * in the backend directly
1446 * Return values : LDAP_SUCCESS
1450 * LDAP_UNWILLING_TO_PERFORM
1453 slapi_modify_internal(
1456 LDAPControl **controls,
1462 pb = slapi_pblock_new();
1467 slapi_modify_internal_set_pb( pb, ldn, mods, controls, NULL, NULL,
1468 log_change ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1470 slapi_modify_internal_pb( pb );
1475 #endif /* LDAP_SLAPI */
1478 int slapi_add_internal_set_pb( Slapi_PBlock *pb,
1481 LDAPControl **controls,
1482 Slapi_ComponentId *plugin_identity,
1483 int operation_flags )
1486 slapi_pblock_set( pb, SLAPI_ADD_TARGET, (void *)dn );
1487 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)attrs );
1488 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1489 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1490 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1495 #endif /* LDAP_SLAPI */
1498 Slapi_PBlock *slapi_add_internal(
1501 LDAPControl **controls,
1507 pb = slapi_pblock_new();
1511 slapi_add_internal_set_pb( pb, dn, attrs, controls, NULL,
1512 log_changes ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1514 slapi_add_internal_pb( pb );
1519 #endif /* LDAP_SLAPI */
1522 void slapi_add_entry_internal_set_pb( Slapi_PBlock *pb,
1524 LDAPControl **controls,
1525 Slapi_ComponentId *plugin_identity,
1526 int operation_flags )
1529 slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)e );
1530 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1531 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1532 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1533 #endif /* LDAP_SLAPI */
1537 slapi_add_entry_internal(
1539 LDAPControl **controls,
1545 pb = slapi_pblock_new();
1549 slapi_add_entry_internal_set_pb( pb, e, controls, NULL,
1550 log_changes ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1552 slapi_add_internal_pb( pb );
1557 #endif /* LDAP_SLAPI */
1560 void slapi_rename_internal_set_pb( Slapi_PBlock *pb,
1563 const char *newsuperior,
1565 LDAPControl **controls,
1566 const char *uniqueid,
1567 Slapi_ComponentId *plugin_identity,
1568 int operation_flags )
1571 slapi_pblock_set( pb, SLAPI_MODRDN_TARGET, (void *)olddn );
1572 slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)newrdn );
1573 slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR, (void *)newsuperior );
1574 slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)deloldrdn );
1575 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1576 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
1577 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1578 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1579 #endif /* LDAP_SLAPI */
1582 /* Function : slapi_modrdn_internal
1584 * Description : Plugin functions call this routine to modify the rdn
1585 * of an entry in the backend directly
1586 * Return values : LDAP_SUCCESS
1590 * LDAP_UNWILLING_TO_PERFORM
1592 * NOTE: This function does not support the "newSuperior" option from LDAP V3.
1595 slapi_modrdn_internal(
1599 LDAPControl **controls,
1605 pb = slapi_pblock_new();
1610 slapi_rename_internal_set_pb( pb, olddn, lnewrdn, NULL,
1611 deloldrdn, controls, NULL, NULL,
1612 log_change ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1614 slapi_modrdn_internal_pb( pb );
1619 #endif /* LDAP_SLAPI */
1622 void slapi_delete_internal_set_pb( Slapi_PBlock *pb,
1624 LDAPControl **controls,
1625 const char *uniqueid,
1626 Slapi_ComponentId *plugin_identity,
1627 int operation_flags )
1630 slapi_pblock_set( pb, SLAPI_TARGET_DN, (void *)dn );
1631 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1632 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
1633 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1634 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1635 #endif /* LDAP_SLAPI */
1638 /* Function : slapi_delete_internal
1640 * Description : Plugin functions call this routine to delete an entry
1641 * in the backend directly
1642 * Return values : LDAP_SUCCESS
1646 * LDAP_UNWILLING_TO_PERFORM
1649 slapi_delete_internal(
1651 LDAPControl **controls,
1657 pb = slapi_pblock_new();
1661 slapi_delete_internal_set_pb( pb, ldn, controls, NULL, NULL,
1662 log_change ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1664 slapi_delete_internal_pb( pb );
1669 #endif /* LDAP_SLAPI */