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;
269 op->o_ndn.bv_val = requestorDn;
270 op->o_ndn.bv_len = strlen( requestorDn );
271 op->o_dn = op->o_ndn;
274 rc = slapi_int_pblock_get_connection( pb, op );
275 if ( rc != LDAP_SUCCESS ) {
279 slapi_pblock_get( pb, SLAPI_REQCONTROLS, (void **)&controls );
280 rc = slapi_int_get_ctrls( op, rs, controls );
281 if ( rc != LDAP_SUCCESS ) {
289 slapi_int_init_connection( Slapi_PBlock *pb,
296 ber_len_t max = sockbuf_max_incoming;
299 conn = (Connection *) slapi_ch_calloc(1, sizeof(Connection));
301 LDAP_STAILQ_INIT( &conn->c_pending_ops );
303 op = (Operation *) slapi_ch_calloc( 1, OPERATION_BUFFER_SIZE );
304 op->o_hdr = (Opheader *)(op + 1);
305 op->o_controls = (void **)(op->o_hdr + 1);
307 op->o_extensions = NULL;
309 conn->c_pending_ops.stqh_first = op;
311 /* connection object authorization information */
312 conn->c_authtype = LDAP_AUTH_NONE;
313 conn->c_authmech.bv_val = NULL;
314 conn->c_authmech.bv_len = 0;
315 conn->c_dn.bv_val = NULL;
316 conn->c_dn.bv_len = 0;
317 conn->c_ndn.bv_val = NULL;
318 conn->c_ndn.bv_len = 0;
320 conn->c_listener = &slap_unknown_listener;
321 ber_dupbv( &conn->c_peer_domain, (struct berval *)&slap_unknown_bv );
322 ber_dupbv( &conn->c_peer_name, (struct berval *)&slap_unknown_bv );
324 LDAP_STAILQ_INIT( &conn->c_ops );
326 conn->c_sasl_bind_mech.bv_val = NULL;
327 conn->c_sasl_bind_mech.bv_len = 0;
328 conn->c_sasl_authctx = NULL;
329 conn->c_sasl_sockctx = NULL;
330 conn->c_sasl_extra = NULL;
332 conn->c_sb = ber_sockbuf_alloc( );
334 ber_sockbuf_ctrl( conn->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max );
336 conn->c_currentber = NULL;
338 /* should check status of thread calls */
339 ldap_pvt_thread_mutex_init( &conn->c_mutex );
340 ldap_pvt_thread_mutex_init( &conn->c_write_mutex );
341 ldap_pvt_thread_cond_init( &conn->c_write_cv );
343 ldap_pvt_thread_mutex_lock( &conn->c_mutex );
345 conn->c_n_ops_received = 0;
346 conn->c_n_ops_executing = 0;
347 conn->c_n_ops_pending = 0;
348 conn->c_n_ops_completed = 0;
354 conn->c_protocol = LDAP_VERSION3;
356 conn->c_activitytime = conn->c_starttime = slap_get_time();
359 * A real connection ID is required, because syncrepl associates
360 * pending CSNs with unique ( connection, operation ) tuples.
361 * Setting a fake connection ID will cause slap_get_commit_csn()
362 * to return a stale value.
364 connection_assign_nextid( conn );
366 conn->c_conn_state = 0x01; /* SLAP_C_ACTIVE */
367 conn->c_struct_state = 0x02; /* SLAP_C_USED */
369 conn->c_ssf = conn->c_transport_ssf = 0;
372 backend_connection_init( conn );
374 conn->c_send_ldap_result = slapi_int_send_ldap_result_shim;
375 conn->c_send_search_entry = slapi_int_send_search_entry_shim;
376 conn->c_send_ldap_extended = slapi_int_send_ldap_extended_shim;
377 conn->c_send_search_reference = slapi_int_send_search_reference_shim;
379 /* operation object */
381 op->o_protocol = LDAP_VERSION3;
382 op->o_authmech.bv_val = NULL;
383 op->o_authmech.bv_len = 0;
384 op->o_time = slap_get_time();
385 op->o_do_not_cache = 1;
386 op->o_threadctx = ldap_pvt_thread_pool_context();
387 op->o_tmpmemctx = NULL;
388 op->o_tmpmfuncs = &ch_mfuncs;
390 op->o_connid = conn->c_connid;
392 rc = slapi_int_pblock_get_operation( pb, op, rs );
394 slapi_pblock_set( op->o_pb, SLAPI_OPERATION, op );
395 slapi_pblock_set( op->o_pb, SLAPI_CONNECTION, conn );
397 ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
399 if ( rc != LDAP_SUCCESS ) {
400 slapi_int_connection_destroy( &conn );
409 void slapi_int_connection_destroy( Connection **pConn )
411 Connection *conn = *pConn;
414 if ( conn == NULL ) {
418 op = (Operation *)conn->c_pending_ops.stqh_first;
420 slap_graduate_commit_csn( op );
422 if ( op->o_req_dn.bv_val != NULL ) {
423 slapi_ch_free( (void **)&op->o_req_dn.bv_val );
425 if ( op->o_req_ndn.bv_val != NULL ) {
426 slapi_ch_free( (void **)&op->o_req_ndn.bv_val );
429 if ( conn->c_sb != NULL ) {
430 ber_sockbuf_free( conn->c_sb );
433 slapi_pblock_set( op->o_pb, SLAPI_OPERATION, NULL );
434 slapi_pblock_set( op->o_pb, SLAPI_CONNECTION, NULL );
437 slapi_ch_free( (void **)&op );
440 slapi_ch_free( (void **)pConn );
444 * Function : values2obj
445 * Convert an array of strings into a BerVarray.
456 if ( ppValue == NULL ) {
461 for ( i = 0; ppValue[i] != NULL; i++ )
464 tmpberval = (BerVarray)slapi_ch_malloc( (i+1) * (sizeof(struct berval)) );
465 if ( tmpberval == NULL ) {
466 return LDAP_NO_MEMORY;
468 for ( i = 0; ppValue[i] != NULL; i++ ) {
469 size_t len = strlen( ppValue[i] );
471 tmpberval[i].bv_val = slapi_ch_malloc( len + 1 );
472 AC_MEMCPY( tmpberval[i].bv_val, ppValue[i], len + 1 );
473 tmpberval[i].bv_len = len;
475 tmpberval[i].bv_val = NULL;
476 tmpberval[i].bv_len = 0;
485 struct berval **bvptr,
491 if ( bvptr == NULL ) {
496 for ( i = 0; bvptr[i] != NULL; i++ )
499 tmpberval = (BerVarray)slapi_ch_malloc( (i + 1) * sizeof(struct berval));
500 if ( tmpberval == NULL ) {
501 return LDAP_NO_MEMORY;
504 for ( i = 0; bvptr[i] != NULL; i++ ) {
505 tmpberval[i].bv_val = slapi_ch_malloc( bvptr[i]->bv_len );
506 tmpberval[i].bv_len = bvptr[i]->bv_len;
507 AC_MEMCPY( tmpberval[i].bv_val, bvptr[i]->bv_val, bvptr[i]->bv_len );
510 tmpberval[i].bv_val = NULL;
511 tmpberval[i].bv_len = 0;
519 * Function : slapi_int_ldapmod_to_entry
520 * convert a dn plus an array of LDAPMod struct ptrs to an entry structure
521 * with a link list of the correspondent attributes.
522 * Return value : LDAP_SUCCESS
527 slapi_int_ldapmod_to_entry(
532 struct berval dn = BER_BVNULL;
538 Modifications *modlist = NULL;
539 Modifications **modtail = &modlist;
542 int rc = LDAP_SUCCESS;
545 const char *text = NULL;
547 op = (Operation *)pConn->c_pending_ops.stqh_first;
549 pEntry = (Entry *) ch_calloc( 1, sizeof(Entry) );
550 if ( pEntry == NULL) {
556 dn.bv_len = strlen( ldn );
558 rc = dnPrettyNormal( NULL, &dn, &pEntry->e_name, &pEntry->e_nname, NULL );
559 if ( rc != LDAP_SUCCESS ) {
563 if ( rc == LDAP_SUCCESS ) {
564 for ( i = 0, pMod = mods[0]; rc == LDAP_SUCCESS && pMod != NULL; pMod = mods[++i]) {
567 if ( (pMod->mod_op & LDAP_MOD_BVALUES) != 0 ) {
569 * Convert an array of pointers to bervals to
570 * an array of bervals. Note that we need to copy the
571 * values too, as the slap_mods_check() will free the
572 * original values after prettying; the modifications
573 * being passed in may not have been allocated on the
576 rc = bvptr2obj_copy( pMod->mod_bvalues, &bv );
577 if ( rc != LDAP_SUCCESS ) goto cleanup;
578 tmp.sml_type.bv_val = pMod->mod_type;
579 tmp.sml_type.bv_len = strlen( pMod->mod_type );
581 tmp.sml_nvalues = NULL;
583 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
585 mod->sml_op = LDAP_MOD_ADD;
587 mod->sml_next = NULL;
588 mod->sml_desc = NULL;
589 mod->sml_type = tmp.sml_type;
590 mod->sml_values = tmp.sml_values;
591 mod->sml_nvalues = tmp.sml_nvalues;
594 modtail = &mod->sml_next;
597 /* attr values are in string format, need to be converted */
598 /* to an array of bervals */
599 if ( pMod->mod_values == NULL ) {
602 rc = values2obj_copy( pMod->mod_values, &bv );
603 if ( rc != LDAP_SUCCESS ) goto cleanup;
604 tmp.sml_type.bv_val = pMod->mod_type;
605 tmp.sml_type.bv_len = strlen( pMod->mod_type );
607 tmp.sml_nvalues = NULL;
609 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
611 mod->sml_op = LDAP_MOD_ADD;
613 mod->sml_next = NULL;
614 mod->sml_desc = NULL;
615 mod->sml_type = tmp.sml_type;
616 mod->sml_values = tmp.sml_values;
617 mod->sml_nvalues = tmp.sml_nvalues;
620 modtail = &mod->sml_next;
623 } /* for each LDAPMod */
626 op->o_bd = select_backend( &pEntry->e_nname, 0, 0 );
627 if ( op->o_bd == NULL ) {
628 rc = LDAP_PARTIAL_RESULTS;
630 int repl_user = be_isupdate_dn( op->o_bd, &op->o_bd->be_rootdn );
631 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
632 int update = !BER_BVISNULL( &op->o_bd->be_update_ndn );
633 char textbuf[ SLAP_TEXT_BUFLEN ];
634 size_t textlen = sizeof( textbuf );
636 rc = slap_mods_check( modlist, &text,
637 textbuf, textlen, NULL );
639 if ( rc != LDAP_SUCCESS) {
644 rc = slap_mods_no_user_mod_check( op, modlist,
645 &text, textbuf, textlen );
646 if ( rc != LDAP_SUCCESS) {
652 rc = slap_mods_opattrs( op, modlist, modtail,
653 &text, textbuf, textlen, 1 );
654 if ( rc != LDAP_SUCCESS) {
659 rc = slap_mods2entry( modlist, &pEntry, repl_user,
660 0, &text, textbuf, textlen );
661 if (rc != LDAP_SUCCESS) {
671 if ( modlist != NULL )
672 slap_mods_free( modlist );
673 if ( rc != LDAP_SUCCESS ) {
674 if ( pEntry != NULL ) {
675 slapi_entry_free( pEntry );
684 slapi_delete_internal_pb( Slapi_PBlock *pb )
687 Connection *conn = NULL;
688 Operation *op = NULL;
689 int operation_flags = 0;
691 SlapReply rs = { REP_RESULT };
697 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, &operation_flags );
699 rs.sr_err = slapi_int_init_connection( pb, &rs, LDAP_REQ_DELETE, &conn );
700 if ( rs.sr_err != LDAP_SUCCESS ) {
704 op = conn->c_pending_ops.stqh_first;
706 if ( op->o_bd->be_delete != NULL ) {
707 int repl_user = be_isupdate( op );
708 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
709 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
710 if ( operation_flags & SLAPI_OP_FLAG_LOG_CHANGE )
711 op->o_callback = &cb;
713 op->o_bd->be_delete( op, &rs );
715 rs.sr_err = LDAP_REFERRAL;
718 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
722 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
723 slapi_int_connection_destroy( &conn );
728 #endif /* LDAP_SLAPI */
732 slapi_add_internal_pb( Slapi_PBlock *pb )
735 Connection *conn = NULL;
736 Slapi_Entry *entry = NULL;
737 Slapi_Entry *argEntry = NULL;
739 LDAPMod **mods = NULL;
740 int operation_flags = 0;
741 Operation *op = NULL;
744 SlapReply rs = { REP_RESULT };
750 slapi_pblock_get( pb, SLAPI_ADD_ENTRY, (void **)&argEntry );
751 slapi_pblock_get( pb, SLAPI_ADD_TARGET, (void **)&dn );
752 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&mods );
753 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, (void **)&operation_flags );
755 if ( argEntry != NULL ) {
757 * The caller can specify a new entry, or a target DN and set
758 * of modifications, but not both.
761 rs.sr_err = LDAP_PARAM_ERROR;
766 * Set the DN here so that slapi_int_init_backend() will select
769 dn = slapi_entry_get_dn( argEntry );
770 slapi_pblock_set( pb, SLAPI_ADD_TARGET, &entry->e_nname.bv_val );
773 rs.sr_err = slapi_int_init_connection( pb, &rs, LDAP_REQ_ADD, &conn );
774 if ( rs.sr_err != LDAP_SUCCESS ) {
778 if ( argEntry != NULL ) {
779 entry = slapi_entry_dup( argEntry );
781 if ( mods == NULL || dn == NULL ) {
782 rs.sr_err = LDAP_PARAM_ERROR;
786 for ( i = 0; mods[i] != NULL; i++ ) {
787 if ( (mods[i]->mod_op & LDAP_MOD_OP ) != LDAP_MOD_ADD ) {
788 rs.sr_err = LDAP_PARAM_ERROR;
793 entry = slapi_int_ldapmod_to_entry( conn, dn, mods );
794 if ( entry == NULL ) {
795 rs.sr_err = LDAP_OTHER;
800 op = (Operation *)conn->c_pending_ops.stqh_first;
801 op->oq_add.rs_e = entry;
803 if ( op->o_bd->be_add != NULL ) {
804 int repl_user = be_isupdate( op );
805 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
806 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
808 if ( operation_flags & SLAPI_OP_FLAG_LOG_CHANGE )
809 op->o_callback = &cb;
811 if ( op->o_bd->be_add( op, &rs ) == LDAP_SUCCESS ) {
812 be_entry_release_w( op, entry );
816 rs.sr_err = LDAP_REFERRAL;
819 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
823 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
825 if ( entry != NULL ) {
826 slapi_entry_free( entry );
828 if ( argEntry != NULL ) {
829 slapi_pblock_set( pb, SLAPI_ADD_TARGET, NULL );
832 slapi_int_connection_destroy( &conn );
837 #endif /* LDAP_SLAPI */
841 slapi_modrdn_internal_pb( Slapi_PBlock *pb )
844 struct berval dn = BER_BVNULL;
845 struct berval newrdn = BER_BVNULL;
846 struct berval newsupdn = BER_BVNULL;
847 struct berval newSuperiorPretty = BER_BVNULL;
848 struct berval newSuperiorNormalized = BER_BVNULL;
849 Connection *conn = NULL;
850 Operation *op = NULL;
851 int manageDsaIt = SLAP_CONTROL_NONE;
859 SlapReply rs = { REP_RESULT };
865 slapi_pblock_get( pb, SLAPI_MODRDN_NEWRDN, (void **)&lnewrdn );
866 slapi_pblock_get( pb, SLAPI_MODRDN_NEWSUPERIOR, (void **)&newsuperior );
867 slapi_pblock_get( pb, SLAPI_MODRDN_DELOLDRDN, (void **)&deloldrdn );
868 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, (void **)&operation_flags );
870 rs.sr_err = slapi_int_init_connection( pb, &rs, LDAP_REQ_MODRDN, &conn );
871 if ( rs.sr_err != LDAP_SUCCESS ) {
875 op = (Operation *)conn->c_pending_ops.stqh_first;
877 if ( op->o_req_dn.bv_len == 0 ) {
878 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
882 newrdn.bv_val = lnewrdn;
883 newrdn.bv_len = strlen( lnewrdn );
885 rs.sr_err = dnPrettyNormal( NULL, &newrdn, &op->oq_modrdn.rs_newrdn, &op->oq_modrdn.rs_nnewrdn, NULL );
886 if ( rs.sr_err != LDAP_SUCCESS ) {
890 if ( rdn_validate( &op->oq_modrdn.rs_nnewrdn ) != LDAP_SUCCESS ) {
894 if ( newsuperior != NULL ) {
895 newsupdn.bv_val = (char *)newsuperior;
896 newsupdn.bv_len = strlen( newsuperior );
898 rs.sr_err = dnPrettyNormal( NULL, &newsupdn, &newSuperiorPretty, &newSuperiorNormalized, NULL );
899 if ( rs.sr_err != LDAP_SUCCESS )
902 op->oq_modrdn.rs_newSup = &newSuperiorPretty;
903 op->oq_modrdn.rs_nnewSup = &newSuperiorNormalized;
905 op->oq_modrdn.rs_newSup = NULL;
906 op->oq_modrdn.rs_nnewSup = NULL;
909 op->oq_modrdn.rs_deleteoldrdn = deloldrdn;
911 if ( op->o_bd->be_modrdn != NULL ) {
912 int repl_user = be_isupdate( op );
913 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
914 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
916 if ( operation_flags & SLAPI_OP_FLAG_LOG_CHANGE )
917 op->o_callback = &cb;
919 op->o_bd->be_modrdn( op, &rs );
921 rs.sr_err = LDAP_REFERRAL;
924 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
928 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
930 if ( op->oq_modrdn.rs_newrdn.bv_val != NULL )
931 slapi_ch_free_string( &op->oq_modrdn.rs_newrdn.bv_val );
932 if ( op->oq_modrdn.rs_nnewrdn.bv_val != NULL )
933 slapi_ch_free_string( &op->oq_modrdn.rs_nnewrdn.bv_val );
934 if ( newSuperiorPretty.bv_val != NULL )
935 slapi_ch_free_string( &newSuperiorPretty.bv_val );
936 if ( newSuperiorNormalized.bv_val != NULL )
937 slapi_ch_free_string( &newSuperiorNormalized.bv_val );
939 slapi_int_connection_destroy( &conn );
944 #endif /* LDAP_SLAPI */
947 int slapi_modify_internal_pb( Slapi_PBlock *pb )
951 Connection *conn = NULL;
952 Operation *op = NULL;
954 struct berval dn = BER_BVNULL;
956 int manageDsaIt = SLAP_CONTROL_NONE;
961 Modifications *modlist = NULL;
962 Modifications **modtail = &modlist;
965 LDAPMod **mods = NULL;
966 int operation_flags = 0;
968 SlapReply rs = { REP_RESULT };
974 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&mods );
975 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, (void **)&operation_flags );
977 if ( mods == NULL || mods[0] == NULL ) {
978 rs.sr_err = LDAP_PARAM_ERROR ;
982 rs.sr_err = slapi_int_init_connection( pb, &rs, LDAP_REQ_MODIFY, &conn );
983 if ( rs.sr_err != LDAP_SUCCESS ) {
987 for ( i = 0, pMod = mods[0];
988 rs.sr_err == LDAP_SUCCESS && pMod != NULL;
993 if ( (pMod->mod_op & LDAP_MOD_BVALUES) != 0 ) {
995 * attr values are in berval format
996 * convert an array of pointers to bervals
997 * to an array of bervals
999 rs.sr_err = bvptr2obj_copy( pMod->mod_bvalues, &bv );
1000 if ( rs.sr_err != LDAP_SUCCESS )
1002 tmp.sml_type.bv_val = pMod->mod_type;
1003 tmp.sml_type.bv_len = strlen( pMod->mod_type );
1004 tmp.sml_values = bv;
1005 tmp.sml_nvalues = NULL;
1007 mod = (Modifications *)ch_malloc( sizeof(Modifications) );
1009 mod->sml_op = pMod->mod_op & LDAP_MOD_OP;
1011 mod->sml_next = NULL;
1012 mod->sml_desc = NULL;
1013 mod->sml_type = tmp.sml_type;
1014 mod->sml_values = tmp.sml_values;
1015 mod->sml_nvalues = tmp.sml_nvalues;
1017 rs.sr_err = values2obj_copy( pMod->mod_values, &bv );
1018 if ( rs.sr_err != LDAP_SUCCESS )
1020 tmp.sml_type.bv_val = pMod->mod_type;
1021 tmp.sml_type.bv_len = strlen( pMod->mod_type );
1022 tmp.sml_values = bv;
1023 tmp.sml_nvalues = NULL;
1025 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
1027 mod->sml_op = pMod->mod_op & LDAP_MOD_OP;
1029 mod->sml_next = NULL;
1030 mod->sml_desc = NULL;
1031 mod->sml_type = tmp.sml_type;
1032 mod->sml_values = tmp.sml_values;
1033 mod->sml_nvalues = tmp.sml_nvalues;
1036 modtail = &mod->sml_next;
1038 switch( pMod->mod_op & LDAP_MOD_OP ) {
1040 if ( mod->sml_values == NULL ) {
1041 rs.sr_err = LDAP_PROTOCOL_ERROR;
1046 case LDAP_MOD_DELETE:
1047 case LDAP_MOD_REPLACE:
1048 case LDAP_MOD_INCREMENT:
1052 rs.sr_err = LDAP_PROTOCOL_ERROR;
1058 op = (Operation *)conn->c_pending_ops.stqh_first;
1060 if ( op->o_req_ndn.bv_len == 0 ) {
1061 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
1065 op->oq_modify.rs_modlist = modlist;
1067 if ( op->o_bd->be_modify != NULL ) {
1068 int repl_user = be_isupdate( op );
1069 if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
1070 int update = !BER_BVISEMPTY( &op->o_bd->be_update_ndn );
1071 const char *text = NULL;
1072 char textbuf[ SLAP_TEXT_BUFLEN ];
1073 size_t textlen = sizeof( textbuf );
1074 slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
1076 rs.sr_err = slap_mods_check( modlist,
1077 &text, textbuf, textlen, NULL );
1078 if ( rs.sr_err != LDAP_SUCCESS ) {
1083 rs.sr_err = slap_mods_no_user_mod_check( op, modlist,
1084 &text, textbuf, textlen );
1085 if ( rs.sr_err != LDAP_SUCCESS ) {
1091 rs.sr_err = slap_mods_opattrs( op, modlist,
1092 modtail, &text, textbuf,
1094 if ( rs.sr_err != LDAP_SUCCESS ) {
1099 if ( operation_flags & SLAPI_OP_FLAG_LOG_CHANGE )
1100 op->o_callback = &cb;
1102 op->o_bd->be_modify( op, &rs );
1104 rs.sr_err = LDAP_REFERRAL;
1107 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
1111 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
1113 if ( modlist != NULL )
1114 slap_mods_free( modlist );
1116 slapi_int_connection_destroy( &conn );
1121 #endif /* LDAP_SLAPI */
1126 slapi_int_search_entry_callback( Slapi_Entry *entry, void *callback_data )
1128 int nentries = 0, i = 0;
1129 Slapi_Entry **head = NULL, **tp;
1130 Slapi_PBlock *pb = (Slapi_PBlock *)callback_data;
1132 entry = slapi_entry_dup( entry );
1133 if ( entry == NULL ) {
1137 slapi_pblock_get( pb, SLAPI_NENTRIES, &nentries );
1138 slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &head );
1141 if ( nentries == 0 ) {
1142 tp = (Slapi_Entry **)slapi_ch_malloc( 2 * sizeof(Slapi_Entry *) );
1144 slapi_entry_free( entry );
1150 tp = (Slapi_Entry **)slapi_ch_realloc( (char *)head,
1151 sizeof(Slapi_Entry *) * ( i + 1 ) );
1153 slapi_entry_free( entry );
1156 tp[ i - 1 ] = entry;
1160 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, (void *)tp );
1161 slapi_pblock_set( pb, SLAPI_NENTRIES, (void *)i );
1163 return LDAP_SUCCESS;
1165 #endif /* LDAP_SLAPI */
1167 int slapi_search_internal_pb( Slapi_PBlock *pb )
1170 return slapi_search_internal_callback_pb( pb,
1173 slapi_int_search_entry_callback,
1180 int slapi_search_internal_callback_pb( Slapi_PBlock *pb,
1181 void *callback_data,
1182 plugin_result_callback prc,
1183 plugin_search_entry_callback psec,
1184 plugin_referral_entry_callback prec )
1187 Connection *conn = NULL;
1188 Operation *op = NULL;
1189 struct berval dn = BER_BVNULL;
1190 Filter *filter = NULL;
1191 struct berval fstr = BER_BVNULL;
1192 AttributeName *an = NULL;
1193 const char *text = NULL;
1195 int manageDsaIt = SLAP_CONTROL_NONE;
1199 int scope = LDAP_SCOPE_BASE;
1200 char *filStr = NULL;
1201 LDAPControl **controls = NULL;
1202 char **attrs = NULL;
1203 char *uniqueid = NULL;
1205 int operation_flags = 0;
1208 SlapReply rs = { REP_RESULT };
1214 slapi_pblock_get( pb, SLAPI_SEARCH_SCOPE, (void **)&scope );
1215 slapi_pblock_get( pb, SLAPI_SEARCH_FILTER, (void **)&filter );
1216 slapi_pblock_get( pb, SLAPI_SEARCH_STRFILTER, (void **)&filStr );
1217 slapi_pblock_get( pb, SLAPI_SEARCH_ATTRS, (void **)&attrs );
1218 slapi_pblock_get( pb, SLAPI_SEARCH_ATTRSONLY, (void **)&attrsonly );
1219 slapi_pblock_get( pb, SLAPI_REQCONTROLS, (void **)&controls );
1220 slapi_pblock_get( pb, SLAPI_TARGET_UNIQUEID, (void **)&uniqueid );
1221 slapi_pblock_get( pb, SLAPI_X_INTOP_FLAGS, (void **)&operation_flags );
1223 rs.sr_err = slapi_int_init_connection( pb, &rs, LDAP_REQ_SEARCH, &conn );
1224 if ( rs.sr_err != LDAP_SUCCESS ) {
1228 /* search callback and arguments */
1229 slapi_pblock_set( pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void *)prc );
1230 slapi_pblock_set( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, (void *)psec );
1231 slapi_pblock_set( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, (void *)prec );
1232 slapi_pblock_set( pb, SLAPI_X_INTOP_CALLBACK_DATA, (void *)callback_data );
1234 op = (Operation *)conn->c_pending_ops.stqh_first;
1237 case LDAP_SCOPE_BASE:
1238 case LDAP_SCOPE_ONELEVEL:
1239 case LDAP_SCOPE_SUBTREE:
1240 #ifdef LDAP_SCOPE_SUBORDINATE
1241 case LDAP_SCOPE_SUBORDINATE:
1245 rs.sr_err = LDAP_PROTOCOL_ERROR;
1249 if ( filter == NULL ) {
1250 if ( filStr == NULL ) {
1251 rs.sr_err = LDAP_PARAM_ERROR;
1255 filter = slapi_str2filter( filStr );
1256 if ( filter == NULL ) {
1257 rs.sr_err = LDAP_PROTOCOL_ERROR;
1264 filter2bv( filter, &fstr );
1266 for ( i = 0; attrs != NULL && attrs[i] != NULL; i++ ) {
1267 ; /* count the number of attributes */
1271 an = (AttributeName *)slapi_ch_calloc( (i + 1), sizeof(AttributeName) );
1272 for (i = 0; attrs[i] != 0; i++) {
1273 an[i].an_desc = NULL;
1275 an[i].an_oc_exclude = 0;
1276 an[i].an_name.bv_val = slapi_ch_strdup(attrs[i]);
1277 an[i].an_name.bv_len = strlen(attrs[i]);
1278 slap_bv2ad( &an[i].an_name, &an[i].an_desc, &text );
1280 an[i].an_name.bv_val = NULL;
1283 rs.sr_type = REP_RESULT;
1284 rs.sr_err = LDAP_SUCCESS;
1285 rs.sr_entry = NULL; /* paranoia */
1287 if ( scope == LDAP_SCOPE_BASE ) {
1290 if ( op->o_req_ndn.bv_len == 0 ) {
1291 rs.sr_err = root_dse_info( conn, &rs.sr_entry, &rs.sr_text );
1294 if( rs.sr_err != LDAP_SUCCESS ) {
1295 send_ldap_result( op, &rs );
1297 } else if ( rs.sr_entry != NULL ) {
1298 rs.sr_err = test_filter( op, rs.sr_entry, filter );
1300 if ( rs.sr_err == LDAP_COMPARE_TRUE ) {
1301 rs.sr_type = REP_SEARCH;
1302 rs.sr_err = LDAP_SUCCESS;
1304 rs.sr_operational_attrs = NULL;
1305 rs.sr_flags = REP_ENTRY_MODIFIABLE;
1307 send_search_entry( op, &rs );
1310 entry_free( rs.sr_entry );
1312 rs.sr_type = REP_RESULT;
1313 rs.sr_err = LDAP_SUCCESS;
1315 send_ldap_result( op, &rs );
1321 op->oq_search.rs_scope = scope;
1322 op->oq_search.rs_deref = 0;
1323 op->oq_search.rs_slimit = SLAP_NO_LIMIT;
1324 op->oq_search.rs_tlimit = SLAP_NO_LIMIT;
1325 op->oq_search.rs_attrsonly = attrsonly;
1326 op->oq_search.rs_attrs = an;
1327 op->oq_search.rs_filter = filter;
1328 op->oq_search.rs_filterstr = fstr;
1330 if ( BER_BVISEMPTY( &op->o_req_ndn ) &&
1331 !BER_BVISEMPTY( &default_search_nbase ) ) {
1332 slapi_ch_free( (void **)&op->o_req_dn.bv_val );
1333 slapi_ch_free( (void **)&op->o_req_ndn.bv_val );
1335 ber_dupbv( &op->o_req_dn, &default_search_base );
1336 ber_dupbv( &op->o_req_ndn, &default_search_nbase );
1338 rs.sr_err = slapi_int_pblock_get_backend( pb, op );
1339 if ( rs.sr_err != LDAP_SUCCESS )
1343 if ( op->o_bd->be_search != NULL ) {
1344 (*op->o_bd->be_search)( op, &rs );
1346 rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
1350 slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
1351 slapi_pblock_set( pb, SLAPI_X_INTOP_RESULT_CALLBACK, NULL );
1352 slapi_pblock_set( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, NULL );
1353 slapi_pblock_set( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, NULL );
1354 slapi_pblock_set( pb, SLAPI_X_INTOP_CALLBACK_DATA, NULL );
1356 if ( freeFilter && filter != NULL )
1357 slapi_filter_free( filter, 1 );
1359 slapi_ch_free( (void **)&fstr.bv_val );
1361 slapi_ch_free( (void **)&an );
1363 slapi_int_connection_destroy( &conn );
1368 #endif /* LDAP_SLAPI */
1371 /* Wrappers for old API */
1373 void slapi_search_internal_set_pb( Slapi_PBlock *pb,
1379 LDAPControl **controls,
1380 const char *uniqueid,
1381 Slapi_ComponentId *plugin_identity,
1382 int operation_flags )
1385 slapi_pblock_set( pb, SLAPI_SEARCH_TARGET, (void *)base );
1386 slapi_pblock_set( pb, SLAPI_SEARCH_SCOPE, (void *)scope );
1387 slapi_pblock_set( pb, SLAPI_SEARCH_FILTER, NULL );
1388 slapi_pblock_set( pb, SLAPI_SEARCH_STRFILTER, (void *)filter );
1389 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRS, (void *)attrs );
1390 slapi_pblock_set( pb, SLAPI_SEARCH_ATTRSONLY, (void *)attrsonly );
1391 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1392 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
1393 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1394 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1395 #endif /* LDAP_SLAPI */
1399 slapi_search_internal(
1403 LDAPControl **controls,
1410 pb = slapi_pblock_new();
1415 slapi_search_internal_set_pb( pb, ldn, scope, filStr, attrs, attrsonly,
1416 controls, NULL, NULL, 0 );
1418 slapi_search_internal_pb( pb );
1423 #endif /* LDAP_SLAPI */
1426 void slapi_modify_internal_set_pb( Slapi_PBlock *pb,
1429 LDAPControl **controls,
1430 const char *uniqueid,
1431 Slapi_ComponentId *plugin_identity,
1432 int operation_flags )
1435 slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn );
1436 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)mods );
1437 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1438 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
1439 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1440 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1441 #endif /* LDAP_SLAPI */
1444 /* Function : slapi_modify_internal
1446 * Description: Plugin functions call this routine to modify an entry
1447 * in the backend directly
1448 * Return values : LDAP_SUCCESS
1452 * LDAP_UNWILLING_TO_PERFORM
1455 slapi_modify_internal(
1458 LDAPControl **controls,
1464 pb = slapi_pblock_new();
1469 slapi_modify_internal_set_pb( pb, ldn, mods, controls, NULL, NULL,
1470 log_change ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1472 slapi_modify_internal_pb( pb );
1477 #endif /* LDAP_SLAPI */
1480 int slapi_add_internal_set_pb( Slapi_PBlock *pb,
1483 LDAPControl **controls,
1484 Slapi_ComponentId *plugin_identity,
1485 int operation_flags )
1488 slapi_pblock_set( pb, SLAPI_ADD_TARGET, (void *)dn );
1489 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)attrs );
1490 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1491 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1492 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1497 #endif /* LDAP_SLAPI */
1500 Slapi_PBlock *slapi_add_internal(
1503 LDAPControl **controls,
1509 pb = slapi_pblock_new();
1513 slapi_add_internal_set_pb( pb, dn, attrs, controls, NULL,
1514 log_changes ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1516 slapi_add_internal_pb( pb );
1521 #endif /* LDAP_SLAPI */
1524 void slapi_add_entry_internal_set_pb( Slapi_PBlock *pb,
1526 LDAPControl **controls,
1527 Slapi_ComponentId *plugin_identity,
1528 int operation_flags )
1531 slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)e );
1532 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1533 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1534 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1535 #endif /* LDAP_SLAPI */
1539 slapi_add_entry_internal(
1541 LDAPControl **controls,
1547 pb = slapi_pblock_new();
1551 slapi_add_entry_internal_set_pb( pb, e, controls, NULL,
1552 log_changes ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1554 slapi_add_internal_pb( pb );
1559 #endif /* LDAP_SLAPI */
1562 void slapi_rename_internal_set_pb( Slapi_PBlock *pb,
1565 const char *newsuperior,
1567 LDAPControl **controls,
1568 const char *uniqueid,
1569 Slapi_ComponentId *plugin_identity,
1570 int operation_flags )
1573 slapi_pblock_set( pb, SLAPI_MODRDN_TARGET, (void *)olddn );
1574 slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)newrdn );
1575 slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR, (void *)newsuperior );
1576 slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)deloldrdn );
1577 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1578 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
1579 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1580 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1581 #endif /* LDAP_SLAPI */
1584 /* Function : slapi_modrdn_internal
1586 * Description : Plugin functions call this routine to modify the rdn
1587 * of an entry in the backend directly
1588 * Return values : LDAP_SUCCESS
1592 * LDAP_UNWILLING_TO_PERFORM
1594 * NOTE: This function does not support the "newSuperior" option from LDAP V3.
1597 slapi_modrdn_internal(
1601 LDAPControl **controls,
1607 pb = slapi_pblock_new();
1612 slapi_rename_internal_set_pb( pb, olddn, lnewrdn, NULL,
1613 deloldrdn, controls, NULL, NULL,
1614 log_change ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1616 slapi_modrdn_internal_pb( pb );
1621 #endif /* LDAP_SLAPI */
1624 void slapi_delete_internal_set_pb( Slapi_PBlock *pb,
1626 LDAPControl **controls,
1627 const char *uniqueid,
1628 Slapi_ComponentId *plugin_identity,
1629 int operation_flags )
1632 slapi_pblock_set( pb, SLAPI_TARGET_DN, (void *)dn );
1633 slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
1634 slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
1635 slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
1636 slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)operation_flags );
1637 #endif /* LDAP_SLAPI */
1640 /* Function : slapi_delete_internal
1642 * Description : Plugin functions call this routine to delete an entry
1643 * in the backend directly
1644 * Return values : LDAP_SUCCESS
1648 * LDAP_UNWILLING_TO_PERFORM
1651 slapi_delete_internal(
1653 LDAPControl **controls,
1659 pb = slapi_pblock_new();
1663 slapi_delete_internal_set_pb( pb, ldn, controls, NULL, NULL,
1664 log_change ? SLAPI_OP_FLAG_LOG_CHANGE : 0 );
1666 slapi_delete_internal_pb( pb );
1671 #endif /* LDAP_SLAPI */