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, (void **)&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, (void **)&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_get_ctrls( Operation *op, SlapReply *rs, LDAPControl **controls )
147 op->o_ctrls = controls;
148 if ( op->o_ctrls == NULL ) {
152 for ( c = op->o_ctrls; *c != NULL; c++ ) {
153 rc = slap_parse_ctrl( op, rs, *c, &rs->sr_text );
154 if ( rc != LDAP_SUCCESS )
162 * To allow plugins to forward frontend requests to internal operations,
163 * the internal operation and connection structures should import as
164 * much state as practicable from the supplied parameter block.
168 * Select the backend to be used for an internal operation, either
169 * from the operation target DN or from the parameter block.
172 slapi_int_pblock_get_backend( Slapi_PBlock *pb, Operation *op )
174 int manageDsaIt = 0, isCritical;
175 LDAPControl **controls = NULL;
178 slapi_pblock_get( pb, SLAPI_REQCONTROLS, (void **)&controls );
180 slapi_pblock_get( pb, SLAPI_MANAGEDSAIT, (void **)&manageDsaIt );
181 if ( manageDsaIt != 0 )
182 manageDsaIt = SLAP_CONTROL_CRITICAL;
183 else if ( slapi_control_present( controls, SLAPI_CONTROL_MANAGEDSAIT_OID,
185 manageDsaIt = isCritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL;
187 /* let caller force a specific backend */
188 slapi_pblock_get( pb, SLAPI_BACKEND, (void **)&op->o_bd );
189 if ( op->o_bd == NULL ) {
190 op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 1 );
191 if ( op->o_bd == NULL ) {
192 if ( op->o_tag == LDAP_REQ_SEARCH && manageDsaIt > SLAP_CONTROL_NONE )
193 rc = LDAP_NO_SUCH_OBJECT;
195 rc = LDAP_PARTIAL_RESULTS;
199 if ( op->o_bd != NULL ) {
207 slapi_int_pblock_get_connection( Slapi_PBlock *pb, Operation *op )
210 Connection *conn = op->o_conn;
212 slapi_pblock_get( pb, SLAPI_X_CONN_SSF, (void **)&conn->c_ssf );
213 slapi_pblock_get( pb, SLAPI_X_CONN_SASL_CONTEXT, (void **)&conn->c_sasl_authctx );
215 if ( slapi_pblock_get( pb, SLAPI_CONN_DN, (void **)&connDn ) != 0 ||
217 /* default to operation DN */
218 conn->c_ndn = op->o_ndn;
219 conn->c_dn = op->o_ndn;
221 /* NB: conn DN must be normalized */
222 conn->c_ndn.bv_val = connDn;
223 conn->c_ndn.bv_len = strlen( connDn );
225 conn->c_dn = conn->c_ndn;
232 slapi_int_pblock_get_operation( Slapi_PBlock *pb, Operation *op, SlapReply *rs )
236 char *requestorDn = NULL;
237 struct berval targetDn = BER_BVNULL;
238 LDAPControl **controls;
241 /* All internal operations must specify a target DN */
242 if ( slapi_pblock_get( pb, SLAPI_TARGET_DN, (void **)&targetDn.bv_val ) != 0 ||
243 targetDn.bv_val == NULL ) {
244 return LDAP_PARAM_ERROR;
247 targetDn.bv_len = strlen( targetDn.bv_val );
249 rc = dnPrettyNormal( NULL, &targetDn, &op->o_req_dn, &op->o_req_ndn, NULL );
250 if ( rc != LDAP_SUCCESS ) {
254 rc = slapi_int_pblock_get_backend( pb, op );
255 if ( rc != LDAP_SUCCESS ) {
259 slapi_pblock_get( pb, SLAPI_REQUESTOR_ISROOT, (void **)&isRoot );
260 slapi_pblock_get( pb, SLAPI_REQUESTOR_ISUPDATEDN, (void **)&isUpdateDn );
261 /* NB: requestor DN must be normalized */
262 slapi_pblock_get( pb, SLAPI_REQUESTOR_DN, (void **)&requestorDn );
264 /* Default authorization identity for internal operations is root DN */
265 if ( isRoot || requestorDn == NULL ) {
266 op->o_dn = op->o_bd->be_rootdn;
267 op->o_ndn = op->o_bd->be_rootndn;
270 op->o_ndn.bv_val = requestorDn;
271 op->o_ndn.bv_len = strlen( requestorDn );
272 op->o_dn = op->o_ndn;
276 slapi_pblock_set( pb, SLAPI_REQUESTOR_ISROOT, (void *)isRoot );
278 rc = slapi_int_pblock_get_connection( pb, op );
279 if ( rc != LDAP_SUCCESS ) {
283 slapi_pblock_get( pb, SLAPI_REQCONTROLS, (void **)&controls );
284 rc = slapi_int_get_ctrls( op, rs, controls );
285 if ( rc != LDAP_SUCCESS ) {
293 slapi_int_init_connection( Slapi_PBlock *pb,
300 ber_len_t max = sockbuf_max_incoming;
303 conn = (Connection *) slapi_ch_calloc(1, sizeof(Connection));
305 LDAP_STAILQ_INIT( &conn->c_pending_ops );
307 op = (Operation *) slapi_ch_calloc( 1, OPERATION_BUFFER_SIZE );
308 op->o_hdr = (Opheader *)(op + 1);
309 op->o_controls = (void **)(op->o_hdr + 1);
311 op->o_extensions = NULL;
313 conn->c_pending_ops.stqh_first = op;
315 /* connection object authorization information */
316 conn->c_authtype = LDAP_AUTH_NONE;
317 conn->c_authmech.bv_val = NULL;
318 conn->c_authmech.bv_len = 0;
319 conn->c_dn.bv_val = NULL;
320 conn->c_dn.bv_len = 0;
321 conn->c_ndn.bv_val = NULL;
322 conn->c_ndn.bv_len = 0;
324 conn->c_listener = &slap_unknown_listener;
325 ber_dupbv( &conn->c_peer_domain, (struct berval *)&slap_unknown_bv );
326 ber_dupbv( &conn->c_peer_name, (struct berval *)&slap_unknown_bv );
328 LDAP_STAILQ_INIT( &conn->c_ops );
330 conn->c_sasl_bind_mech.bv_val = NULL;
331 conn->c_sasl_bind_mech.bv_len = 0;
332 conn->c_sasl_authctx = NULL;
333 conn->c_sasl_sockctx = NULL;
334 conn->c_sasl_extra = NULL;
336 conn->c_sb = ber_sockbuf_alloc( );
338 ber_sockbuf_ctrl( conn->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max );
340 conn->c_currentber = NULL;
342 /* should check status of thread calls */
343 ldap_pvt_thread_mutex_init( &conn->c_mutex );
344 ldap_pvt_thread_mutex_init( &conn->c_write_mutex );
345 ldap_pvt_thread_cond_init( &conn->c_write_cv );
347 ldap_pvt_thread_mutex_lock( &conn->c_mutex );
349 conn->c_n_ops_received = 0;
350 conn->c_n_ops_executing = 0;
351 conn->c_n_ops_pending = 0;
352 conn->c_n_ops_completed = 0;
358 conn->c_protocol = LDAP_VERSION3;
360 conn->c_activitytime = conn->c_starttime = slap_get_time();
363 * A real connection ID is required, because syncrepl associates
364 * pending CSNs with unique ( connection, operation ) tuples.
365 * Setting a fake connection ID will cause slap_get_commit_csn()
366 * to return a stale value.
368 connection_assign_nextid( conn );
370 conn->c_conn_state = 0x01; /* SLAP_C_ACTIVE */
371 conn->c_struct_state = 0x02; /* SLAP_C_USED */
373 conn->c_ssf = conn->c_transport_ssf = 0;
376 backend_connection_init( conn );
378 conn->c_send_ldap_result = slapi_int_send_ldap_result_shim;
379 conn->c_send_search_entry = slapi_int_send_search_entry_shim;
380 conn->c_send_ldap_extended = slapi_int_send_ldap_extended_shim;
381 conn->c_send_search_reference = slapi_int_send_search_reference_shim;
383 /* operation object */
385 op->o_protocol = LDAP_VERSION3;
386 op->o_authmech.bv_val = NULL;
387 op->o_authmech.bv_len = 0;
388 op->o_time = slap_get_time();
389 op->o_do_not_cache = 1;
390 op->o_threadctx = ldap_pvt_thread_pool_context();
391 op->o_tmpmemctx = NULL;
392 op->o_tmpmfuncs = &ch_mfuncs;
394 op->o_connid = conn->c_connid;
396 rc = slapi_int_pblock_get_operation( pb, op, rs );
398 slapi_pblock_set( op->o_pb, SLAPI_OPERATION, op );
399 slapi_pblock_set( op->o_pb, SLAPI_CONNECTION, conn );
401 ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
403 if ( rc != LDAP_SUCCESS ) {
404 slapi_int_connection_destroy( &conn );
413 void slapi_int_connection_destroy( Connection **pConn )
415 Connection *conn = *pConn;
418 if ( conn == NULL ) {
422 op = (Operation *)conn->c_pending_ops.stqh_first;
424 slap_graduate_commit_csn( op );
426 if ( op->o_req_dn.bv_val != NULL ) {
427 slapi_ch_free( (void **)&op->o_req_dn.bv_val );
429 if ( op->o_req_ndn.bv_val != NULL ) {
430 slapi_ch_free( (void **)&op->o_req_ndn.bv_val );
433 if ( conn->c_sb != NULL ) {
434 ber_sockbuf_free( conn->c_sb );
437 slapi_pblock_set( op->o_pb, SLAPI_OPERATION, NULL );
438 slapi_pblock_set( op->o_pb, SLAPI_CONNECTION, NULL );
441 slapi_ch_free( (void **)&op );
444 slapi_ch_free( (void **)pConn );
448 * Function : values2obj
449 * Convert an array of strings into a BerVarray.
460 if ( ppValue == NULL ) {
465 for ( i = 0; ppValue[i] != NULL; i++ )
468 tmpberval = (BerVarray)slapi_ch_malloc( (i+1) * (sizeof(struct berval)) );
469 if ( tmpberval == NULL ) {
470 return LDAP_NO_MEMORY;
472 for ( i = 0; ppValue[i] != NULL; i++ ) {
473 size_t len = strlen( ppValue[i] );
475 tmpberval[i].bv_val = slapi_ch_malloc( len + 1 );
476 AC_MEMCPY( tmpberval[i].bv_val, ppValue[i], len + 1 );
477 tmpberval[i].bv_len = len;
479 tmpberval[i].bv_val = NULL;
480 tmpberval[i].bv_len = 0;
489 struct berval **bvptr,
495 if ( bvptr == NULL ) {
500 for ( i = 0; bvptr[i] != NULL; i++ )
503 tmpberval = (BerVarray)slapi_ch_malloc( (i + 1) * sizeof(struct berval));
504 if ( tmpberval == NULL ) {
505 return LDAP_NO_MEMORY;
508 for ( i = 0; bvptr[i] != NULL; i++ ) {
509 tmpberval[i].bv_val = slapi_ch_malloc( bvptr[i]->bv_len );
510 tmpberval[i].bv_len = bvptr[i]->bv_len;
511 AC_MEMCPY( tmpberval[i].bv_val, bvptr[i]->bv_val, bvptr[i]->bv_len );
514 tmpberval[i].bv_val = NULL;
515 tmpberval[i].bv_len = 0;
523 * Function : slapi_int_ldapmod_to_entry
524 * convert a dn plus an array of LDAPMod struct ptrs to an entry structure
525 * with a link list of the correspondent attributes.
526 * Return value : LDAP_SUCCESS
531 slapi_int_ldapmod_to_entry(
536 struct berval dn = BER_BVNULL;
542 Modifications *modlist = NULL;
543 Modifications **modtail = &modlist;
546 int rc = LDAP_SUCCESS;
549 const char *text = NULL;
551 op = (Operation *)pConn->c_pending_ops.stqh_first;
553 pEntry = (Entry *) ch_calloc( 1, sizeof(Entry) );
554 if ( pEntry == NULL) {
560 dn.bv_len = strlen( ldn );
562 rc = dnPrettyNormal( NULL, &dn, &pEntry->e_name, &pEntry->e_nname, NULL );
563 if ( rc != LDAP_SUCCESS ) {
567 if ( rc == LDAP_SUCCESS ) {
568 for ( i = 0, pMod = mods[0]; rc == LDAP_SUCCESS && pMod != NULL; pMod = mods[++i]) {
571 if ( (pMod->mod_op & LDAP_MOD_BVALUES) != 0 ) {
573 * Convert an array of pointers to bervals to
574 * an array of bervals. Note that we need to copy the
575 * values too, as the slap_mods_check() will free the
576 * original values after prettying; the modifications
577 * being passed in may not have been allocated on the
580 rc = bvptr2obj_copy( pMod->mod_bvalues, &bv );
581 if ( rc != LDAP_SUCCESS ) goto cleanup;
582 tmp.sml_type.bv_val = pMod->mod_type;
583 tmp.sml_type.bv_len = strlen( pMod->mod_type );
585 tmp.sml_nvalues = NULL;
587 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
589 mod->sml_op = LDAP_MOD_ADD;
591 mod->sml_next = NULL;
592 mod->sml_desc = NULL;
593 mod->sml_type = tmp.sml_type;
594 mod->sml_values = tmp.sml_values;
595 mod->sml_nvalues = tmp.sml_nvalues;
598 modtail = &mod->sml_next;
601 /* attr values are in string format, need to be converted */
602 /* to an array of bervals */
603 if ( pMod->mod_values == NULL ) {
606 rc = values2obj_copy( pMod->mod_values, &bv );
607 if ( rc != LDAP_SUCCESS ) goto cleanup;
608 tmp.sml_type.bv_val = pMod->mod_type;
609 tmp.sml_type.bv_len = strlen( pMod->mod_type );
611 tmp.sml_nvalues = NULL;
613 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
615 mod->sml_op = LDAP_MOD_ADD;
617 mod->sml_next = NULL;
618 mod->sml_desc = NULL;
619 mod->sml_type = tmp.sml_type;
620 mod->sml_values = tmp.sml_values;
621 mod->sml_nvalues = tmp.sml_nvalues;
624 modtail = &mod->sml_next;
627 } /* for each LDAPMod */
630 op->o_bd = select_backend( &pEntry->e_nname, 0, 0 );
631 if ( op->o_bd == NULL ) {
632 rc = LDAP_PARTIAL_RESULTS;
634 int repl_user = be_isupdate_dn( op->o_bd, &op->o_bd->be_rootdn );
635 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
636 int update = !BER_BVISNULL( &op->o_bd->be_update_ndn );
637 char textbuf[ SLAP_TEXT_BUFLEN ];
638 size_t textlen = sizeof( textbuf );
640 rc = slap_mods_check( modlist, &text,
641 textbuf, textlen, NULL );
643 if ( rc != LDAP_SUCCESS) {
648 rc = slap_mods_no_user_mod_check( op, modlist,
649 &text, textbuf, textlen );
650 if ( rc != LDAP_SUCCESS) {
656 rc = slap_mods_opattrs( op, modlist, modtail,
657 &text, textbuf, textlen, 1 );
658 if ( rc != LDAP_SUCCESS) {
663 rc = slap_mods2entry( modlist, &pEntry, repl_user,
664 0, &text, textbuf, textlen );
665 if (rc != LDAP_SUCCESS) {
675 if ( modlist != NULL )
676 slap_mods_free( modlist );
677 if ( rc != LDAP_SUCCESS ) {
678 if ( pEntry != NULL ) {
679 slapi_entry_free( pEntry );
688 slapi_delete_internal_pb( Slapi_PBlock *pb )
691 Connection *conn = NULL;
692 Operation *op = NULL;
693 int operation_flags = 0;
695 SlapReply rs = { REP_RESULT };
701 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, &operation_flags );
703 rs.sr_err = slapi_int_init_connection( pb, &rs, LDAP_REQ_DELETE, &conn );
704 if ( rs.sr_err != LDAP_SUCCESS ) {
708 op = conn->c_pending_ops.stqh_first;
710 if ( op->o_bd->be_delete != NULL ) {
711 int repl_user = be_isupdate( op );
712 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
713 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
714 if ( operation_flags & SLAPI_OP_FLAG_LOG_CHANGE )
715 op->o_callback = &cb;
717 op->o_bd->be_delete( op, &rs );
719 rs.sr_err = LDAP_REFERRAL;
722 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
726 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
727 slapi_int_connection_destroy( &conn );
732 #endif /* LDAP_SLAPI */
736 slapi_add_internal_pb( Slapi_PBlock *pb )
739 Connection *conn = NULL;
740 Slapi_Entry *entry = NULL;
741 Slapi_Entry *argEntry = NULL;
743 LDAPMod **mods = NULL;
744 int operation_flags = 0;
745 Operation *op = NULL;
748 SlapReply rs = { REP_RESULT };
754 slapi_pblock_get( pb, SLAPI_ADD_ENTRY, (void **)&argEntry );
755 slapi_pblock_get( pb, SLAPI_ADD_TARGET, (void **)&dn );
756 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&mods );
757 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, (void **)&operation_flags );
759 if ( argEntry != NULL ) {
761 * The caller can specify a new entry, or a target DN and set
762 * of modifications, but not both.
765 rs.sr_err = LDAP_PARAM_ERROR;
770 * Set the DN here so that slapi_int_init_backend() will select
773 dn = slapi_entry_get_dn( argEntry );
774 slapi_pblock_set( pb, SLAPI_ADD_TARGET, &entry->e_nname.bv_val );
777 rs.sr_err = slapi_int_init_connection( pb, &rs, LDAP_REQ_ADD, &conn );
778 if ( rs.sr_err != LDAP_SUCCESS ) {
782 if ( argEntry != NULL ) {
783 entry = slapi_entry_dup( argEntry );
785 if ( mods == NULL || dn == NULL ) {
786 rs.sr_err = LDAP_PARAM_ERROR;
790 for ( i = 0; mods[i] != NULL; i++ ) {
791 if ( (mods[i]->mod_op & LDAP_MOD_OP ) != LDAP_MOD_ADD ) {
792 rs.sr_err = LDAP_PARAM_ERROR;
797 entry = slapi_int_ldapmod_to_entry( conn, dn, mods );
798 if ( entry == NULL ) {
799 rs.sr_err = LDAP_OTHER;
804 op = (Operation *)conn->c_pending_ops.stqh_first;
805 op->oq_add.rs_e = entry;
807 if ( op->o_bd->be_add != NULL ) {
808 int repl_user = be_isupdate( op );
809 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
810 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
812 if ( operation_flags & SLAPI_OP_FLAG_LOG_CHANGE )
813 op->o_callback = &cb;
815 if ( op->o_bd->be_add( op, &rs ) == LDAP_SUCCESS ) {
816 be_entry_release_w( op, entry );
820 rs.sr_err = LDAP_REFERRAL;
823 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
827 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
829 if ( entry != NULL ) {
830 slapi_entry_free( entry );
832 if ( argEntry != NULL ) {
833 slapi_pblock_set( pb, SLAPI_ADD_TARGET, NULL );
836 slapi_int_connection_destroy( &conn );
841 #endif /* LDAP_SLAPI */
845 slapi_modrdn_internal_pb( Slapi_PBlock *pb )
848 struct berval dn = BER_BVNULL;
849 struct berval newrdn = BER_BVNULL;
850 struct berval newsupdn = BER_BVNULL;
851 struct berval newSuperiorPretty = BER_BVNULL;
852 struct berval newSuperiorNormalized = BER_BVNULL;
853 Connection *conn = NULL;
854 Operation *op = NULL;
855 int manageDsaIt = SLAP_CONTROL_NONE;
863 SlapReply rs = { REP_RESULT };
869 slapi_pblock_get( pb, SLAPI_MODRDN_NEWRDN, (void **)&lnewrdn );
870 slapi_pblock_get( pb, SLAPI_MODRDN_NEWSUPERIOR, (void **)&newsuperior );
871 slapi_pblock_get( pb, SLAPI_MODRDN_DELOLDRDN, (void **)&deloldrdn );
872 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, (void **)&operation_flags );
874 rs.sr_err = slapi_int_init_connection( pb, &rs, LDAP_REQ_MODRDN, &conn );
875 if ( rs.sr_err != LDAP_SUCCESS ) {
879 op = (Operation *)conn->c_pending_ops.stqh_first;
881 if ( op->o_req_dn.bv_len == 0 ) {
882 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
886 newrdn.bv_val = lnewrdn;
887 newrdn.bv_len = strlen( lnewrdn );
889 rs.sr_err = dnPrettyNormal( NULL, &newrdn, &op->oq_modrdn.rs_newrdn, &op->oq_modrdn.rs_nnewrdn, NULL );
890 if ( rs.sr_err != LDAP_SUCCESS ) {
894 if ( rdn_validate( &op->oq_modrdn.rs_nnewrdn ) != LDAP_SUCCESS ) {
898 if ( newsuperior != NULL ) {
899 newsupdn.bv_val = (char *)newsuperior;
900 newsupdn.bv_len = strlen( newsuperior );
902 rs.sr_err = dnPrettyNormal( NULL, &newsupdn, &newSuperiorPretty, &newSuperiorNormalized, NULL );
903 if ( rs.sr_err != LDAP_SUCCESS )
906 op->oq_modrdn.rs_newSup = &newSuperiorPretty;
907 op->oq_modrdn.rs_nnewSup = &newSuperiorNormalized;
909 op->oq_modrdn.rs_newSup = NULL;
910 op->oq_modrdn.rs_nnewSup = NULL;
913 op->oq_modrdn.rs_deleteoldrdn = deloldrdn;
915 if ( op->o_bd->be_modrdn != NULL ) {
916 int repl_user = be_isupdate( op );
917 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
918 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
920 if ( operation_flags & SLAPI_OP_FLAG_LOG_CHANGE )
921 op->o_callback = &cb;
923 op->o_bd->be_modrdn( op, &rs );
925 rs.sr_err = LDAP_REFERRAL;
928 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
932 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
934 if ( op->oq_modrdn.rs_newrdn.bv_val != NULL )
935 slapi_ch_free_string( &op->oq_modrdn.rs_newrdn.bv_val );
936 if ( op->oq_modrdn.rs_nnewrdn.bv_val != NULL )
937 slapi_ch_free_string( &op->oq_modrdn.rs_nnewrdn.bv_val );
938 if ( newSuperiorPretty.bv_val != NULL )
939 slapi_ch_free_string( &newSuperiorPretty.bv_val );
940 if ( newSuperiorNormalized.bv_val != NULL )
941 slapi_ch_free_string( &newSuperiorNormalized.bv_val );
943 slapi_int_connection_destroy( &conn );
948 #endif /* LDAP_SLAPI */
951 int slapi_modify_internal_pb( Slapi_PBlock *pb )
955 Connection *conn = NULL;
956 Operation *op = NULL;
958 struct berval dn = BER_BVNULL;
960 int manageDsaIt = SLAP_CONTROL_NONE;
965 Modifications *modlist = NULL;
966 Modifications **modtail = &modlist;
969 LDAPMod **mods = NULL;
970 int operation_flags = 0;
972 SlapReply rs = { REP_RESULT };
978 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&mods );
979 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, (void **)&operation_flags );
981 if ( mods == NULL || mods[0] == NULL ) {
982 rs.sr_err = LDAP_PARAM_ERROR ;
986 rs.sr_err = slapi_int_init_connection( pb, &rs, LDAP_REQ_MODIFY, &conn );
987 if ( rs.sr_err != LDAP_SUCCESS ) {
991 for ( i = 0, pMod = mods[0];
992 rs.sr_err == LDAP_SUCCESS && pMod != NULL;
997 if ( (pMod->mod_op & LDAP_MOD_BVALUES) != 0 ) {
999 * attr values are in berval format
1000 * convert an array of pointers to bervals
1001 * to an array of bervals
1003 rs.sr_err = bvptr2obj_copy( pMod->mod_bvalues, &bv );
1004 if ( rs.sr_err != LDAP_SUCCESS )
1006 tmp.sml_type.bv_val = pMod->mod_type;
1007 tmp.sml_type.bv_len = strlen( pMod->mod_type );
1008 tmp.sml_values = bv;
1009 tmp.sml_nvalues = NULL;
1011 mod = (Modifications *)ch_malloc( sizeof(Modifications) );
1013 mod->sml_op = pMod->mod_op & LDAP_MOD_OP;
1015 mod->sml_next = NULL;
1016 mod->sml_desc = NULL;
1017 mod->sml_type = tmp.sml_type;
1018 mod->sml_values = tmp.sml_values;
1019 mod->sml_nvalues = tmp.sml_nvalues;
1021 rs.sr_err = values2obj_copy( pMod->mod_values, &bv );
1022 if ( rs.sr_err != LDAP_SUCCESS )
1024 tmp.sml_type.bv_val = pMod->mod_type;
1025 tmp.sml_type.bv_len = strlen( pMod->mod_type );
1026 tmp.sml_values = bv;
1027 tmp.sml_nvalues = NULL;
1029 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
1031 mod->sml_op = pMod->mod_op & LDAP_MOD_OP;
1033 mod->sml_next = NULL;
1034 mod->sml_desc = NULL;
1035 mod->sml_type = tmp.sml_type;
1036 mod->sml_values = tmp.sml_values;
1037 mod->sml_nvalues = tmp.sml_nvalues;
1040 modtail = &mod->sml_next;
1042 switch( pMod->mod_op & LDAP_MOD_OP ) {
1044 if ( mod->sml_values == NULL ) {
1045 rs.sr_err = LDAP_PROTOCOL_ERROR;
1050 case LDAP_MOD_DELETE:
1051 case LDAP_MOD_REPLACE:
1052 case LDAP_MOD_INCREMENT:
1056 rs.sr_err = LDAP_PROTOCOL_ERROR;
1062 op = (Operation *)conn->c_pending_ops.stqh_first;
1064 if ( op->o_req_ndn.bv_len == 0 ) {
1065 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
1069 op->oq_modify.rs_modlist = modlist;
1071 if ( op->o_bd->be_modify != NULL ) {
1072 int repl_user = be_isupdate( op );
1073 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
1074 int update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn );
1075 const char *text = NULL;
1076 char textbuf[ SLAP_TEXT_BUFLEN ];
1077 size_t textlen = sizeof( textbuf );
1078 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
1080 rs.sr_err = slap_mods_check( modlist,
1081 &text, textbuf, textlen, NULL );
1082 if ( rs.sr_err != LDAP_SUCCESS ) {
1087 rs.sr_err = slap_mods_no_user_mod_check( op, modlist,
1088 &text, textbuf, textlen );
1089 if ( rs.sr_err != LDAP_SUCCESS ) {
1095 rs.sr_err = slap_mods_opattrs( op, modlist,
1096 modtail, &text, textbuf,
1098 if ( rs.sr_err != LDAP_SUCCESS ) {
1103 if ( operation_flags & SLAPI_OP_FLAG_LOG_CHANGE )
1104 op->o_callback = &cb;
1106 op->o_bd->be_modify( op, &rs );
1108 rs.sr_err = LDAP_REFERRAL;
1111 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
1115 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
1117 if ( modlist != NULL )
1118 slap_mods_free( modlist );
1120 slapi_int_connection_destroy( &conn );
1125 #endif /* LDAP_SLAPI */
1130 slapi_int_search_entry_callback( Slapi_Entry *entry, void *callback_data )
1132 int nentries = 0, i = 0;
1133 Slapi_Entry **head = NULL, **tp;
1134 Slapi_PBlock *pb = (Slapi_PBlock *)callback_data;
1136 entry = slapi_entry_dup( entry );
1137 if ( entry == NULL ) {
1141 slapi_pblock_get( pb, SLAPI_NENTRIES, &nentries );
1142 slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &head );
1145 if ( nentries == 0 ) {
1146 tp = (Slapi_Entry **)slapi_ch_malloc( 2 * sizeof(Slapi_Entry *) );
1148 slapi_entry_free( entry );
1154 tp = (Slapi_Entry **)slapi_ch_realloc( (char *)head,
1155 sizeof(Slapi_Entry *) * ( i + 1 ) );
1157 slapi_entry_free( entry );
1160 tp[ i - 1 ] = entry;
1164 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, (void *)tp );
1165 slapi_pblock_set( pb, SLAPI_NENTRIES, (void *)i );
1167 return LDAP_SUCCESS;
1169 #endif /* LDAP_SLAPI */
1171 int slapi_search_internal_pb( Slapi_PBlock *pb )
1174 return slapi_search_internal_callback_pb( pb,
1177 slapi_int_search_entry_callback,
1184 int slapi_search_internal_callback_pb( Slapi_PBlock *pb,
1185 void *callback_data,
1186 plugin_result_callback prc,
1187 plugin_search_entry_callback psec,
1188 plugin_referral_entry_callback prec )
1191 Connection *conn = NULL;
1192 Operation *op = NULL;
1193 struct berval dn = BER_BVNULL;
1194 Filter *filter = NULL;
1195 struct berval fstr = BER_BVNULL;
1196 AttributeName *an = NULL;
1197 const char *text = NULL;
1199 int manageDsaIt = SLAP_CONTROL_NONE;
1203 int scope = LDAP_SCOPE_BASE;
1204 char *filStr = NULL;
1205 LDAPControl **controls = NULL;
1206 char **attrs = NULL;
1207 char *uniqueid = NULL;
1209 int operation_flags = 0;
1212 SlapReply rs = { REP_RESULT };
1218 slapi_pblock_get( pb, SLAPI_SEARCH_SCOPE, (void **)&scope );
1219 slapi_pblock_get( pb, SLAPI_SEARCH_FILTER, (void **)&filter );
1220 slapi_pblock_get( pb, SLAPI_SEARCH_STRFILTER, (void **)&filStr );
1221 slapi_pblock_get( pb, SLAPI_SEARCH_ATTRS, (void **)&attrs );
1222 slapi_pblock_get( pb, SLAPI_SEARCH_ATTRSONLY, (void **)&attrsonly );
1223 slapi_pblock_get( pb, SLAPI_REQCONTROLS, (void **)&controls );
1224 slapi_pblock_get( pb, SLAPI_TARGET_UNIQUEID, (void **)&uniqueid );
1225 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, (void **)&operation_flags );
1227 rs.sr_err = slapi_int_init_connection( pb, &rs, LDAP_REQ_SEARCH, &conn );
1228 if ( rs.sr_err != LDAP_SUCCESS ) {
1232 /* search callback and arguments */
1233 slapi_pblock_set( pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void *)prc );
1234 slapi_pblock_set( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, (void *)psec );
1235 slapi_pblock_set( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, (void *)prec );
1236 slapi_pblock_set( pb, SLAPI_X_INTOP_CALLBACK_DATA, (void *)callback_data );
1238 op = (Operation *)conn->c_pending_ops.stqh_first;
1241 case LDAP_SCOPE_BASE:
1242 case LDAP_SCOPE_ONELEVEL:
1243 case LDAP_SCOPE_SUBTREE:
1244 #ifdef LDAP_SCOPE_SUBORDINATE
1245 case LDAP_SCOPE_SUBORDINATE:
1249 rs.sr_err = LDAP_PROTOCOL_ERROR;
1253 if ( filter == NULL ) {
1254 if ( filStr == NULL ) {
1255 rs.sr_err = LDAP_PARAM_ERROR;
1259 filter = slapi_str2filter( filStr );
1260 if ( filter == NULL ) {
1261 rs.sr_err = LDAP_PROTOCOL_ERROR;
1268 filter2bv( filter, &fstr );
1270 for ( i = 0; attrs != NULL && attrs[i] != NULL; i++ ) {
1271 ; /* count the number of attributes */
1275 an = (AttributeName *)slapi_ch_calloc( (i + 1), sizeof(AttributeName) );
1276 for (i = 0; attrs[i] != 0; i++) {
1277 an[i].an_desc = NULL;
1279 an[i].an_oc_exclude = 0;
1280 an[i].an_name.bv_val = slapi_ch_strdup(attrs[i]);
1281 an[i].an_name.bv_len = strlen(attrs[i]);
1282 slap_bv2ad( &an[i].an_name, &an[i].an_desc, &text );
1284 an[i].an_name.bv_val = NULL;
1287 rs.sr_type = REP_RESULT;
1288 rs.sr_err = LDAP_SUCCESS;
1289 rs.sr_entry = NULL; /* paranoia */
1291 if ( scope == LDAP_SCOPE_BASE ) {
1294 if ( op->o_req_ndn.bv_len == 0 ) {
1295 rs.sr_err = root_dse_info( conn, &rs.sr_entry, &rs.sr_text );
1298 if( rs.sr_err != LDAP_SUCCESS ) {
1299 send_ldap_result( op, &rs );
1301 } else if ( rs.sr_entry != NULL ) {
1302 rs.sr_err = test_filter( op, rs.sr_entry, filter );
1304 if ( rs.sr_err == LDAP_COMPARE_TRUE ) {
1305 rs.sr_type = REP_SEARCH;
1306 rs.sr_err = LDAP_SUCCESS;
1308 rs.sr_operational_attrs = NULL;
1309 rs.sr_flags = REP_ENTRY_MODIFIABLE;
1311 send_search_entry( op, &rs );
1314 entry_free( rs.sr_entry );
1316 rs.sr_type = REP_RESULT;
1317 rs.sr_err = LDAP_SUCCESS;
1319 send_ldap_result( op, &rs );
1325 op->oq_search.rs_scope = scope;
1326 op->oq_search.rs_deref = 0;
1327 op->oq_search.rs_slimit = SLAP_NO_LIMIT;
1328 op->oq_search.rs_tlimit = SLAP_NO_LIMIT;
1329 op->oq_search.rs_attrsonly = attrsonly;
1330 op->oq_search.rs_attrs = an;
1331 op->oq_search.rs_filter = filter;
1332 op->oq_search.rs_filterstr = fstr;
1334 if ( BER_BVISEMPTY( &op->o_req_ndn ) &&
1335 !BER_BVISEMPTY( &default_search_nbase ) ) {
1336 slapi_ch_free( (void **)&op->o_req_dn.bv_val );
1337 slapi_ch_free( (void **)&op->o_req_ndn.bv_val );
1339 ber_dupbv( &op->o_req_dn, &default_search_base );
1340 ber_dupbv( &op->o_req_ndn, &default_search_nbase );
1342 rs.sr_err = slapi_int_pblock_get_backend( pb, op );
1343 if ( rs.sr_err != LDAP_SUCCESS )
1347 if ( op->o_bd->be_search != NULL ) {
1348 (*op->o_bd->be_search)( op, &rs );
1350 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
1354 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
1355 slapi_pblock_set( pb, SLAPI_X_INTOP_RESULT_CALLBACK, NULL );
1356 slapi_pblock_set( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, NULL );
1357 slapi_pblock_set( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, NULL );
1358 slapi_pblock_set( pb, SLAPI_X_INTOP_CALLBACK_DATA, NULL );
1360 if ( freeFilter && filter != NULL )
1361 slapi_filter_free( filter, 1 );
1363 slapi_ch_free( (void **)&fstr.bv_val );
1365 slapi_ch_free( (void **)&an );
1367 slapi_int_connection_destroy( &conn );
1372 #endif /* LDAP_SLAPI */
1375 /* Wrappers for old API */
1377 void slapi_search_internal_set_pb( Slapi_PBlock *pb,
1383 LDAPControl **controls,
1384 const char *uniqueid,
1385 Slapi_ComponentId *plugin_identity,
1386 int operation_flags )
1389 slapi_pblock_set( pb, SLAPI_SEARCH_TARGET, (void *)base );
1390 slapi_pblock_set( pb, SLAPI_SEARCH_SCOPE, (void *)scope );
1391 slapi_pblock_set( pb, SLAPI_SEARCH_FILTER, NULL );
1392 slapi_pblock_set( pb, SLAPI_SEARCH_STRFILTER, (void *)filter );
1393 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRS, (void *)attrs );
1394 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRSONLY, (void *)attrsonly );
1395 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1396 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
1397 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1398 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1399 #endif /* LDAP_SLAPI */
1403 slapi_search_internal(
1407 LDAPControl **controls,
1414 pb = slapi_pblock_new();
1419 slapi_search_internal_set_pb( pb, ldn, scope, filStr, attrs, attrsonly,
1420 controls, NULL, NULL, 0 );
1422 slapi_search_internal_pb( pb );
1427 #endif /* LDAP_SLAPI */
1430 void slapi_modify_internal_set_pb( Slapi_PBlock *pb,
1433 LDAPControl **controls,
1434 const char *uniqueid,
1435 Slapi_ComponentId *plugin_identity,
1436 int operation_flags )
1439 slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn );
1440 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)mods );
1441 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1442 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
1443 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1444 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1445 #endif /* LDAP_SLAPI */
1448 /* Function : slapi_modify_internal
1450 * Description: Plugin functions call this routine to modify an entry
1451 * in the backend directly
1452 * Return values : LDAP_SUCCESS
1456 * LDAP_UNWILLING_TO_PERFORM
1459 slapi_modify_internal(
1462 LDAPControl **controls,
1468 pb = slapi_pblock_new();
1473 slapi_modify_internal_set_pb( pb, ldn, mods, controls, NULL, NULL,
1474 log_change ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1476 slapi_modify_internal_pb( pb );
1481 #endif /* LDAP_SLAPI */
1484 int slapi_add_internal_set_pb( Slapi_PBlock *pb,
1487 LDAPControl **controls,
1488 Slapi_ComponentId *plugin_identity,
1489 int operation_flags )
1492 slapi_pblock_set( pb, SLAPI_ADD_TARGET, (void *)dn );
1493 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)attrs );
1494 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1495 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1496 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1501 #endif /* LDAP_SLAPI */
1504 Slapi_PBlock *slapi_add_internal(
1507 LDAPControl **controls,
1513 pb = slapi_pblock_new();
1517 slapi_add_internal_set_pb( pb, dn, attrs, controls, NULL,
1518 log_changes ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1520 slapi_add_internal_pb( pb );
1525 #endif /* LDAP_SLAPI */
1528 void slapi_add_entry_internal_set_pb( Slapi_PBlock *pb,
1530 LDAPControl **controls,
1531 Slapi_ComponentId *plugin_identity,
1532 int operation_flags )
1535 slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)e );
1536 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1537 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1538 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1539 #endif /* LDAP_SLAPI */
1543 slapi_add_entry_internal(
1545 LDAPControl **controls,
1551 pb = slapi_pblock_new();
1555 slapi_add_entry_internal_set_pb( pb, e, controls, NULL,
1556 log_changes ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1558 slapi_add_internal_pb( pb );
1563 #endif /* LDAP_SLAPI */
1566 void slapi_rename_internal_set_pb( Slapi_PBlock *pb,
1569 const char *newsuperior,
1571 LDAPControl **controls,
1572 const char *uniqueid,
1573 Slapi_ComponentId *plugin_identity,
1574 int operation_flags )
1577 slapi_pblock_set( pb, SLAPI_MODRDN_TARGET, (void *)olddn );
1578 slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)newrdn );
1579 slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR, (void *)newsuperior );
1580 slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)deloldrdn );
1581 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1582 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
1583 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1584 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1585 #endif /* LDAP_SLAPI */
1588 /* Function : slapi_modrdn_internal
1590 * Description : Plugin functions call this routine to modify the rdn
1591 * of an entry in the backend directly
1592 * Return values : LDAP_SUCCESS
1596 * LDAP_UNWILLING_TO_PERFORM
1598 * NOTE: This function does not support the "newSuperior" option from LDAP V3.
1601 slapi_modrdn_internal(
1605 LDAPControl **controls,
1611 pb = slapi_pblock_new();
1616 slapi_rename_internal_set_pb( pb, olddn, lnewrdn, NULL,
1617 deloldrdn, controls, NULL, NULL,
1618 log_change ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1620 slapi_modrdn_internal_pb( pb );
1625 #endif /* LDAP_SLAPI */
1628 void slapi_delete_internal_set_pb( Slapi_PBlock *pb,
1630 LDAPControl **controls,
1631 const char *uniqueid,
1632 Slapi_ComponentId *plugin_identity,
1633 int operation_flags )
1636 slapi_pblock_set( pb, SLAPI_TARGET_DN, (void *)dn );
1637 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1638 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
1639 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1640 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1641 #endif /* LDAP_SLAPI */
1644 /* Function : slapi_delete_internal
1646 * Description : Plugin functions call this routine to delete an entry
1647 * in the backend directly
1648 * Return values : LDAP_SUCCESS
1652 * LDAP_UNWILLING_TO_PERFORM
1655 slapi_delete_internal(
1657 LDAPControl **controls,
1663 pb = slapi_pblock_new();
1667 slapi_delete_internal_set_pb( pb, ldn, controls, NULL, NULL,
1668 log_change ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1670 slapi_delete_internal_pb( pb );
1675 #endif /* LDAP_SLAPI */