X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fslapi%2Fslapi_ops.c;h=9a95d502299756f28ba77539d6c1c28b38a9acc2;hb=6661a26e9bc2f2fa8dd14f573a9d72acd0c5bfae;hp=8e59193b4109ed78128a1b76e09c3e5ef86f1c1a;hpb=74960cc52f1adadf9b576ad21bb2c27562ccf57b;p=openldap
diff --git a/servers/slapd/slapi/slapi_ops.c b/servers/slapd/slapi/slapi_ops.c
index 8e59193b41..9a95d50229 100644
--- a/servers/slapd/slapi/slapi_ops.c
+++ b/servers/slapd/slapi/slapi_ops.c
@@ -1,1260 +1,946 @@
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software .
+ *
+ * Copyright 2002-2008 The OpenLDAP Foundation.
+ * Portions Copyright 1997,2002-2003 IBM Corporation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * .
*/
-/*
- * (C) Copyright IBM Corp. 1997,2002
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is
- * given to IBM Corporation. This software is provided ``as is''
- * without express or implied warranty.
+/* ACKNOWLEDGEMENTS:
+ * This work was initially developed by IBM Corporation for use in
+ * IBM products and subsequently ported to OpenLDAP Software by
+ * Steve Omrani. Additional significant contributors include:
+ * Luke Howard
*/
#include "portable.h"
+
+#include
+#include
+#include
+#include
+
#include
+#include
#include
-#include
-#include "../../../libraries/liblber/lber-int.h"
+#ifdef LDAP_SLAPI
-int bvptr2obj( struct berval **bvptr, struct berval **bvobj );
+static struct slap_listener slapi_listener = {
+ BER_BVC("slapi://"),
+ BER_BVC("slapi://")
+};
-static void
-internal_result_v3(
- Connection *conn,
- Operation *op,
- ber_int_t err,
- const char *matched,
- const char *text,
- BerVarray referrals,
- LDAPControl **ctrls )
+static LDAPControl **
+slapi_int_dup_controls( LDAPControl **controls )
{
- return;
+ LDAPControl **c;
+ size_t i;
+
+ if ( controls == NULL )
+ return NULL;
+
+ for ( i = 0; controls[i] != NULL; i++ )
+ ;
+
+ c = (LDAPControl **) slapi_ch_calloc( i + 1, sizeof(LDAPControl *) );
+
+ for ( i = 0; controls[i] != NULL; i++ ) {
+ c[i] = slapi_dup_control( controls[i] );
+ }
+
+ return c;
}
static int
-internal_search_entry(
- Backend *be,
- Connection *conn,
+slapi_int_result(
Operation *op,
- Entry *e,
- AttributeName *attrs,
- int attrsonly,
- LDAPControl **ctrls )
+ SlapReply *rs )
{
- char *ent2str = NULL;
- int nentries = 0, len = 0, i = 0;
- Slapi_Entry **head = NULL, **tp;
-
- ent2str = slapi_entry2str( e, &len );
- if ( ent2str == NULL ) {
- return 1;
- }
+ Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
+ plugin_result_callback prc = NULL;
+ void *callback_data = NULL;
+ LDAPControl **ctrls = NULL;
- slapi_pblock_get( (Slapi_PBlock *)op->o_pb,
- SLAPI_NENTRIES, &nentries );
- slapi_pblock_get( (Slapi_PBlock *)op->o_pb,
- SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &head );
-
- i = nentries + 1;
- if ( nentries == 0 ) {
- tp = (Slapi_Entry **)slapi_ch_malloc( 2 * sizeof(Slapi_Entry *) );
- if ( tp == NULL ) {
- return 1;
- }
+ assert( pb != NULL );
- tp[ 0 ] = (Slapi_Entry *)str2entry( ent2str );
- if ( tp[ 0 ] == NULL ) {
- return 1;
- }
+ slapi_pblock_get( pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void **)&prc );
+ slapi_pblock_get( pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
- } else {
- tp = (Slapi_Entry **)slapi_ch_realloc( (char *)head,
- sizeof(Slapi_Entry *) * ( i + 1 ) );
- if ( tp == NULL ) {
- return 1;
- }
- tp[ i - 1 ] = (Slapi_Entry *)str2entry( ent2str );
- if ( tp[ i - 1 ] == NULL ) {
- return 1;
- }
+ /* we need to duplicate controls because they might go out of scope */
+ ctrls = slapi_int_dup_controls( rs->sr_ctrls );
+ slapi_pblock_set( pb, SLAPI_RESCONTROLS, ctrls );
+
+ if ( prc != NULL ) {
+ (*prc)( rs->sr_err, callback_data );
}
- tp[ i ] = NULL;
-
- slapi_pblock_set( (Slapi_PBlock *)op->o_pb,
- SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, (void *)tp );
- slapi_pblock_set( (Slapi_PBlock *)op->o_pb,
- SLAPI_NENTRIES, (void *)i );
- return LDAP_SUCCESS;
+ return rs->sr_err;
}
-static void
-internal_search_result(
- Connection *conn,
+static int
+slapi_int_search_entry(
Operation *op,
- ber_int_t err,
- const char *matched,
- const char *text,
- BerVarray refs,
- LDAPControl **ctrls,
- int nentries )
+ SlapReply *rs )
{
- slapi_pblock_set( (Slapi_PBlock *)op->o_pb,
- SLAPI_NENTRIES, (void *)nentries );
+ Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
+ plugin_search_entry_callback psec = NULL;
+ void *callback_data = NULL;
+ int rc = LDAP_SUCCESS;
- return;
-}
+ assert( pb != NULL );
-static void
-internal_result_ext(
- Connection *conn,
- Operation *op,
- ber_int_t errnum,
- const char *matched,
- const char *text,
- BerVarray refs,
- const char *rspoid,
- struct berval *rspdata,
- LDAPControl **ctrls )
-{
- return;
+ slapi_pblock_get( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, (void **)&psec );
+ slapi_pblock_get( pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
+
+ if ( psec != NULL ) {
+ rc = (*psec)( rs->sr_entry, callback_data );
+ }
+
+ return rc;
}
static int
-internal_search_reference(
- Backend *be,
- Connection *conn,
- Operation *op,
- Entry *e,
- BerVarray refs,
- LDAPControl **ctrls,
- BerVarray *v2refs )
+slapi_int_search_reference(
+ Operation *op,
+ SlapReply *rs )
{
- return LDAP_SUCCESS;
-}
+ int i, rc = LDAP_SUCCESS;
+ plugin_referral_entry_callback prec = NULL;
+ void *callback_data = NULL;
+ Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
-static Connection *
-fakeConnection(
- char *DN,
- int OpType )
-{
- Connection *pConn, *c;
- ber_len_t max = sockbuf_max_incoming;
-
- pConn = (Connection *) slapi_ch_calloc(1, sizeof(Connection));
- if (pConn == NULL) {
- return (Connection *)NULL;
- }
+ assert( pb != NULL );
- LDAP_STAILQ_INIT( &pConn->c_pending_ops );
+ slapi_pblock_get( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, (void **)&prec );
+ slapi_pblock_get( pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
- pConn->c_pending_ops.stqh_first =
- (Operation *) slapi_ch_calloc( 1, sizeof(Operation) );
- if ( pConn->c_pending_ops.stqh_first == NULL ) {
- slapi_ch_free( (void **)&pConn );
- return (Connection *)NULL;
- }
-
- pConn->c_pending_ops.stqh_first->o_pb =
- (Slapi_PBlock *) slapi_pblock_new();
- if ( pConn->c_pending_ops.stqh_first->o_pb == NULL ) {
- slapi_ch_free( (void **)&pConn->c_pending_ops.stqh_first );
- slapi_ch_free( (void **)&pConn );
- return (Connection *)NULL;
+ if ( prec != NULL ) {
+ for ( i = 0; rs->sr_ref[i].bv_val != NULL; i++ ) {
+ rc = (*prec)( rs->sr_ref[i].bv_val, callback_data );
+ if ( rc != LDAP_SUCCESS ) {
+ break;
+ }
+ }
}
- c = pConn;
+ return rc;
+}
- /* operation object */
- c->c_pending_ops.stqh_first->o_tag = OpType;
- c->c_pending_ops.stqh_first->o_protocol = LDAP_VERSION3;
- c->c_pending_ops.stqh_first->o_authmech.bv_val = NULL;
- c->c_pending_ops.stqh_first->o_authmech.bv_len = 0;
- c->c_pending_ops.stqh_first->o_time = slap_get_time();
- c->c_pending_ops.stqh_first->o_do_not_cache = 1;
- c->c_pending_ops.stqh_first->o_threadctx = ldap_pvt_thread_pool_context( &connection_pool );
-
- /* connection object */
- c->c_authmech.bv_val = NULL;
- c->c_authmech.bv_len = 0;
- c->c_dn.bv_val = NULL;
- c->c_dn.bv_len = 0;
- c->c_ndn.bv_val = NULL;
- c->c_ndn.bv_len = 0;
- c->c_groups = NULL;
-
- c->c_listener = NULL;
- c->c_peer_domain.bv_val = NULL;
- c->c_peer_domain.bv_len = 0;
- c->c_peer_name.bv_val = NULL;
- c->c_peer_name.bv_len = 0;
-
- LDAP_STAILQ_INIT( &c->c_ops );
-
- c->c_sasl_bind_mech.bv_val = NULL;
- c->c_sasl_bind_mech.bv_len = 0;
- c->c_sasl_context = NULL;
- c->c_sasl_extra = NULL;
-
- c->c_sb = ber_sockbuf_alloc( );
-
- ber_sockbuf_ctrl( c->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max );
-
- c->c_currentber = NULL;
+int
+slapi_int_response( Slapi_Operation *op, SlapReply *rs )
+{
+ int rc;
- /* should check status of thread calls */
- ldap_pvt_thread_mutex_init( &c->c_mutex );
- ldap_pvt_thread_mutex_init( &c->c_write_mutex );
- ldap_pvt_thread_cond_init( &c->c_write_cv );
+ switch ( rs->sr_type ) {
+ case REP_RESULT:
+ rc = slapi_int_result( op, rs );
+ break;
+ case REP_SEARCH:
+ rc = slapi_int_search_entry( op, rs );
+ break;
+ case REP_SEARCHREF:
+ rc = slapi_int_search_reference( op, rs );
+ break;
+ default:
+ rc = LDAP_OTHER;
+ break;
+ }
- c->c_n_ops_received = 0;
- c->c_n_ops_executing = 0;
- c->c_n_ops_pending = 0;
- c->c_n_ops_completed = 0;
+ assert( rc != SLAP_CB_CONTINUE ); /* never try to send a wire response */
- c->c_n_get = 0;
- c->c_n_read = 0;
- c->c_n_write = 0;
+ return rc;
+}
- c->c_protocol = LDAP_VERSION3;
+static int
+slapi_int_get_ctrls( Slapi_PBlock *pb )
+{
+ LDAPControl **c;
+ int rc = LDAP_SUCCESS;
- c->c_activitytime = c->c_starttime = slap_get_time();
+ if ( pb->pb_op->o_ctrls != NULL ) {
+ for ( c = pb->pb_op->o_ctrls; *c != NULL; c++ ) {
+ rc = slap_parse_ctrl( pb->pb_op, pb->pb_rs, *c, &pb->pb_rs->sr_text );
+ if ( rc != LDAP_SUCCESS )
+ break;
+ }
+ }
- c->c_connid = 0;
+ return rc;
+}
- c->c_conn_state = 0x01; /* SLAP_C_ACTIVE */
- c->c_struct_state = 0x02; /* SLAP_C_USED */
+void
+slapi_int_connection_init_pb( Slapi_PBlock *pb, ber_tag_t tag )
+{
+ Connection *conn;
+ Operation *op;
+ ber_len_t max = sockbuf_max_incoming;
- c->c_ssf = c->c_transport_ssf = 0;
- c->c_tls_ssf = 0;
+ conn = (Connection *) slapi_ch_calloc( 1, sizeof(Connection) );
- backend_connection_init( c );
+ LDAP_STAILQ_INIT( &conn->c_pending_ops );
- pConn->c_send_ldap_result = internal_result_v3;
- pConn->c_send_search_entry = internal_search_entry;
- pConn->c_send_search_result = internal_search_result;
- pConn->c_send_ldap_extended = internal_result_ext;
- pConn->c_send_search_reference = internal_search_reference;
+ op = (Operation *) slapi_ch_calloc( 1, OPERATION_BUFFER_SIZE );
+ op->o_hdr = (Opheader *)(op + 1);
+ op->o_controls = (void **)(op->o_hdr + 1);
- return pConn;
-}
+ op->o_callback = (slap_callback *) slapi_ch_calloc( 1, sizeof(slap_callback) );
+ op->o_callback->sc_response = slapi_int_response;
+ op->o_callback->sc_cleanup = NULL;
+ op->o_callback->sc_private = pb;
+ op->o_callback->sc_next = NULL;
-/*
- * Function : values2obj
- * Convert an array of strings into a BerVarray.
- * the strings.
- */
-static int
-values2obj(
- char **ppValue,
- BerVarray *bvobj)
-{
- int i;
- BerVarray tmpberval;
+ conn->c_pending_ops.stqh_first = op;
- if ( ppValue == NULL ) {
- *bvobj = NULL;
- return LDAP_SUCCESS;
- }
+ /* connection object authorization information */
+ conn->c_authtype = LDAP_AUTH_NONE;
+ BER_BVZERO( &conn->c_authmech );
+ BER_BVZERO( &conn->c_dn );
+ BER_BVZERO( &conn->c_ndn );
- for ( i = 0; ppValue[i] != NULL; i++ )
- ;
+ conn->c_listener = &slapi_listener;
+ ber_dupbv( &conn->c_peer_domain, (struct berval *)&slap_unknown_bv );
+ ber_dupbv( &conn->c_peer_name, (struct berval *)&slap_unknown_bv );
- tmpberval = (BerVarray)slapi_ch_malloc( (i+1) * (sizeof(struct berval)) );
- if ( tmpberval == NULL ) {
- return LDAP_NO_MEMORY;
- }
- for ( i = 0; ppValue[i] != NULL; i++ ) {
- tmpberval[i].bv_val = ppValue[i];
- tmpberval[i].bv_len = strlen( ppValue[i] );
- }
- tmpberval[i].bv_val = NULL;
- tmpberval[i].bv_len = 0;
+ LDAP_STAILQ_INIT( &conn->c_ops );
- *bvobj = tmpberval;
+ BER_BVZERO( &conn->c_sasl_bind_mech );
+ conn->c_sasl_authctx = NULL;
+ conn->c_sasl_sockctx = NULL;
+ conn->c_sasl_extra = NULL;
- return LDAP_SUCCESS;
-}
+ conn->c_sb = ber_sockbuf_alloc();
-static void
-freeMods( Modifications *ml )
-{
- /*
- * Free a modification list whose values have been
- * set with bvptr2obj() or values2obj() (ie. they
- * do not own the pointer to the underlying values)
- */
- Modifications *next;
+ ber_sockbuf_ctrl( conn->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max );
- for ( ; ml != NULL; ml = next ) {
- next = ml->sml_next;
+ conn->c_currentber = NULL;
- slapi_ch_free( (void **)&ml->sml_bvalues );
-#ifdef SLAP_NVALUES
- slapi_ch_free( (void **)&ml->sml_nvalues );
-#endif
- slapi_ch_free( (void **)&ml );
- }
-}
+ /* should check status of thread calls */
+ ldap_pvt_thread_mutex_init( &conn->c_mutex );
+ ldap_pvt_thread_mutex_init( &conn->c_write_mutex );
+ ldap_pvt_thread_cond_init( &conn->c_write_cv );
-/*
- * Function : LDAPModToEntry
- * convert a dn plus an array of LDAPMod struct ptrs to an entry structure
- * with a link list of the correspondent attributes.
- * Return value : LDAP_SUCCESS
- * LDAP_NO_MEMORY
- * LDAP_OTHER
-*/
-Entry *
-LDAPModToEntry(
- char *ldn,
- LDAPMod **mods )
-{
- struct berval dn = { 0, NULL };
- Entry *pEntry=NULL;
- LDAPMod *pMod;
- struct berval *bv;
- Backend *be;
- Operation *op;
+ ldap_pvt_thread_mutex_lock( &conn->c_mutex );
- Modifications *modlist = NULL;
- Modifications **modtail = &modlist;
- Modifications tmp;
+ conn->c_n_ops_received = 0;
+ conn->c_n_ops_executing = 0;
+ conn->c_n_ops_pending = 0;
+ conn->c_n_ops_completed = 0;
- int rc = LDAP_SUCCESS;
- int i;
+ conn->c_n_get = 0;
+ conn->c_n_read = 0;
+ conn->c_n_write = 0;
- const char *text = NULL;
+ conn->c_protocol = LDAP_VERSION3;
+ conn->c_activitytime = conn->c_starttime = slap_get_time();
- op = (Operation *) slapi_ch_calloc(1, sizeof(Operation));
- if ( pEntry == NULL) {
- rc = LDAP_NO_MEMORY;
- goto cleanup;
- }
- op->o_tag = LDAP_REQ_ADD;
+ /*
+ * A real connection ID is required, because syncrepl associates
+ * pending CSNs with unique ( connection, operation ) tuples.
+ * Setting a fake connection ID will cause slap_get_commit_csn()
+ * to return a stale value.
+ */
+ connection_assign_nextid( conn );
- pEntry = (Entry *) ch_calloc( 1, sizeof(Entry) );
- if ( pEntry == NULL) {
- rc = LDAP_NO_MEMORY;
- goto cleanup;
- }
-
- dn.bv_val = slapi_ch_strdup(ldn);
- dn.bv_len = strlen(ldn);
-
- rc = dnPrettyNormal( NULL, &dn, &pEntry->e_name, &pEntry->e_nname );
- if (rc != LDAP_SUCCESS) goto cleanup;
-
- if ( rc == LDAP_SUCCESS ) {
- for ( i=0, pMod=mods[0]; rc == LDAP_SUCCESS && pMod != NULL; pMod=mods[++i]) {
- Modifications *mod;
- if ( (pMod->mod_op & LDAP_MOD_BVALUES) != 0 ) {
- /* attr values are in berval format */
- /* convert an array of pointers to bervals to an array of bervals */
- rc = bvptr2obj(pMod->mod_bvalues, &bv);
- if (rc != LDAP_SUCCESS) goto cleanup;
- tmp.sml_type.bv_val = pMod->mod_type;
- tmp.sml_type.bv_len = strlen( pMod->mod_type );
- tmp.sml_bvalues = bv;
-#ifdef SLAP_NVALUES
- tmp.sml_nvalues = NULL;
-#endif
-
- mod = (Modifications *) ch_malloc( sizeof(Modifications) );
-
- mod->sml_op = LDAP_MOD_ADD;
- mod->sml_next = NULL;
- mod->sml_desc = NULL;
- mod->sml_type = tmp.sml_type;
- mod->sml_bvalues = tmp.sml_bvalues;
-#ifdef SLAP_NVALUES
- mod->sml_nvalues = tmp.sml_nvalues;
-#endif
-
- *modtail = mod;
- modtail = &mod->sml_next;
-
- } else {
- /* attr values are in string format, need to be converted */
- /* to an array of bervals */
- if ( pMod->mod_values == NULL ) {
- rc = LDAP_OTHER;
- } else {
- rc = values2obj( pMod->mod_values, &bv );
- if (rc != LDAP_SUCCESS) goto cleanup;
- tmp.sml_type.bv_val = pMod->mod_type;
- tmp.sml_type.bv_len = strlen( pMod->mod_type );
- tmp.sml_bvalues = bv;
-#ifdef SLAP_NVALUES
- tmp.sml_nvalues = NULL;
-#endif
-
- mod = (Modifications *) ch_malloc( sizeof(Modifications) );
-
- mod->sml_op = LDAP_MOD_ADD;
- mod->sml_next = NULL;
- mod->sml_desc = NULL;
- mod->sml_type = tmp.sml_type;
- mod->sml_bvalues = tmp.sml_bvalues;
-#ifdef SLAP_NVALUES
- mod->sml_nvalues = tmp.sml_nvalues;
-#endif
-
- *modtail = mod;
- modtail = &mod->sml_next;
- }
- }
- } /* for each LDAPMod */
- }
+ conn->c_conn_state = 0x01; /* SLAP_C_ACTIVE */
+ conn->c_struct_state = 0x02; /* SLAP_C_USED */
- be = select_backend(&pEntry->e_nname, 0, 0);
- if ( be == NULL ) {
- rc = LDAP_PARTIAL_RESULTS;
- goto cleanup;
- }
+ conn->c_ssf = conn->c_transport_ssf = local_ssf;
+ conn->c_tls_ssf = 0;
- if ( be ) {
- int repl_user = be_isupdate(be, &be->be_rootdn );
- if ( !be->be_update_ndn.bv_len || repl_user ) {
- int update = be->be_update_ndn.bv_len;
- char textbuf[SLAP_TEXT_BUFLEN];
- size_t textlen = sizeof textbuf;
-
- rc = slap_mods_check( modlist, update, &text,
- textbuf, textlen );
- if ( rc != LDAP_SUCCESS) {
- goto cleanup;
- }
+ backend_connection_init( conn );
- if ( !repl_user ) {
- rc = slap_mods_opattrs( be, op,
- modlist, modtail, &text,
- textbuf, textlen );
- if ( rc != LDAP_SUCCESS) {
- goto cleanup;
- }
- }
+ conn->c_send_ldap_result = slap_send_ldap_result;
+ conn->c_send_search_entry = slap_send_search_entry;
+ conn->c_send_ldap_extended = slap_send_ldap_extended;
+ conn->c_send_search_reference = slap_send_search_reference;
- /*
- * FIXME: slap_mods2entry is declared static
- * in servers/slapd/add.c
- */
- rc = slap_mods2entry( modlist, &pEntry, repl_user,
- &text, textbuf, textlen );
- if (rc != LDAP_SUCCESS) {
- goto cleanup;
- }
+ /* operation object */
+ op->o_tag = tag;
+ op->o_protocol = LDAP_VERSION3;
+ BER_BVZERO( &op->o_authmech );
+ op->o_time = slap_get_time();
+ op->o_do_not_cache = 1;
+ op->o_threadctx = ldap_pvt_thread_pool_context();
+ op->o_tmpmemctx = NULL;
+ op->o_tmpmfuncs = &ch_mfuncs;
+ op->o_conn = conn;
+ op->o_connid = conn->c_connid;
+ op->o_bd = frontendDB;
+
+ /* extensions */
+ slapi_int_create_object_extensions( SLAPI_X_EXT_OPERATION, op );
+ slapi_int_create_object_extensions( SLAPI_X_EXT_CONNECTION, conn );
+
+ pb->pb_rs = (SlapReply *)slapi_ch_calloc( 1, sizeof(SlapReply) );
+ pb->pb_op = op;
+ pb->pb_conn = conn;
+ pb->pb_intop = 1;
+
+ ldap_pvt_thread_mutex_unlock( &conn->c_mutex );
+}
- } else {
- rc = LDAP_REFERRAL;
+static void
+slapi_int_set_operation_dn( Slapi_PBlock *pb )
+{
+ Backend *be;
+ Operation *op = pb->pb_op;
+
+ if ( BER_BVISNULL( &op->o_ndn ) ) {
+ /* set to root DN */
+ be = select_backend( &op->o_req_ndn, get_manageDSAit( op ), 1 );
+ if ( be != NULL ) {
+ ber_dupbv( &op->o_dn, &be->be_rootdn );
+ ber_dupbv( &op->o_ndn, &be->be_rootndn );
}
- } else {
- rc = LDAP_UNWILLING_TO_PERFORM;
}
+}
-cleanup:
+void
+slapi_int_connection_done_pb( Slapi_PBlock *pb )
+{
+ Connection *conn;
+ Operation *op;
- if ( dn.bv_val ) slapi_ch_free( (void **)&dn.bv_val );
- if ( op ) slapi_ch_free( (void **)&op );
- if ( modlist != NULL ) freeMods( modlist );
- if ( rc != LDAP_SUCCESS ) {
- if ( pEntry != NULL ) {
- slapi_entry_free( pEntry );
+ PBLOCK_ASSERT_INTOP( pb, 0 );
+
+ conn = pb->pb_conn;
+ op = pb->pb_op;
+
+ /* free allocated DNs */
+ if ( !BER_BVISNULL( &op->o_dn ) )
+ op->o_tmpfree( op->o_dn.bv_val, op->o_tmpmemctx );
+ if ( !BER_BVISNULL( &op->o_ndn ) )
+ op->o_tmpfree( op->o_ndn.bv_val, op->o_tmpmemctx );
+
+ if ( !BER_BVISNULL( &op->o_req_dn ) )
+ op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
+ if ( !BER_BVISNULL( &op->o_req_ndn ) )
+ op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
+
+ switch ( op->o_tag ) {
+ case LDAP_REQ_MODRDN:
+ if ( !BER_BVISNULL( &op->orr_newrdn ))
+ op->o_tmpfree( op->orr_newrdn.bv_val, op->o_tmpmemctx );
+ if ( !BER_BVISNULL( &op->orr_nnewrdn ))
+ op->o_tmpfree( op->orr_nnewrdn.bv_val, op->o_tmpmemctx );
+ if ( op->orr_newSup != NULL ) {
+ assert( !BER_BVISNULL( op->orr_newSup ) );
+ op->o_tmpfree( op->orr_newSup->bv_val, op->o_tmpmemctx );
+ op->o_tmpfree( op->orr_newSup, op->o_tmpmemctx );
+ }
+ if ( op->orr_nnewSup != NULL ) {
+ assert( !BER_BVISNULL( op->orr_nnewSup ) );
+ op->o_tmpfree( op->orr_nnewSup->bv_val, op->o_tmpmemctx );
+ op->o_tmpfree( op->orr_nnewSup, op->o_tmpmemctx );
}
- pEntry = NULL;
+ break;
+ case LDAP_REQ_ADD:
+ slap_mods_free( op->ora_modlist, 0 );
+ break;
+ case LDAP_REQ_MODIFY:
+ slap_mods_free( op->orm_modlist, 1 );
+ break;
+ case LDAP_REQ_SEARCH:
+ if ( op->ors_attrs != NULL ) {
+ op->o_tmpfree( op->ors_attrs, op->o_tmpmemctx );
+ op->ors_attrs = NULL;
+ }
+ break;
+ default:
+ break;
}
- return( pEntry );
-}
+ slapi_ch_free_string( &conn->c_authmech.bv_val );
+ slapi_ch_free_string( &conn->c_dn.bv_val );
+ slapi_ch_free_string( &conn->c_ndn.bv_val );
+ slapi_ch_free_string( &conn->c_peer_domain.bv_val );
+ slapi_ch_free_string( &conn->c_peer_name.bv_val );
-/* Function : slapi_delete_internal
- *
- * Description : Plugin functions call this routine to delete an entry
- * in the backend directly
- * Return values : LDAP_SUCCESS
- * LDAP_PARAM_ERROR
- * LDAP_NO_MEMORY
- * LDAP_OTHER
- * LDAP_UNWILLING_TO_PERFORM
-*/
-Slapi_PBlock *
-slapi_delete_internal(
- char *ldn,
- LDAPControl **controls,
- int log_change )
-{
-#if defined(LDAP_SLAPI)
- Backend *be;
- Connection *pConn = NULL;
- Operation *op = NULL;
- Slapi_PBlock *pPB = NULL;
- Slapi_PBlock *pSavePB = NULL;
+ if ( conn->c_sb != NULL ) {
+ ber_sockbuf_free( conn->c_sb );
+ }
- struct berval dn = { 0, NULL };
- struct berval pdn = { 0, NULL };
- struct berval ndn = { 0, NULL };
+ slapi_int_free_object_extensions( SLAPI_X_EXT_OPERATION, op );
+ slapi_int_free_object_extensions( SLAPI_X_EXT_CONNECTION, conn );
- int rc=LDAP_SUCCESS;
- int manageDsaIt = 0;
- int isCritical;
+ slapi_ch_free( (void **)&pb->pb_op->o_callback );
+ slapi_ch_free( (void **)&pb->pb_op );
+ slapi_ch_free( (void **)&pb->pb_conn );
+ slapi_ch_free( (void **)&pb->pb_rs );
+}
- if ( ldn == NULL ) {
- rc = LDAP_PARAM_ERROR;
- goto cleanup;
- }
+static int
+slapi_int_func_internal_pb( Slapi_PBlock *pb, slap_operation_t which )
+{
+ BI_op_bind **func;
+ SlapReply *rs = pb->pb_rs;
+ int rc;
- pConn = fakeConnection( NULL, LDAP_REQ_DELETE );
- if (pConn == NULL) {
- rc = LDAP_NO_MEMORY;
- goto cleanup;
+ PBLOCK_ASSERT_INTOP( pb, 0 );
+
+ rc = slapi_int_get_ctrls( pb );
+ if ( rc != LDAP_SUCCESS ) {
+ rs->sr_err = rc;
+ return rc;
}
- op = (Operation *)pConn->c_pending_ops.stqh_first;
- pPB = (Slapi_PBlock *)op->o_pb;
- op->o_ctrls = controls;
+ pb->pb_op->o_bd = frontendDB;
+ func = &frontendDB->be_bind;
- dn.bv_val = slapi_ch_strdup(ldn);
- dn.bv_len = slapi_strlen(ldn);
- rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
- if ( rc != LDAP_SUCCESS ) goto cleanup;
+ return func[which]( pb->pb_op, pb->pb_rs );
+}
- if ( slapi_control_present( controls,
- SLAPI_CONTROL_MANAGEDSAIT_OID, NULL, &isCritical) ) {
- manageDsaIt = 1;
+int
+slapi_delete_internal_pb( Slapi_PBlock *pb )
+{
+ if ( pb == NULL ) {
+ return -1;
}
- be = select_backend( &ndn, manageDsaIt, 0 );
- if ( be == NULL ) {
- rc = LDAP_PARTIAL_RESULTS;
- goto cleanup;
- }
+ PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_DELETE );
- op->o_dn = pConn->c_dn = be->be_rootdn;
- op->o_ndn = pConn->c_ndn = be->be_rootndn;
-
- if ( be->be_delete ) {
- int repl_user = be_isupdate( be, &op->o_ndn );
- if ( !be->be_update_ndn.bv_len || repl_user ) {
- rc = (*be->be_delete)( be, pConn, op, &pdn, &ndn );
- if ( rc == 0 ) {
- if (log_change) {
- replog( be, op, &pdn, &ndn, NULL );
- }
- rc = LDAP_SUCCESS;
- } else {
- rc = LDAP_OTHER;
- }
- } else {
- rc = LDAP_REFERRAL;
- }
- } else {
- rc = LDAP_UNWILLING_TO_PERFORM;
- }
+ slapi_int_func_internal_pb( pb, op_delete );
-cleanup:
- if (pPB != NULL)
- slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rc );
-
- if (dn.bv_val) slapi_ch_free( (void **)&dn.bv_val );
- if (pdn.bv_val) slapi_ch_free( (void **)&pdn.bv_val );
- if (ndn.bv_val) slapi_ch_free( (void **)&ndn.bv_val );
-
- if ( pConn != NULL ) {
- if ( pConn->c_sb != NULL ) ber_sockbuf_free( pConn->c_sb );
- if ( op ) slapi_ch_free( (void **)&op );
- pSavePB = pPB;
- free( pConn );
- }
-
- return (pSavePB);
-#endif /* LDAP_SLAPI */
- return NULL;
+ return 0;
}
-Slapi_PBlock *
-slapi_add_entry_internal(
- Slapi_Entry *e,
- LDAPControl **controls,
- int log_changes )
+int
+slapi_add_internal_pb( Slapi_PBlock *pb )
{
-#if defined(LDAP_SLAPI)
- Connection *pConn = NULL;
- Operation *op = NULL;
- Slapi_PBlock *pPB = NULL, *pSavePB = NULL;
- Backend *be;
-
- int manageDsaIt = 0;
- int isCritical;
- int rc = LDAP_SUCCESS;
+ SlapReply *rs;
+ Slapi_Entry *entry_orig = NULL;
- if ( e == NULL ) {
- rc = LDAP_PARAM_ERROR;
- goto cleanup;
- }
-
- pConn = fakeConnection( NULL, LDAP_REQ_ADD );
- if ( pConn == NULL ) {
- rc = LDAP_NO_MEMORY;
- goto cleanup;
+ if ( pb == NULL ) {
+ return -1;
}
- if ( slapi_control_present( controls, LDAP_CONTROL_MANAGEDSAIT,
- NULL, &isCritical ) ) {
- manageDsaIt = 1;
- }
+ PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_ADD );
- op = (Operation *)pConn->c_pending_ops.stqh_first;
- pPB = (Slapi_PBlock *)op->o_pb;
- op->o_ctrls = controls;
+ rs = pb->pb_rs;
- be = select_backend( &e->e_nname, manageDsaIt, 0 );
- if ( be == NULL ) {
- rc = LDAP_PARTIAL_RESULTS;
- goto cleanup;
- }
+ entry_orig = pb->pb_op->ora_e;
+ pb->pb_op->ora_e = NULL;
- op->o_dn = pConn->c_dn = be->be_rootdn;
- op->o_ndn = pConn->c_ndn = be->be_rootndn;
-
- if ( be->be_add ) {
- int repl_user = be_isupdate( be, &op->o_ndn );
- if ( !be->be_update_ndn.bv_len || repl_user ){
- if ( (*be->be_add)( be, pConn, op, e ) == 0 ) {
- if ( log_changes ) {
- replog( be, op, &e->e_name,
- &e->e_nname, e );
- }
- rc = LDAP_SUCCESS;
- }
- } else {
- rc = LDAP_REFERRAL;
+ /*
+ * The caller can specify a new entry, or a target DN and set
+ * of modifications, but not both.
+ */
+ if ( entry_orig != NULL ) {
+ if ( pb->pb_op->ora_modlist != NULL || !BER_BVISNULL( &pb->pb_op->o_req_ndn )) {
+ rs->sr_err = LDAP_PARAM_ERROR;
+ goto cleanup;
}
- } else {
- rc = LDAP_UNWILLING_TO_PERFORM;
+
+ assert( BER_BVISNULL( &pb->pb_op->o_req_dn ) ); /* shouldn't get set */
+ ber_dupbv( &pb->pb_op->o_req_dn, &entry_orig->e_name );
+ ber_dupbv( &pb->pb_op->o_req_ndn, &entry_orig->e_nname );
+ } else if ( pb->pb_op->ora_modlist == NULL || BER_BVISNULL( &pb->pb_op->o_req_ndn )) {
+ rs->sr_err = LDAP_PARAM_ERROR;
+ goto cleanup;
}
-cleanup:
+ pb->pb_op->ora_e = (Entry *)slapi_ch_calloc( 1, sizeof(Entry) );
+ ber_dupbv( &pb->pb_op->ora_e->e_name, &pb->pb_op->o_req_dn );
+ ber_dupbv( &pb->pb_op->ora_e->e_nname, &pb->pb_op->o_req_ndn );
- if ( pPB != NULL ) {
- slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rc );
- }
+ if ( entry_orig != NULL ) {
+ assert( pb->pb_op->ora_modlist == NULL );
- if ( pConn != NULL ) {
- if ( pConn->c_sb != NULL ) ber_sockbuf_free( pConn->c_sb );
- if ( op != NULL ) slapi_ch_free( (void **)&op );
- pSavePB = pPB;
- free( pConn );
+ rs->sr_err = slap_entry2mods( entry_orig, &pb->pb_op->ora_modlist,
+ &rs->sr_text, pb->pb_textbuf, sizeof( pb->pb_textbuf ) );
+ if ( rs->sr_err != LDAP_SUCCESS ) {
+ goto cleanup;
+ }
+ } else {
+ assert( pb->pb_op->ora_modlist != NULL );
}
- return( pSavePB );
-#endif /* LDAP_SLAPI */
- return NULL;
-}
+ rs->sr_err = slap_mods_check( pb->pb_op->ora_modlist, &rs->sr_text,
+ pb->pb_textbuf, sizeof( pb->pb_textbuf ), NULL );
+ if ( rs->sr_err != LDAP_SUCCESS ) {
+ goto cleanup;
+ }
-Slapi_PBlock *
-slapi_add_internal(
- char *dn,
- LDAPMod **mods,
- LDAPControl **controls,
- int log_changes )
-{
-#if defined(LDAP_SLAPI)
- LDAPMod *pMod = NULL;
- Slapi_PBlock *pb = NULL;
- Entry *pEntry = NULL;
- int i, rc=LDAP_SUCCESS;
-
- if ( mods == NULL || *mods == NULL || dn == NULL || *dn == '\0' ) {
- rc = LDAP_PARAM_ERROR ;
+ /* Duplicate the values, because we may call slapi_entry_free() */
+ rs->sr_err = slap_mods2entry( pb->pb_op->ora_modlist, &pb->pb_op->ora_e,
+ 1, 0, &rs->sr_text, pb->pb_textbuf, sizeof( pb->pb_textbuf ) );
+ if ( rs->sr_err != LDAP_SUCCESS ) {
+ goto cleanup;
}
- if ( rc == LDAP_SUCCESS ) {
- for ( i = 0, pMod = mods[0]; pMod != NULL; pMod = mods[++i] ) {
- if ( (pMod->mod_op & ~LDAP_MOD_BVALUES) != LDAP_MOD_ADD ) {
- rc = LDAP_OTHER;
- break;
- }
- }
- }
+ if ( slapi_int_func_internal_pb( pb, op_add ) == 0 ) {
+ if ( pb->pb_op->ora_e != NULL && pb->pb_op->o_private != NULL ) {
+ BackendDB *bd = pb->pb_op->o_bd;
- if ( rc == LDAP_SUCCESS ) {
- if((pEntry = LDAPModToEntry( dn, mods )) == NULL) {
- rc = LDAP_OTHER;
+ pb->pb_op->o_bd = (BackendDB *)pb->pb_op->o_private;
+ pb->pb_op->o_private = NULL;
+ be_entry_release_w( pb->pb_op, pb->pb_op->ora_e );
+ pb->pb_op->ora_e = NULL;
+ pb->pb_op->o_bd = bd;
+ pb->pb_op->o_private = NULL;
}
}
- if ( rc != LDAP_SUCCESS ) {
- pb = slapi_pblock_new();
- slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rc );
- } else {
- pb = slapi_add_entry_internal( pEntry, controls, log_changes );
- }
+cleanup:
- if ( pEntry ) {
- slapi_entry_free(pEntry);
+ if ( pb->pb_op->ora_e != NULL ) {
+ slapi_entry_free( pb->pb_op->ora_e );
+ pb->pb_op->ora_e = NULL;
+ }
+ if ( entry_orig != NULL ) {
+ pb->pb_op->ora_e = entry_orig;
+ slap_mods_free( pb->pb_op->ora_modlist, 1 );
+ pb->pb_op->ora_modlist = NULL;
}
- return(pb);
-#endif /* LDAP_SLAPI */
- return NULL;
+ return 0;
}
-/* Function : slapi_modrdn_internal
- *
- * Description : Plugin functions call this routine to modify the rdn
- * of an entry in the backend directly
- * Return values : LDAP_SUCCESS
- * LDAP_PARAM_ERROR
- * LDAP_NO_MEMORY
- * LDAP_OTHER
- * LDAP_UNWILLING_TO_PERFORM
- *
- * NOTE: This function does not support the "newSuperior" option from LDAP V3.
- */
-Slapi_PBlock *
-slapi_modrdn_internal(
- char *olddn,
- char *lnewrdn,
- int deloldrdn,
- LDAPControl **controls,
- int log_change )
+int
+slapi_modrdn_internal_pb( Slapi_PBlock *pb )
{
-#if defined(LDAP_SLAPI)
- int rc = LDAP_SUCCESS;
-
- struct berval dn = { 0, NULL };
- struct berval pdn = { 0, NULL };
- struct berval ndn = { 0, NULL };
+ if ( pb == NULL ) {
+ return -1;
+ }
- struct berval newrdn = { 0, NULL };
- struct berval pnewrdn = { 0, NULL };
- struct berval nnewrdn = { 0, NULL };
+ PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_MODRDN );
-#if 0 /* currently unused */
- struct berval newSuperior = { 0, NULL };
-#endif
- struct berval pnewSuperior = { 0, NULL };
-#if 0 /* currently unused */
- struct berval nnewSuperior = { 0, NULL };
-#endif
+ if ( BER_BVISEMPTY( &pb->pb_op->o_req_ndn ) ) {
+ pb->pb_rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+ goto cleanup;
+ }
- struct berval *pnewS = NULL;
- struct berval *nnewS = NULL;
+ slapi_int_func_internal_pb( pb, op_modrdn );
- Connection *pConn = NULL;
- Operation *op = NULL;
- Slapi_PBlock *pPB = NULL;
- Slapi_PBlock *pSavePB = NULL;
+cleanup:
- Backend *be;
-#if 0 /* currently unused */
- Backend *newSuperior_be = NULL;
-#endif
+ return 0;
+}
- int manageDsaIt = 0;
- int isCritical;
-#if 0 /* currently unused */
- const char *text = NULL;
-#endif
+int
+slapi_modify_internal_pb( Slapi_PBlock *pb )
+{
+ SlapReply *rs;
- dn.bv_val = slapi_ch_strdup(olddn);
- dn.bv_len = slapi_ch_stlen(olddn);
+ if ( pb == NULL ) {
+ return -1;
+ }
- rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
+ PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_MODIFY );
- if ( rc != LDAP_SUCCESS ) goto cleanup;
+ rs = pb->pb_rs;
- if ( ndn.bv_len == 0 ) {
- rc = LDAP_UNWILLING_TO_PERFORM;
+ if ( pb->pb_op->orm_modlist == NULL ) {
+ rs->sr_err = LDAP_PARAM_ERROR;
goto cleanup;
}
- newrdn.bv_val = slapi_ch_strdup( lnewrdn );
- newrdn.bv_len = slapi_ch_stlen( lnewrdn );
+ if ( BER_BVISEMPTY( &pb->pb_op->o_req_ndn ) ) {
+ rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+ goto cleanup;
+ }
- rc = dnPrettyNormal( NULL, &newrdn, &pnewrdn, &nnewrdn );
+ rs->sr_err = slap_mods_check( pb->pb_op->orm_modlist,
+ &rs->sr_text, pb->pb_textbuf, sizeof( pb->pb_textbuf ), NULL );
+ if ( rs->sr_err != LDAP_SUCCESS ) {
+ goto cleanup;
+ }
- if ( rc != LDAP_SUCCESS ) goto cleanup;
+ slapi_int_func_internal_pb( pb, op_modify );
- if ( rdnValidate( &pnewrdn ) != LDAP_SUCCESS ) goto cleanup;
+cleanup:
- pConn = fakeConnection( NULL, LDAP_REQ_MODRDN);
- if ( pConn == NULL) {
- rc = LDAP_NO_MEMORY;
- goto cleanup;
- }
+ return 0;
+}
- op = (Operation *)pConn->c_pending_ops.stqh_first;
- pPB = (Slapi_PBlock *)op->o_pb;
- op->o_ctrls = controls;
+static int
+slapi_int_search_entry_callback( Slapi_Entry *entry, void *callback_data )
+{
+ int nentries = 0, i = 0;
+ Slapi_Entry **head = NULL, **tp;
+ Slapi_PBlock *pb = (Slapi_PBlock *)callback_data;
- if ( slapi_control_present( controls,
- SLAPI_CONTROL_MANAGEDSAIT_OID, NULL, &isCritical ) ) {
- manageDsaIt = 1;
- }
+ PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_SEARCH );
- be = select_backend( &ndn, manageDsaIt, 0 );
- if ( be == NULL ) {
- rc = LDAP_PARTIAL_RESULTS;
- goto cleanup;
+ entry = slapi_entry_dup( entry );
+ if ( entry == NULL ) {
+ return LDAP_NO_MEMORY;
}
- op->o_dn = pConn->c_dn = be->be_rootdn;
- op->o_ndn = pConn->c_ndn = be->be_rootndn;
-
- if ( be->be_modrdn ) {
- int repl_user = be_isupdate( be, &op->o_ndn );
- if ( !be->be_update_ndn.bv_len || repl_user ) {
- rc = (*be->be_modrdn)( be, pConn, op, &pdn, &ndn,
- &pnewrdn, &nnewrdn, deloldrdn, pnewS,
- nnewS );
- if ( rc == 0 ) {
- struct slap_replog_moddn moddn;
- moddn.newrdn = &pnewrdn;
- moddn.deloldrdn = deloldrdn;
- moddn.newsup = &pnewSuperior;
- if ( log_change ) {
- replog( be, op, &pdn, &ndn, &moddn );
- }
- rc = LDAP_SUCCESS;
-
- } else {
- rc = LDAP_OTHER;
- }
-
- } else {
- rc = LDAP_REFERRAL;
+ slapi_pblock_get( pb, SLAPI_NENTRIES, &nentries );
+ slapi_pblock_get( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &head );
+
+ i = nentries + 1;
+ if ( nentries == 0 ) {
+ tp = (Slapi_Entry **)slapi_ch_malloc( 2 * sizeof(Slapi_Entry *) );
+ if ( tp == NULL ) {
+ slapi_entry_free( entry );
+ return LDAP_NO_MEMORY;
}
+ tp[0] = entry;
} else {
- rc = LDAP_UNWILLING_TO_PERFORM;
- }
-
-cleanup:
-
- if ( pPB != NULL ) {
- slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rc );
- }
-
- if ( dn.bv_val ) ch_free( dn.bv_val );
- if ( pdn.bv_val ) ch_free( pdn.bv_val );
- if ( ndn.bv_val ) ch_free( ndn.bv_val );
-
- if ( newrdn.bv_val ) ch_free( newrdn.bv_val );
- if ( pnewrdn.bv_val ) ch_free( newrdn.bv_val );
- if ( nnewrdn.bv_val ) ch_free( newrdn.bv_val );
-
- if ( pConn != NULL ) {
- if ( pConn->c_sb != NULL ) ber_sockbuf_free( pConn->c_sb );
- if ( op != NULL ) slapi_ch_free( (void **)&op );
- pSavePB = pPB;
- free( pConn );
+ tp = (Slapi_Entry **)slapi_ch_realloc( (char *)head,
+ sizeof(Slapi_Entry *) * ( i + 1 ) );
+ if ( tp == NULL ) {
+ slapi_entry_free( entry );
+ return LDAP_NO_MEMORY;
+ }
+ tp[i - 1] = entry;
}
+ tp[i] = NULL;
+
+ slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, (void *)tp );
+ slapi_pblock_set( pb, SLAPI_NENTRIES, (void *)&i );
- return( pSavePB );
-#endif /* LDAP_SLAPI */
- return NULL;
+ return LDAP_SUCCESS;
}
-/* Function : slapi_modify_internal
- *
- * Description: Plugin functions call this routine to modify an entry
- * in the backend directly
- * Return values : LDAP_SUCCESS
- * LDAP_PARAM_ERROR
- * LDAP_NO_MEMORY
- * LDAP_OTHER
- * LDAP_UNWILLING_TO_PERFORM
-*/
-Slapi_PBlock *
-slapi_modify_internal(
- char *ldn,
- LDAPMod **mods,
- LDAPControl **controls,
- int log_change )
+int
+slapi_search_internal_pb( Slapi_PBlock *pb )
{
-#if defined(LDAP_SLAPI)
- int i, rc = LDAP_SUCCESS;
- Connection *pConn = NULL;
- Operation *op = NULL;
- Slapi_PBlock *pPB = NULL;
- Slapi_PBlock *pSavePB = NULL;
-
- struct berval dn = { 0, NULL };
- struct berval pdn = { 0, NULL };
- struct berval ndn = { 0, NULL };
-
- int manageDsaIt = 0;
- int isCritical;
- Backend *be;
- struct berval *bv;
- LDAPMod *pMod;
+ return slapi_search_internal_callback_pb( pb,
+ (void *)pb,
+ NULL,
+ slapi_int_search_entry_callback,
+ NULL );
+}
- Modifications *modlist = NULL;
- Modifications **modtail = &modlist;
- Modifications tmp;
+int
+slapi_search_internal_callback_pb( Slapi_PBlock *pb,
+ void *callback_data,
+ plugin_result_callback prc,
+ plugin_search_entry_callback psec,
+ plugin_referral_entry_callback prec )
+{
+ int free_filter = 0;
+ SlapReply *rs;
- if ( mods == NULL || *mods == NULL || ldn == NULL ) {
- rc = LDAP_PARAM_ERROR ;
- goto cleanup;
+ if ( pb == NULL ) {
+ return -1;
}
- pConn = fakeConnection( NULL, LDAP_REQ_MODIFY );
- if ( pConn == NULL ) {
- rc = LDAP_NO_MEMORY;
- goto cleanup;
- }
+ PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_SEARCH );
- op = (Operation *)pConn->c_pending_ops.stqh_first;
- pPB = (Slapi_PBlock *)op->o_pb;
- op->o_ctrls = controls;
+ rs = pb->pb_rs;
- dn.bv_val = slapi_ch_strdup( ldn );
- dn.bv_len = slapi_strlen( ldn );
- rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
- if ( rc != LDAP_SUCCESS ) goto cleanup;
+ /* search callback and arguments */
+ slapi_pblock_set( pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void *)prc );
+ slapi_pblock_set( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK, (void *)psec );
+ slapi_pblock_set( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, (void *)prec );
+ slapi_pblock_set( pb, SLAPI_X_INTOP_CALLBACK_DATA, (void *)callback_data );
- if ( slapi_control_present( controls,
- SLAPI_CONTROL_MANAGEDSAIT_OID, NULL, &isCritical ) ) {
- manageDsaIt = 1;
- }
-
- be = select_backend( &ndn, manageDsaIt, 0 );
- if ( be == NULL ) {
- rc = LDAP_PARTIAL_RESULTS;
+ if ( BER_BVISEMPTY( &pb->pb_op->ors_filterstr )) {
+ rs->sr_err = LDAP_PARAM_ERROR;
goto cleanup;
- }
-
- op->o_dn = pConn->c_dn = be->be_rootdn;
- op->o_ndn = pConn->c_ndn = be->be_rootndn;
-
- for ( i = 0, pMod = mods[0]; rc == LDAP_SUCCESS && pMod != NULL;
- pMod = mods[++i] ) {
- Modifications *mod;
- if ( (pMod->mod_op & LDAP_MOD_BVALUES) != 0 ) {
- /*
- * attr values are in berval format
- * convert an array of pointers to bervals
- * to an array of bervals
- */
- rc = bvptr2obj( pMod->mod_bvalues, &bv );
- if ( rc != LDAP_SUCCESS ) goto cleanup;
- tmp.sml_type.bv_val = pMod->mod_type;
- tmp.sml_type.bv_len = strlen( pMod->mod_type );
- tmp.sml_bvalues = bv;
-#ifdef SLAP_NVALUES
- tmp.sml_nvalues = NULL;
-#endif
-
- mod = (Modifications *)ch_malloc( sizeof(Modifications) );
-
- mod->sml_op = pMod->mod_op;
- mod->sml_next = NULL;
- mod->sml_desc = NULL;
- mod->sml_type = tmp.sml_type;
- mod->sml_bvalues = tmp.sml_bvalues;
-#ifdef SLAP_NVALUES
- mod->sml_nvalues = tmp.sml_nvalues;
-#endif
- } else {
- rc = values2obj( pMod->mod_values, &bv );
- if ( rc != LDAP_SUCCESS ) goto cleanup;
- tmp.sml_type.bv_val = pMod->mod_type;
- tmp.sml_type.bv_len = strlen( pMod->mod_type );
- tmp.sml_bvalues = bv;
-#ifdef SLAP_NVALUES
- tmp.sml_nvalues = NULL;
-#endif
-
- mod = (Modifications *) ch_malloc( sizeof(Modifications) );
-
- mod->sml_op = pMod->mod_op;
- mod->sml_next = NULL;
- mod->sml_desc = NULL;
- mod->sml_type = tmp.sml_type;
- mod->sml_bvalues = tmp.sml_bvalues;
-#ifdef SLAP_NVALUES
- mod->sml_nvalues = tmp.sml_nvalues;
-#endif
- }
- *modtail = mod;
- modtail = &mod->sml_next;
-
- switch( pMod->mod_op ) {
- case LDAP_MOD_ADD:
- if ( mod->sml_bvalues == NULL ) {
- rc = LDAP_PROTOCOL_ERROR;
- goto cleanup;
- }
-
- /* fall through */
- case LDAP_MOD_DELETE:
- case LDAP_MOD_REPLACE:
- break;
+ }
- default:
- rc = LDAP_PROTOCOL_ERROR;
+ if ( pb->pb_op->ors_filter == NULL ) {
+ pb->pb_op->ors_filter = slapi_str2filter( pb->pb_op->ors_filterstr.bv_val );
+ if ( pb->pb_op->ors_filter == NULL ) {
+ rs->sr_err = LDAP_PROTOCOL_ERROR;
goto cleanup;
}
- }
- *modtail = NULL;
- if ( ndn.bv_len == 0 ) {
- rc = LDAP_UNWILLING_TO_PERFORM;
- goto cleanup;
+ free_filter = 1;
}
- if ( be->be_modify ) {
- int repl_user = be_isupdate( be, &op->o_ndn );
- if ( !be->be_update_ndn.bv_len || repl_user ) {
- int update = be->be_update_ndn.bv_len;
- const char *text = NULL;
- char textbuf[SLAP_TEXT_BUFLEN];
- size_t textlen = sizeof( textbuf );
-
- rc = slap_mods_check( modlist, update,
- &text, textbuf, textlen );
- if (rc != LDAP_SUCCESS) {
- goto cleanup;
- }
-
- if ( !repl_user ) {
- rc = slap_mods_opattrs( be, op, modlist,
- modtail, &text, textbuf,
- textlen );
- if (rc != LDAP_SUCCESS) {
- goto cleanup;
- }
- }
- rc = (*be->be_modify)( be, pConn, op,
- &pdn, &ndn, modlist );
- if ( rc == 0 ) {
- if ( log_change ) {
- replog( be, op, &pdn, &ndn, modlist );
- }
- rc = LDAP_SUCCESS;
- } else {
- rc = LDAP_OTHER;
- }
- } else {
- rc = LDAP_REFERRAL;
- }
- } else {
- rc = LDAP_UNWILLING_TO_PERFORM;
- }
+ slapi_int_func_internal_pb( pb, op_search );
cleanup:
+ if ( free_filter ) {
+ slapi_filter_free( pb->pb_op->ors_filter, 1 );
+ pb->pb_op->ors_filter = NULL;
+ }
- if ( pPB != NULL )
- slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rc );
-
- if ( dn.bv_val ) ch_free( dn.bv_val );
- if ( pdn.bv_val ) ch_free( pdn.bv_val );
- if ( ndn.bv_val ) ch_free( ndn.bv_val );
-
- if ( modlist != NULL ) freeMods( modlist );
+ slapi_pblock_delete_param( pb, SLAPI_X_INTOP_RESULT_CALLBACK );
+ slapi_pblock_delete_param( pb, SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK );
+ slapi_pblock_delete_param( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK );
+ slapi_pblock_delete_param( pb, SLAPI_X_INTOP_CALLBACK_DATA );
- if ( pConn != NULL ) {
- if ( pConn->c_sb != NULL ) ber_sockbuf_free( pConn->c_sb );
- if ( op != NULL ) slapi_ch_free( (void **)&op );
- pSavePB = pPB;
- free( pConn );
- }
+ return 0;
+}
- return ( pSavePB );
+/* Wrappers for old API */
-#endif /* LDAP_SLAPI */
- return NULL;
+void
+slapi_search_internal_set_pb( Slapi_PBlock *pb,
+ const char *base,
+ int scope,
+ const char *filter,
+ char **attrs,
+ int attrsonly,
+ LDAPControl **controls,
+ const char *uniqueid,
+ Slapi_ComponentId *plugin_identity,
+ int operation_flags )
+{
+ int no_limit = SLAP_NO_LIMIT;
+ int deref = LDAP_DEREF_NEVER;
+
+ slapi_int_connection_init_pb( pb, LDAP_REQ_SEARCH );
+ slapi_pblock_set( pb, SLAPI_SEARCH_TARGET, (void *)base );
+ slapi_pblock_set( pb, SLAPI_SEARCH_SCOPE, (void *)&scope );
+ slapi_pblock_set( pb, SLAPI_SEARCH_FILTER, (void *)0 );
+ slapi_pblock_set( pb, SLAPI_SEARCH_STRFILTER, (void *)filter );
+ slapi_pblock_set( pb, SLAPI_SEARCH_ATTRS, (void *)attrs );
+ slapi_pblock_set( pb, SLAPI_SEARCH_ATTRSONLY, (void *)&attrsonly );
+ slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
+ slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
+ slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
+ slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags );
+ slapi_pblock_set( pb, SLAPI_SEARCH_DEREF, (void *)&deref );
+ slapi_pblock_set( pb, SLAPI_SEARCH_SIZELIMIT, (void *)&no_limit );
+ slapi_pblock_set( pb, SLAPI_SEARCH_TIMELIMIT, (void *)&no_limit );
+
+ slapi_int_set_operation_dn( pb );
}
Slapi_PBlock *
-slapi_search_internal_bind(
- char *bindDN,
+slapi_search_internal(
char *ldn,
int scope,
char *filStr,
LDAPControl **controls,
char **attrs,
int attrsonly )
-{
-#if defined(LDAP_SLAPI)
- Backend *be;
- Connection *c;
- Operation *op = NULL;
- Slapi_PBlock *ptr = NULL;
- Slapi_PBlock *pSavePB = NULL;
- struct berval dn = { 0, NULL };
- struct berval pdn = { 0, NULL };
- struct berval ndn = { 0, NULL };
- Filter *filter=NULL;
- struct berval fstr = { 0, NULL };
- AttributeName *an = NULL;
- const char *text = NULL;
-
- int deref=0;
- int sizelimit=-1, timelimit=-1;
-
- int manageDsaIt = 0;
- int isCritical;
-
- int i, rc = LDAP_SUCCESS;
-
- c = fakeConnection( NULL, LDAP_REQ_SEARCH );
- if (c == NULL) {
- rc = LDAP_NO_MEMORY;
- goto cleanup;
- }
+{
+ Slapi_PBlock *pb;
- op = (Operation *)c->c_pending_ops.stqh_first;
- ptr = (Slapi_PBlock *)op->o_pb;
- op->o_ctrls = controls;
+ pb = slapi_pblock_new();
- dn.bv_val = slapi_ch_strdup(ldn);
- dn.bv_len = slapi_strlen(ldn);
+ slapi_search_internal_set_pb( pb, ldn, scope, filStr,
+ attrs, attrsonly,
+ controls, NULL, NULL, 0 );
- rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn );
- if (rc != LDAP_SUCCESS) goto cleanup;
+ slapi_search_internal_pb( pb );
- if ( scope != LDAP_SCOPE_BASE &&
- scope != LDAP_SCOPE_ONELEVEL &&
- scope != LDAP_SCOPE_SUBTREE ) {
- rc = LDAP_PROTOCOL_ERROR;
- goto cleanup;
- }
-
- filter = slapi_str2filter(filStr);
- if ( filter == NULL ) {
- rc = LDAP_PROTOCOL_ERROR;
- goto cleanup;
- }
-
- filter2bv( filter, &fstr );
+ return pb;
+}
- for ( i = 0; attrs != NULL && attrs[i] != NULL; i++ ) {
- ; /* count the number of attributes */
- }
+void
+slapi_modify_internal_set_pb( Slapi_PBlock *pb,
+ const char *dn,
+ LDAPMod **mods,
+ LDAPControl **controls,
+ const char *uniqueid,
+ Slapi_ComponentId *plugin_identity,
+ int operation_flags )
+{
+ slapi_int_connection_init_pb( pb, LDAP_REQ_MODIFY );
+ slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn );
+ slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)mods );
+ slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
+ slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
+ slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
+ slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags );
+ slapi_int_set_operation_dn( pb );
+}
- if (i > 0) {
- an = (AttributeName *)slapi_ch_calloc( (i + 1), sizeof(AttributeName) );
- for (i = 0; attrs[i] != 0; i++) {
- an[i].an_desc = NULL;
- an[i].an_oc = NULL;
- an[i].an_name.bv_val = slapi_ch_strdup(attrs[i]);
- an[i].an_name.bv_len = slapi_strlen(attrs[i]);
- slap_bv2ad( &an[i].an_name, &an[i].an_desc, &text );
- }
- an[i].an_name.bv_val = NULL;
- }
+/* Function : slapi_modify_internal
+ *
+ * Description: Plugin functions call this routine to modify an entry
+ * in the backend directly
+ * Return values : LDAP_SUCCESS
+ * LDAP_PARAM_ERROR
+ * LDAP_NO_MEMORY
+ * LDAP_OTHER
+ * LDAP_UNWILLING_TO_PERFORM
+*/
+Slapi_PBlock *
+slapi_modify_internal(
+ char *ldn,
+ LDAPMod **mods,
+ LDAPControl **controls,
+ int log_change )
+{
+ Slapi_PBlock *pb;
- if ( scope == LDAP_SCOPE_BASE ) {
- Entry *entry = NULL;
+ pb = slapi_pblock_new();
- if ( ndn.bv_len == 0 ) {
- rc = root_dse_info( c, &entry, &text );
- }
+ slapi_modify_internal_set_pb( pb, ldn, mods, controls, NULL, NULL, 0 );
+ slapi_pblock_set( pb, SLAPI_LOG_OPERATION, (void *)&log_change );
+ slapi_modify_internal_pb( pb );
- if( rc != LDAP_SUCCESS ) {
- send_ldap_result( c, op, rc, NULL, text, NULL, NULL );
- goto cleanup;
- } else if ( entry != NULL ) {
- rc = test_filter( NULL, c, op, entry, filter );
+ return pb;
+}
- if( rc == LDAP_COMPARE_TRUE ) {
- send_search_entry( NULL, c, op, entry,
- an, attrsonly, NULL );
- }
+int
+slapi_add_internal_set_pb( Slapi_PBlock *pb,
+ const char *dn,
+ LDAPMod **attrs,
+ LDAPControl **controls,
+ Slapi_ComponentId *plugin_identity,
+ int operation_flags )
+{
+ slapi_int_connection_init_pb( pb, LDAP_REQ_ADD );
+ slapi_pblock_set( pb, SLAPI_ADD_TARGET, (void *)dn );
+ slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)attrs );
+ slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
+ slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
+ slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags );
+ slapi_int_set_operation_dn( pb );
+
+ return 0;
+}
- entry_free( entry );
+Slapi_PBlock *
+slapi_add_internal(
+ char * dn,
+ LDAPMod **attrs,
+ LDAPControl **controls,
+ int log_change )
+{
+ Slapi_PBlock *pb;
- send_ldap_result( c, op, LDAP_SUCCESS,
- NULL, NULL, NULL, NULL );
+ pb = slapi_pblock_new();
- rc = LDAP_SUCCESS;
+ slapi_add_internal_set_pb( pb, dn, attrs, controls, NULL, 0);
+ slapi_pblock_set( pb, SLAPI_LOG_OPERATION, (void *)&log_change );
+ slapi_add_internal_pb( pb );
- goto cleanup;
- }
- }
+ return pb;
+}
- if ( !ndn.bv_len && default_search_nbase.bv_len ) {
- ch_free( pdn.bv_val );
- ch_free( ndn.bv_val );
+void
+slapi_add_entry_internal_set_pb( Slapi_PBlock *pb,
+ Slapi_Entry *e,
+ LDAPControl **controls,
+ Slapi_ComponentId *plugin_identity,
+ int operation_flags )
+{
+ slapi_int_connection_init_pb( pb, LDAP_REQ_ADD );
+ slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)e );
+ slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
+ slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
+ slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags );
+ slapi_int_set_operation_dn( pb );
+}
- ber_dupbv( &pdn, &default_search_base );
- ber_dupbv( &ndn, &default_search_nbase );
- }
+Slapi_PBlock *
+slapi_add_entry_internal(
+ Slapi_Entry *e,
+ LDAPControl **controls,
+ int log_change )
+{
+ Slapi_PBlock *pb;
- if ( slapi_control_present( controls,
- LDAP_CONTROL_MANAGEDSAIT, NULL, &isCritical ) ) {
- manageDsaIt = 1;
- }
+ pb = slapi_pblock_new();
- be = select_backend( &ndn, manageDsaIt, 0 );
- if ( be == NULL ) {
- if ( manageDsaIt == 1 ) {
- rc = LDAP_NO_SUCH_OBJECT;
- } else {
- rc = LDAP_PARTIAL_RESULTS;
- }
- goto cleanup;
- }
-
- op->o_dn = c->c_dn = be->be_rootdn;
- op->o_ndn = c->c_ndn = be->be_rootndn;
-
- if ( be->be_search ) {
- rc = (*be->be_search)( be, c, op, &pdn, &ndn,
- scope, deref, sizelimit, timelimit,
- filter, &fstr, an, attrsonly );
- if ( rc == 0 ) {
- rc = LDAP_SUCCESS;
- } else {
- rc = LDAP_OTHER;
- }
- } else {
- rc = LDAP_UNWILLING_TO_PERFORM;
- }
+ slapi_add_entry_internal_set_pb( pb, e, controls, NULL, 0 );
+ slapi_pblock_set( pb, SLAPI_LOG_OPERATION, (void *)&log_change );
+ slapi_add_internal_pb( pb );
-cleanup:
+ return pb;
+}
- if ( ptr != NULL )
- slapi_pblock_set( ptr, SLAPI_PLUGIN_INTOP_RESULT, (void *)rc );
+void
+slapi_rename_internal_set_pb( Slapi_PBlock *pb,
+ const char *olddn,
+ const char *newrdn,
+ const char *newsuperior,
+ int deloldrdn,
+ LDAPControl **controls,
+ const char *uniqueid,
+ Slapi_ComponentId *plugin_identity,
+ int operation_flags )
+{
+ slapi_int_connection_init_pb( pb, LDAP_REQ_MODRDN );
+ slapi_pblock_set( pb, SLAPI_MODRDN_TARGET, (void *)olddn );
+ slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)newrdn );
+ slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR, (void *)newsuperior );
+ slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)&deloldrdn );
+ slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
+ slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
+ slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
+ slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags );
+ slapi_int_set_operation_dn( pb );
+}
- if ( dn.bv_val ) free( dn.bv_val );
- if ( ndn.bv_val ) free( ndn.bv_val );
- if ( pdn.bv_val ) free( pdn.bv_val );
+/* Function : slapi_modrdn_internal
+ *
+ * Description : Plugin functions call this routine to modify the rdn
+ * of an entry in the backend directly
+ * Return values : LDAP_SUCCESS
+ * LDAP_PARAM_ERROR
+ * LDAP_NO_MEMORY
+ * LDAP_OTHER
+ * LDAP_UNWILLING_TO_PERFORM
+ *
+ * NOTE: This function does not support the "newSuperior" option from LDAP V3.
+ */
+Slapi_PBlock *
+slapi_modrdn_internal(
+ char *olddn,
+ char *lnewrdn,
+ int deloldrdn,
+ LDAPControl **controls,
+ int log_change )
+{
+ Slapi_PBlock *pb;
- if ( filter ) slapi_filter_free( filter, 1 );
- if ( fstr.bv_val ) free ( fstr.bv_val );
+ pb = slapi_pblock_new ();
- if ( an != NULL ) free( an );
+ slapi_rename_internal_set_pb( pb, olddn, lnewrdn, NULL,
+ deloldrdn, controls, NULL, NULL, 0 );
+ slapi_pblock_set( pb, SLAPI_LOG_OPERATION, (void *)&log_change );
+ slapi_modrdn_internal_pb( pb );
- if ( c != NULL ) {
- if ( c->c_sb != NULL ) ber_sockbuf_free( c->c_sb );
- if ( op != NULL ) slapi_ch_free( (void **)&op );
- pSavePB = ptr;
- free( c );
- }
- return( pSavePB );
-#endif /* LDAP_SLAPI */
- return NULL;
+ return pb;
}
-Slapi_PBlock *
-slapi_search_internal(
- char *base,
- int scope,
- char *filStr,
+void
+slapi_delete_internal_set_pb( Slapi_PBlock *pb,
+ const char *dn,
LDAPControl **controls,
- char **attrs,
- int attrsonly )
+ const char *uniqueid,
+ Slapi_ComponentId *plugin_identity,
+ int operation_flags )
{
-#if defined(LDAP_SLAPI)
- return slapi_search_internal_bind( NULL, base, scope, filStr,
- controls, attrs, attrsonly );
-#else
- return NULL;
-#endif /* LDAP_SLAPI */
+ slapi_int_connection_init_pb( pb, LDAP_REQ_DELETE );
+ slapi_pblock_set( pb, SLAPI_TARGET_DN, (void *)dn );
+ slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)controls );
+ slapi_pblock_set( pb, SLAPI_TARGET_UNIQUEID, (void *)uniqueid );
+ slapi_pblock_set( pb, SLAPI_PLUGIN_IDENTITY, (void *)plugin_identity );
+ slapi_pblock_set( pb, SLAPI_X_INTOP_FLAGS, (void *)&operation_flags );
+ slapi_int_set_operation_dn( pb );
}
+/* Function : slapi_delete_internal
+ *
+ * Description : Plugin functions call this routine to delete an entry
+ * in the backend directly
+ * Return values : LDAP_SUCCESS
+ * LDAP_PARAM_ERROR
+ * LDAP_NO_MEMORY
+ * LDAP_OTHER
+ * LDAP_UNWILLING_TO_PERFORM
+*/
+Slapi_PBlock *
+slapi_delete_internal(
+ char *ldn,
+ LDAPControl **controls,
+ int log_change )
+{
+ Slapi_PBlock *pb;
+
+ pb = slapi_pblock_new();
+
+ slapi_delete_internal_set_pb( pb, ldn, controls, NULL, NULL, 0 );
+ slapi_pblock_set( pb, SLAPI_LOG_OPERATION, (void *)&log_change );
+ slapi_delete_internal_pb( pb );
+
+ return pb;
+}
+
+#endif /* LDAP_SLAPI */
+