/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2002-2004 The OpenLDAP Foundation.
+ * Copyright 2002-2012 The OpenLDAP Foundation.
* Portions Copyright 1997,2002-2003 IBM Corporation.
* All rights reserved.
*
#include <lber_pvt.h>
#include <slapi.h>
-/*
- * use a fake listener when faking a connection,
- * so it can be used in ACLs
- */
-static struct slap_listener slap_unknown_listener = {
- BER_BVC("unknown"), /* FIXME: use a URI form? (e.g. slapi://) */
- BER_BVC("UNKNOWN")
+#ifdef LDAP_SLAPI
+
+static struct Listener slapi_listener = {
+ BER_BVC("slapi://"),
+ BER_BVC("slapi://")
};
-static void
-internal_result_v3(
+static LDAPControl **
+slapi_int_dup_controls( LDAPControl **controls )
+{
+ 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
+slapi_int_result(
Operation *op,
SlapReply *rs )
{
-#ifdef notdef
- /* XXX needs review after internal API change */
- /* rs->sr_nentries appears to always be 0 */
- if (op->o_tag == LDAP_REQ_SEARCH)
- slapi_pblock_set( (Slapi_PBlock *)op->o_pb,
- SLAPI_NENTRIES, (void *)rs->sr_nentries );
-#endif
-
- return;
+ Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
+ plugin_result_callback prc = NULL;
+ void *callback_data = NULL;
+ LDAPControl **ctrls = NULL;
+
+ assert( pb != NULL );
+
+ slapi_pblock_get( pb, SLAPI_X_INTOP_RESULT_CALLBACK, (void **)&prc );
+ slapi_pblock_get( pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
+
+ /* 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 );
+ }
+
+ return rs->sr_err;
}
static int
-internal_search_entry(
+slapi_int_search_entry(
Operation *op,
SlapReply *rs )
{
- int nentries = 0, len = 0, i = 0;
- Slapi_Entry **head = NULL, **tp;
- Slapi_Entry *entry;
+ Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
+ plugin_search_entry_callback psec = NULL;
+ void *callback_data = NULL;
+ int rc = LDAP_SUCCESS;
- entry = slapi_entry_dup( rs->sr_entry );
- if ( entry == NULL ) {
- return 1;
+ assert( pb != NULL );
+
+ 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 );
}
- 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 ) {
- slapi_entry_free( entry );
- return 1;
- }
+ return rc;
+}
- tp[ 0 ] = entry;
- } else {
- tp = (Slapi_Entry **)slapi_ch_realloc( (char *)head,
- sizeof(Slapi_Entry *) * ( i + 1 ) );
- if ( tp == NULL ) {
- slapi_entry_free( entry );
- return 1;
+static int
+slapi_int_search_reference(
+ Operation *op,
+ SlapReply *rs )
+{
+ int i, rc = LDAP_SUCCESS;
+ plugin_referral_entry_callback prec = NULL;
+ void *callback_data = NULL;
+ Slapi_PBlock *pb = SLAPI_OPERATION_PBLOCK( op );
+
+ assert( pb != NULL );
+
+ slapi_pblock_get( pb, SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK, (void **)&prec );
+ slapi_pblock_get( pb, SLAPI_X_INTOP_CALLBACK_DATA, &callback_data );
+
+ 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;
+ }
}
- tp[ i - 1 ] = entry;
}
- 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 rc;
}
-static void
-internal_result_ext(
- Operation *op,
- SlapReply *sr )
+int
+slapi_int_response( Slapi_Operation *op, SlapReply *rs )
{
- return;
+ int rc;
+
+ 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;
+ }
+
+ assert( rc != SLAP_CB_CONTINUE ); /* never try to send a wire response */
+
+ return rc;
}
static int
-internal_search_reference(
- Operation *op,
- SlapReply *sr )
+slapi_int_get_ctrls( Slapi_PBlock *pb )
{
- return LDAP_SUCCESS;
-}
+ LDAPControl **c;
+ int rc = LDAP_SUCCESS;
-Connection *
-slapi_int_init_connection(
- char *DN,
- int OpType )
-{
- Connection *pConn;
- ber_len_t max = sockbuf_max_incoming;
-
- pConn = (Connection *) slapi_ch_calloc(1, sizeof(Connection));
- if (pConn == NULL) {
- return (Connection *)NULL;
+ 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;
+ }
}
- LDAP_STAILQ_INIT( &pConn->c_pending_ops );
+ return rc;
+}
- 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;
- }
+void
+slapi_int_connection_init_pb( Slapi_PBlock *pb, ber_tag_t tag )
+{
+ Connection *conn;
+ Operation *op;
+ ber_len_t max = sockbuf_max_incoming;
- 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;
- }
+ conn = (Connection *) slapi_ch_calloc( 1, sizeof(Connection) );
- /* connection object */
- pConn->c_authmech.bv_val = NULL;
- pConn->c_authmech.bv_len = 0;
- pConn->c_dn.bv_val = NULL;
- pConn->c_dn.bv_len = 0;
- pConn->c_ndn.bv_val = NULL;
- pConn->c_ndn.bv_len = 0;
+ LDAP_STAILQ_INIT( &conn->c_pending_ops );
- pConn->c_listener = &slap_unknown_listener;
- ber_dupbv( &pConn->c_peer_domain, (struct berval *)&slap_unknown_bv );
- ber_dupbv( &pConn->c_peer_name, (struct berval *)&slap_unknown_bv );
+ op = (Operation *) slapi_ch_calloc( 1, sizeof(OperationBuffer) );
+ op->o_hdr = &((OperationBuffer *) op)->ob_hdr;
+ op->o_controls = ((OperationBuffer *) op)->ob_controls;
- LDAP_STAILQ_INIT( &pConn->c_ops );
+ 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;
- pConn->c_sasl_bind_mech.bv_val = NULL;
- pConn->c_sasl_bind_mech.bv_len = 0;
- pConn->c_sasl_authctx = NULL;
- pConn->c_sasl_sockctx = NULL;
- pConn->c_sasl_extra = NULL;
+ conn->c_pending_ops.stqh_first = op;
- pConn->c_sb = ber_sockbuf_alloc( );
+ /* 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 );
- ber_sockbuf_ctrl( pConn->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max );
+ 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 );
- pConn->c_currentber = NULL;
+ LDAP_STAILQ_INIT( &conn->c_ops );
+
+ BER_BVZERO( &conn->c_sasl_bind_mech );
+ conn->c_sasl_authctx = NULL;
+ conn->c_sasl_sockctx = NULL;
+ conn->c_sasl_extra = NULL;
+
+ conn->c_sb = ber_sockbuf_alloc();
+
+ ber_sockbuf_ctrl( conn->c_sb, LBER_SB_OPT_SET_MAX_INCOMING, &max );
+
+ conn->c_currentber = NULL;
/* should check status of thread calls */
- ldap_pvt_thread_mutex_init( &pConn->c_mutex );
- ldap_pvt_thread_mutex_init( &pConn->c_write_mutex );
- ldap_pvt_thread_cond_init( &pConn->c_write_cv );
+ ldap_pvt_thread_mutex_init( &conn->c_mutex );
+ ldap_pvt_thread_mutex_init( &conn->c_write1_mutex );
+ ldap_pvt_thread_mutex_init( &conn->c_write2_mutex );
+ ldap_pvt_thread_cond_init( &conn->c_write1_cv );
+ ldap_pvt_thread_cond_init( &conn->c_write2_cv );
- ldap_pvt_thread_mutex_lock( &pConn->c_mutex );
+ ldap_pvt_thread_mutex_lock( &conn->c_mutex );
- pConn->c_n_ops_received = 0;
- pConn->c_n_ops_executing = 0;
- pConn->c_n_ops_pending = 0;
- pConn->c_n_ops_completed = 0;
+ conn->c_n_ops_received = 0;
+ conn->c_n_ops_executing = 0;
+ conn->c_n_ops_pending = 0;
+ conn->c_n_ops_completed = 0;
- pConn->c_n_get = 0;
- pConn->c_n_read = 0;
- pConn->c_n_write = 0;
+ conn->c_n_get = 0;
+ conn->c_n_read = 0;
+ conn->c_n_write = 0;
- pConn->c_protocol = LDAP_VERSION3;
+ conn->c_protocol = LDAP_VERSION3;
- pConn->c_activitytime = pConn->c_starttime = slap_get_time();
+ conn->c_activitytime = conn->c_starttime = slap_get_time();
/*
* A real connection ID is required, because syncrepl associates
* Setting a fake connection ID will cause slap_get_commit_csn()
* to return a stale value.
*/
- connection_assign_nextid( pConn );
+ connection_assign_nextid( conn );
- pConn->c_conn_state = 0x01; /* SLAP_C_ACTIVE */
- pConn->c_struct_state = 0x02; /* SLAP_C_USED */
+ conn->c_conn_state = 0x01; /* SLAP_C_ACTIVE */
+ conn->c_struct_state = 0x02; /* SLAP_C_USED */
- pConn->c_ssf = pConn->c_transport_ssf = 0;
- pConn->c_tls_ssf = 0;
+ conn->c_ssf = conn->c_transport_ssf = local_ssf;
+ conn->c_tls_ssf = 0;
- backend_connection_init( pConn );
+ backend_connection_init( conn );
- pConn->c_send_ldap_result = internal_result_v3;
- pConn->c_send_search_entry = internal_search_entry;
- pConn->c_send_ldap_extended = internal_result_ext;
- pConn->c_send_search_reference = internal_search_reference;
+ 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;
/* operation object */
- pConn->c_pending_ops.stqh_first->o_tag = OpType;
- pConn->c_pending_ops.stqh_first->o_protocol = LDAP_VERSION3;
- pConn->c_pending_ops.stqh_first->o_authmech.bv_val = NULL;
- pConn->c_pending_ops.stqh_first->o_authmech.bv_len = 0;
- pConn->c_pending_ops.stqh_first->o_time = slap_get_time();
- pConn->c_pending_ops.stqh_first->o_do_not_cache = 1;
- pConn->c_pending_ops.stqh_first->o_threadctx = ldap_pvt_thread_pool_context();
- pConn->c_pending_ops.stqh_first->o_tmpmemctx = NULL;
- pConn->c_pending_ops.stqh_first->o_tmpmfuncs = &ch_mfuncs;
- pConn->c_pending_ops.stqh_first->o_conn = pConn;
- pConn->c_pending_ops.stqh_first->o_connid = pConn->c_connid;
-
- ldap_pvt_thread_mutex_unlock( &pConn->c_mutex );
-
- return pConn;
+ 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 );
}
-void slapi_int_connection_destroy( Connection **pConn )
+static void
+slapi_int_set_operation_dn( Slapi_PBlock *pb )
{
- Connection *conn = *pConn;
- Operation *op;
-
- if ( pConn == NULL ) {
- return;
- }
-
- op = (Operation *)conn->c_pending_ops.stqh_first;
-
- slap_graduate_commit_csn( op );
-
- if ( op->o_req_dn.bv_val != NULL ) {
- slapi_ch_free( (void **)&op->o_req_dn.bv_val );
- }
- if ( op->o_req_ndn.bv_val != NULL ) {
- slapi_ch_free( (void **)&op->o_req_ndn.bv_val );
- }
-
- if ( conn->c_sb != NULL ) {
- ber_sockbuf_free( conn->c_sb );
- }
- if ( op != NULL ) {
- slapi_ch_free( (void **)&op );
+ Backend *be;
+ Operation *op = pb->pb_op;
+
+ if ( BER_BVISNULL( &op->o_ndn ) ) {
+ /* set to root DN */
+ be = select_backend( &op->o_req_ndn, 1 );
+ if ( be != NULL ) {
+ ber_dupbv( &op->o_dn, &be->be_rootdn );
+ ber_dupbv( &op->o_ndn, &be->be_rootndn );
+ }
}
- slapi_ch_free( (void **)pConn );
}
-/*
- * Function : values2obj
- * Convert an array of strings into a BerVarray.
- * the strings.
- */
-static int
-values2obj_copy(
- char **ppValue,
- BerVarray *bvobj )
+void
+slapi_int_connection_done_pb( Slapi_PBlock *pb )
{
- int i;
- BerVarray tmpberval;
+ Connection *conn;
+ Operation *op;
- if ( ppValue == NULL ) {
- *bvobj = NULL;
- return LDAP_SUCCESS;
+ 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 );
+ }
+ slap_mods_free( op->orr_modlist, 1 );
+ 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;
}
- for ( i = 0; ppValue[i] != NULL; i++ )
- ; /* EMPTY */
-
- tmpberval = (BerVarray)slapi_ch_malloc( (i+1) * (sizeof(struct berval)) );
- if ( tmpberval == NULL ) {
- return LDAP_NO_MEMORY;
- }
- for ( i = 0; ppValue[i] != NULL; i++ ) {
- size_t len = strlen( ppValue[i] );
+ 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 );
- tmpberval[i].bv_val = slapi_ch_malloc( len + 1 );
- AC_MEMCPY( tmpberval[i].bv_val, ppValue[i], len + 1 );
- tmpberval[i].bv_len = len;
+ if ( conn->c_sb != NULL ) {
+ ber_sockbuf_free( conn->c_sb );
}
- tmpberval[i].bv_val = NULL;
- tmpberval[i].bv_len = 0;
- *bvobj = tmpberval;
+ slapi_int_free_object_extensions( SLAPI_X_EXT_OPERATION, op );
+ slapi_int_free_object_extensions( SLAPI_X_EXT_CONNECTION, conn );
- return LDAP_SUCCESS;
+ 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 );
}
static int
-bvptr2obj_copy(
- struct berval **bvptr,
- BerVarray *bvobj )
+slapi_int_func_internal_pb( Slapi_PBlock *pb, slap_operation_t which )
{
- int i;
- BerVarray tmpberval;
+ BI_op_bind **func;
+ SlapReply *rs = pb->pb_rs;
+ int rc;
- if ( bvptr == NULL ) {
- *bvobj = NULL;
- return LDAP_SUCCESS;
+ PBLOCK_ASSERT_INTOP( pb, 0 );
+
+ rc = slapi_int_get_ctrls( pb );
+ if ( rc != LDAP_SUCCESS ) {
+ rs->sr_err = rc;
+ return rc;
}
- for ( i = 0; bvptr[i] != NULL; i++ )
- ; /* EMPTY */
+ pb->pb_op->o_bd = frontendDB;
+ func = &frontendDB->be_bind;
- tmpberval = (BerVarray)slapi_ch_malloc( (i + 1) * sizeof(struct berval));
- if ( tmpberval == NULL ) {
- return LDAP_NO_MEMORY;
- }
+ return func[which]( pb->pb_op, pb->pb_rs );
+}
- for ( i = 0; bvptr[i] != NULL; i++ ) {
- tmpberval[i].bv_val = slapi_ch_malloc( bvptr[i]->bv_len );
- tmpberval[i].bv_len = bvptr[i]->bv_len;
- AC_MEMCPY( tmpberval[i].bv_val, bvptr[i]->bv_val, bvptr[i]->bv_len );
+int
+slapi_delete_internal_pb( Slapi_PBlock *pb )
+{
+ if ( pb == NULL ) {
+ return -1;
}
- tmpberval[i].bv_val = NULL;
- tmpberval[i].bv_len = 0;
+ PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_DELETE );
- *bvobj = tmpberval;
+ slapi_int_func_internal_pb( pb, op_delete );
- return LDAP_SUCCESS;
+ return 0;
}
-/*
- * Function : slapi_int_ldapmod_to_entry
- * 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
-*/
-static Entry *
-slapi_int_ldapmod_to_entry(
- Connection *pConn,
- char *ldn,
- LDAPMod **mods )
+int
+slapi_add_internal_pb( Slapi_PBlock *pb )
{
- struct berval dn = BER_BVNULL;
- Entry *pEntry=NULL;
- LDAPMod *pMod;
- struct berval *bv;
- Operation *op;
-
- Modifications *modlist = NULL;
- Modifications **modtail = &modlist;
- Modifications tmp;
+ SlapReply *rs;
+ Slapi_Entry *entry_orig = NULL;
+ OpExtraDB oex;
+ int rc;
- int rc = LDAP_SUCCESS;
- int i;
+ if ( pb == NULL ) {
+ return -1;
+ }
- const char *text = NULL;
+ PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_ADD );
- op = (Operation *)pConn->c_pending_ops.stqh_first;
+ rs = pb->pb_rs;
- pEntry = (Entry *) ch_calloc( 1, sizeof(Entry) );
- if ( pEntry == NULL) {
- rc = LDAP_NO_MEMORY;
- goto cleanup;
- }
+ entry_orig = pb->pb_op->ora_e;
+ pb->pb_op->ora_e = NULL;
- dn.bv_val = slapi_ch_strdup(ldn);
- dn.bv_len = strlen(ldn);
+ /*
+ * 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;
+ }
- rc = dnPrettyNormal( NULL, &dn, &pEntry->e_name, &pEntry->e_nname, NULL );
- if ( rc != LDAP_SUCCESS ) {
+ 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;
}
- 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 ) {
- /*
- * Convert an array of pointers to bervals to
- * an array of bervals. Note that we need to copy the
- * values too, as the slap_mods_check() will free the
- * original values after prettying; the modifications
- * being passed in may not have been allocated on the
- * heap.
- */
- rc = bvptr2obj_copy( 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_values = bv;
- tmp.sml_nvalues = NULL;
-
- 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_values = tmp.sml_values;
- mod->sml_nvalues = tmp.sml_nvalues;
-
- *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_copy( 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_values = bv;
- tmp.sml_nvalues = NULL;
-
- 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_values = tmp.sml_values;
- mod->sml_nvalues = tmp.sml_nvalues;
-
- *modtail = mod;
- modtail = &mod->sml_next;
- }
- }
- } /* for each LDAPMod */
- }
+ 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 );
- op->o_bd = select_backend( &pEntry->e_nname, 0, 0 );
- if ( op->o_bd == NULL ) {
- rc = LDAP_PARTIAL_RESULTS;
+ if ( entry_orig != NULL ) {
+ assert( pb->pb_op->ora_modlist == NULL );
+
+ 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 {
- int repl_user = be_isupdate_dn( op->o_bd, &op->o_bd->be_rootdn );
- if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
- int update = op->o_bd->be_update_ndn.bv_len;
- char textbuf[SLAP_TEXT_BUFLEN];
- size_t textlen = sizeof textbuf;
-
- rc = slap_mods_check( modlist, update, &text,
- textbuf, textlen, NULL );
- if ( rc != LDAP_SUCCESS) {
- goto cleanup;
- }
+ assert( pb->pb_op->ora_modlist != NULL );
+ }
- if ( !repl_user ) {
- rc = slap_mods_opattrs( op,
- modlist, modtail, &text,
- textbuf, textlen, 1 );
- if ( rc != LDAP_SUCCESS) {
- goto cleanup;
- }
- }
+ rs->sr_err = slap_mods_check( pb->pb_op, pb->pb_op->ora_modlist, &rs->sr_text,
+ pb->pb_textbuf, sizeof( pb->pb_textbuf ), NULL );
+ if ( rs->sr_err != LDAP_SUCCESS ) {
+ goto cleanup;
+ }
- rc = slap_mods2entry( modlist, &pEntry, repl_user,
- 0, &text, textbuf, textlen );
- if (rc != LDAP_SUCCESS) {
- goto cleanup;
- }
+ /* 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;
+ }
+
+ oex.oe.oe_key = (void *)do_add;
+ oex.oe_db = NULL;
+ LDAP_SLIST_INSERT_HEAD(&pb->pb_op->o_extra, &oex.oe, oe_next);
+ rc = slapi_int_func_internal_pb( pb, op_add );
+ LDAP_SLIST_REMOVE(&pb->pb_op->o_extra, &oex.oe, OpExtra, oe_next);
+
+ if ( !rc ) {
+ if ( pb->pb_op->ora_e != NULL && oex.oe_db != NULL ) {
+ BackendDB *bd = pb->pb_op->o_bd;
- } else {
- rc = LDAP_REFERRAL;
+ pb->pb_op->o_bd = oex.oe_db;
+ be_entry_release_w( pb->pb_op, pb->pb_op->ora_e );
+ pb->pb_op->ora_e = NULL;
+ pb->pb_op->o_bd = bd;
}
}
cleanup:
- if ( dn.bv_val )
- slapi_ch_free( (void **)&dn.bv_val );
- if ( modlist != NULL )
- slap_mods_free( modlist );
- if ( rc != LDAP_SUCCESS ) {
- if ( pEntry != NULL ) {
- slapi_entry_free( pEntry );
- }
- pEntry = NULL;
+ 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( pEntry );
+ return 0;
}
-/* 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 )
+int
+slapi_modrdn_internal_pb( Slapi_PBlock *pb )
{
-#ifdef LDAP_SLAPI
- Connection *pConn = NULL;
- Operation *op = NULL;
- Slapi_PBlock *pPB = NULL;
- SlapReply rs = { REP_RESULT };
- struct berval dn = BER_BVNULL;
-
- int manageDsaIt = SLAP_CONTROL_NONE;
- int isCritical;
-
- if ( ldn == NULL ) {
- rs.sr_err = LDAP_PARAM_ERROR;
- goto cleanup;
+ if ( pb == NULL ) {
+ return -1;
}
- pConn = slapi_int_init_connection( NULL, LDAP_REQ_DELETE );
- if (pConn == NULL) {
- rs.sr_err = LDAP_NO_MEMORY;
- goto cleanup;
- }
+ PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_MODRDN );
- op = (Operation *)pConn->c_pending_ops.stqh_first;
- pPB = (Slapi_PBlock *)op->o_pb;
- op->o_ctrls = controls;
-
- dn.bv_val = slapi_ch_strdup(ldn);
- dn.bv_len = strlen(ldn);
- rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL );
- if ( rs.sr_err != LDAP_SUCCESS )
- goto cleanup;
-
- if ( slapi_control_present( controls,
- SLAPI_CONTROL_MANAGEDSAIT_OID, NULL, &isCritical) ) {
- manageDsaIt = isCritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL;
- }
-
- op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 1 );
- if ( op->o_bd == NULL ) {
- rs.sr_err = LDAP_PARTIAL_RESULTS;
+ if ( BER_BVISEMPTY( &pb->pb_op->o_req_ndn ) ) {
+ pb->pb_rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
goto cleanup;
}
- op->o_dn = pConn->c_dn = op->o_bd->be_rootdn;
- op->o_ndn = pConn->c_ndn = op->o_bd->be_rootndn;
-
- if ( op->o_bd->be_delete ) {
- int repl_user = be_isupdate( op );
- if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
- slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
- if ( log_change ) op->o_callback = &cb;
- if ( (*op->o_bd->be_delete)( op, &rs ) ) {
- rs.sr_err = LDAP_OTHER;
- }
- } else {
- rs.sr_err = LDAP_REFERRAL;
- }
- } else {
- rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
- }
+ slapi_int_func_internal_pb( pb, op_modrdn );
cleanup:
- if ( pPB != NULL ) {
- slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
- }
- if ( dn.bv_val ) {
- slapi_ch_free( (void **)&dn.bv_val );
- }
-
- slapi_int_connection_destroy( &pConn );
- return pPB;
-#else
- return NULL;
-#endif /* LDAP_SLAPI */
+ return 0;
}
-#ifdef LDAP_SLAPI
-static Slapi_PBlock *
-slapi_int_add_entry_locked(
- Connection *pConn,
- Slapi_Entry **e,
- LDAPControl **controls,
- int log_changes )
+int
+slapi_modify_internal_pb( Slapi_PBlock *pb )
{
- Operation *op = NULL;
- Slapi_PBlock *pPB = NULL;
+ SlapReply *rs;
- int manageDsaIt = SLAP_CONTROL_NONE;
- int isCritical;
- SlapReply rs = { REP_RESULT };
-
- if ( *e == NULL ) {
- rs.sr_err = LDAP_PARAM_ERROR;
- goto cleanup;
+ if ( pb == NULL ) {
+ return -1;
}
- if ( slapi_control_present( controls, LDAP_CONTROL_MANAGEDSAIT,
- NULL, &isCritical ) ) {
- manageDsaIt = isCritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL;
- }
+ PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_MODIFY );
- op = (Operation *)pConn->c_pending_ops.stqh_first;
- pPB = (Slapi_PBlock *)op->o_pb;
- op->o_ctrls = controls;
+ rs = pb->pb_rs;
- op->o_bd = select_backend( &((*e)->e_nname), manageDsaIt, 1 );
- if ( op->o_bd == NULL ) {
- rs.sr_err = LDAP_PARTIAL_RESULTS;
+ if ( pb->pb_op->orm_modlist == NULL ) {
+ rs->sr_err = LDAP_PARAM_ERROR;
goto cleanup;
}
- op->o_dn = pConn->c_dn = op->o_bd->be_rootdn;
- op->o_ndn = pConn->c_ndn = op->o_bd->be_rootndn;
- op->oq_add.rs_e = *e;
-
- if ( op->o_bd->be_add ) {
- int repl_user = be_isupdate( op );
- if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
- slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
- if ( log_changes ) op->o_callback = &cb;
- if ( (*op->o_bd->be_add)( op, &rs ) == 0 ) {
- be_entry_release_w( op, *e );
- *e = NULL;
- }
- } else {
- rs.sr_err = LDAP_REFERRAL;
- }
- } else {
- rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
- }
-
-cleanup:
- if ( pPB != NULL ) {
- slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
+ if ( BER_BVISEMPTY( &pb->pb_op->o_req_ndn ) ) {
+ rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
+ goto cleanup;
}
- return( pPB );
-}
-#endif /* LDAP_SLAPI */
-
-Slapi_PBlock *
-slapi_add_entry_internal(
- Slapi_Entry *e,
- LDAPControl **controls,
- int log_changes )
-{
-#ifdef LDAP_SLAPI
- Slapi_PBlock *pb = NULL;
- Slapi_Entry *entry = NULL;
- Connection *pConn = NULL;
-
- pConn = slapi_int_init_connection( NULL, LDAP_REQ_ADD );
- if ( pConn == NULL ) {
- return NULL;
- }
+ rs->sr_err = slap_mods_check( pb->pb_op, pb->pb_op->orm_modlist,
+ &rs->sr_text, pb->pb_textbuf, sizeof( pb->pb_textbuf ), NULL );
+ if ( rs->sr_err != LDAP_SUCCESS ) {
+ goto cleanup;
+ }
- /*
- * We make a copy to avoid an entry that may be freed later
- * by the caller being placed in the cache.
- */
- entry = slapi_entry_dup( e );
- pb = slapi_int_add_entry_locked( pConn, &entry, controls, log_changes );
- if ( entry != NULL ) {
- slapi_entry_free( entry );
- }
+ slapi_int_func_internal_pb( pb, op_modify );
- slapi_int_connection_destroy( &pConn );
+cleanup:
- return pb;
-#else
- return NULL;
-#endif
+ return 0;
}
-Slapi_PBlock *
-slapi_add_internal(
- char *dn,
- LDAPMod **mods,
- LDAPControl **controls,
- int log_changes )
+static int
+slapi_int_search_entry_callback( Slapi_Entry *entry, void *callback_data )
{
-#ifdef LDAP_SLAPI
- LDAPMod *pMod = NULL;
- Connection *pConn = 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 ;
- }
+ int nentries = 0, i = 0;
+ Slapi_Entry **head = NULL, **tp;
+ Slapi_PBlock *pb = (Slapi_PBlock *)callback_data;
- if ( rc == LDAP_SUCCESS ) {
- for ( i = 0, pMod = mods[0]; pMod != NULL; pMod = mods[++i] ) {
- if ( (pMod->mod_op & LDAP_MOD_OP ) != LDAP_MOD_ADD ) {
- rc = LDAP_OTHER;
- break;
- }
- }
+ PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_SEARCH );
+
+ entry = slapi_entry_dup( entry );
+ if ( entry == NULL ) {
+ return LDAP_NO_MEMORY;
}
- if ( rc == LDAP_SUCCESS ) {
- pConn = slapi_int_init_connection( NULL, LDAP_REQ_ADD );
- if ( pConn != NULL ) {
- pEntry = slapi_int_ldapmod_to_entry( pConn, dn, mods );
- if ( pEntry == NULL ) {
- rc = LDAP_OTHER;
- }
+ 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;
}
- }
- if ( rc != LDAP_SUCCESS ) {
- pb = slapi_pblock_new();
- slapi_pblock_set( pb, SLAPI_PLUGIN_INTOP_RESULT, (void *)rc );
+ tp[0] = entry;
} else {
- pb = slapi_int_add_entry_locked( pConn, &pEntry, controls, log_changes );
- }
-
- if ( pEntry != NULL ) {
- slapi_entry_free( pEntry );
+ 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 );
- slapi_int_connection_destroy( &pConn );
-
- return pb;
-#else
- return NULL;
-#endif /* LDAP_SLAPI */
+ return LDAP_SUCCESS;
}
-/* 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_search_internal_pb( Slapi_PBlock *pb )
{
-#ifdef LDAP_SLAPI
- struct berval dn = BER_BVNULL;
- struct berval newrdn = BER_BVNULL;
- Connection *pConn = NULL;
- Operation *op = NULL;
- Slapi_PBlock *pPB = NULL;
- int manageDsaIt = SLAP_CONTROL_NONE;
- int isCritical;
- SlapReply rs = { REP_RESULT };
-
- pConn = slapi_int_init_connection( NULL, LDAP_REQ_MODRDN );
- if ( pConn == NULL) {
- rs.sr_err = LDAP_NO_MEMORY;
- goto cleanup;
- }
+ return slapi_search_internal_callback_pb( pb,
+ (void *)pb,
+ NULL,
+ slapi_int_search_entry_callback,
+ NULL );
+}
- op = (Operation *)pConn->c_pending_ops.stqh_first;
- pPB = (Slapi_PBlock *)op->o_pb;
- op->o_ctrls = controls;
+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 ( slapi_control_present( controls,
- SLAPI_CONTROL_MANAGEDSAIT_OID, NULL, &isCritical ) ) {
- manageDsaIt = isCritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL;
+ if ( pb == NULL ) {
+ return -1;
}
- op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 1 );
- if ( op->o_bd == NULL ) {
- rs.sr_err = LDAP_PARTIAL_RESULTS;
- goto cleanup;
- }
+ PBLOCK_ASSERT_INTOP( pb, LDAP_REQ_SEARCH );
- op->o_dn = pConn->c_dn = op->o_bd->be_rootdn;
- op->o_ndn = pConn->c_ndn = op->o_bd->be_rootndn;
+ rs = pb->pb_rs;
- dn.bv_val = slapi_ch_strdup( olddn );
- dn.bv_len = strlen( olddn );
+ /* 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 );
- rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL );
- if ( rs.sr_err != LDAP_SUCCESS ) {
+ if ( BER_BVISEMPTY( &pb->pb_op->ors_filterstr )) {
+ rs->sr_err = LDAP_PARAM_ERROR;
goto cleanup;
}
- if ( op->o_req_dn.bv_len == 0 ) {
- rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
- goto cleanup;
+ 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;
+ }
+
+ free_filter = 1;
}
- newrdn.bv_val = slapi_ch_strdup( lnewrdn );
- newrdn.bv_len = strlen( lnewrdn );
+ slapi_int_func_internal_pb( pb, op_search );
- rs.sr_err = dnPrettyNormal( NULL, &newrdn, &op->oq_modrdn.rs_newrdn, &op->oq_modrdn.rs_nnewrdn, NULL );
- if ( rs.sr_err != LDAP_SUCCESS ) {
- goto cleanup;
+cleanup:
+ if ( free_filter ) {
+ slapi_filter_free( pb->pb_op->ors_filter, 1 );
+ pb->pb_op->ors_filter = NULL;
}
- if ( rdn_validate( &op->oq_modrdn.rs_nnewrdn ) != LDAP_SUCCESS ) {
- goto cleanup;
- }
+ 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 );
- op->oq_modrdn.rs_newSup = NULL;
- op->oq_modrdn.rs_nnewSup = NULL;
- op->oq_modrdn.rs_deleteoldrdn = deloldrdn;
-
- if ( op->o_bd->be_modrdn ) {
- int repl_user = be_isupdate( op );
- if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
- slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
- if ( log_change ) op->o_callback = &cb;
- if ( (*op->o_bd->be_modrdn)( op, &rs ) ) {
- rs.sr_err = LDAP_OTHER;
- }
- } else {
- rs.sr_err = LDAP_REFERRAL;
- }
- } else {
- rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
- }
+ return 0;
+}
-cleanup:
+/* Wrappers for old API */
+
+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 );
+}
- if ( pPB != NULL ) {
- slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
- }
-
- if ( dn.bv_val )
- slapi_ch_free( (void **)&dn.bv_val );
+Slapi_PBlock *
+slapi_search_internal(
+ char *ldn,
+ int scope,
+ char *filStr,
+ LDAPControl **controls,
+ char **attrs,
+ int attrsonly )
+{
+ Slapi_PBlock *pb;
- if ( newrdn.bv_val )
- slapi_ch_free( (void **)&newrdn.bv_val );
- if ( op->oq_modrdn.rs_newrdn.bv_val )
- slapi_ch_free( (void **)&op->oq_modrdn.rs_newrdn.bv_val );
- if ( op->oq_modrdn.rs_nnewrdn.bv_val )
- slapi_ch_free( (void **)&op->oq_modrdn.rs_nnewrdn.bv_val );
+ pb = slapi_pblock_new();
- slapi_int_connection_destroy( &pConn );
+ slapi_search_internal_set_pb( pb, ldn, scope, filStr,
+ attrs, attrsonly,
+ controls, NULL, NULL, 0 );
- return pPB;
-#else
- return NULL;
-#endif /* LDAP_SLAPI */
+ slapi_search_internal_pb( pb );
+
+ return pb;
+}
+
+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 );
}
/* Function : slapi_modify_internal
LDAPControl **controls,
int log_change )
{
-#ifdef LDAP_SLAPI
- int i;
- Connection *pConn = NULL;
- Operation *op = NULL;
- Slapi_PBlock *pPB = NULL;
+ Slapi_PBlock *pb;
- struct berval dn = BER_BVNULL;
+ pb = slapi_pblock_new();
- int manageDsaIt = SLAP_CONTROL_NONE;
- int isCritical;
- struct berval *bv;
- LDAPMod *pMod;
+ 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 );
- Modifications *modlist = NULL;
- Modifications **modtail = &modlist;
- Modifications tmp;
-
- SlapReply rs = { REP_RESULT };
-
- if ( mods == NULL || *mods == NULL || ldn == NULL ) {
- rs.sr_err = LDAP_PARAM_ERROR ;
- goto cleanup;
- }
-
- pConn = slapi_int_init_connection( NULL, LDAP_REQ_MODIFY );
- if ( pConn == NULL ) {
- rs.sr_err = LDAP_NO_MEMORY;
- goto cleanup;
- }
+ return pb;
+}
- op = (Operation *)pConn->c_pending_ops.stqh_first;
- pPB = (Slapi_PBlock *)op->o_pb;
- op->o_ctrls = controls;
+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;
+}
- dn.bv_val = slapi_ch_strdup( ldn );
- dn.bv_len = strlen( ldn );
- rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL );
- if ( rs.sr_err != LDAP_SUCCESS ) {
- goto cleanup;
- }
+Slapi_PBlock *
+slapi_add_internal(
+ char * dn,
+ LDAPMod **attrs,
+ LDAPControl **controls,
+ int log_change )
+{
+ Slapi_PBlock *pb;
- if ( slapi_control_present( controls,
- SLAPI_CONTROL_MANAGEDSAIT_OID, NULL, &isCritical ) ) {
- manageDsaIt = isCritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL;
- }
+ pb = slapi_pblock_new();
- op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 1 );
- if ( op->o_bd == NULL ) {
- rs.sr_err = LDAP_PARTIAL_RESULTS;
- goto cleanup;
- }
-
- op->o_dn = pConn->c_dn = op->o_bd->be_rootdn;
- op->o_ndn = pConn->c_ndn = op->o_bd->be_rootndn;
-
- for ( i = 0, pMod = mods[0];
- rs.sr_err == 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
- */
- rs.sr_err = bvptr2obj_copy( pMod->mod_bvalues, &bv );
- if ( rs.sr_err != LDAP_SUCCESS )
- goto cleanup;
- tmp.sml_type.bv_val = pMod->mod_type;
- tmp.sml_type.bv_len = strlen( pMod->mod_type );
- tmp.sml_values = bv;
- tmp.sml_nvalues = NULL;
-
- mod = (Modifications *)ch_malloc( sizeof(Modifications) );
-
- mod->sml_op = pMod->mod_op & LDAP_MOD_OP;
- mod->sml_next = NULL;
- mod->sml_desc = NULL;
- mod->sml_type = tmp.sml_type;
- mod->sml_values = tmp.sml_values;
- mod->sml_nvalues = tmp.sml_nvalues;
- } else {
- rs.sr_err = values2obj_copy( pMod->mod_values, &bv );
- if ( rs.sr_err != LDAP_SUCCESS )
- goto cleanup;
- tmp.sml_type.bv_val = pMod->mod_type;
- tmp.sml_type.bv_len = strlen( pMod->mod_type );
- tmp.sml_values = bv;
- tmp.sml_nvalues = NULL;
-
- mod = (Modifications *) ch_malloc( sizeof(Modifications) );
-
- mod->sml_op = pMod->mod_op & LDAP_MOD_OP;
- mod->sml_next = NULL;
- mod->sml_desc = NULL;
- mod->sml_type = tmp.sml_type;
- mod->sml_values = tmp.sml_values;
- mod->sml_nvalues = tmp.sml_nvalues;
- }
- *modtail = mod;
- modtail = &mod->sml_next;
+ 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 );
- switch( pMod->mod_op & LDAP_MOD_OP ) {
- case LDAP_MOD_ADD:
- if ( mod->sml_values == NULL ) {
- rs.sr_err = LDAP_PROTOCOL_ERROR;
- goto cleanup;
- }
+ return pb;
+}
- /* fall through */
- case LDAP_MOD_DELETE:
- case LDAP_MOD_REPLACE:
- break;
+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 );
+}
- default:
- rs.sr_err = LDAP_PROTOCOL_ERROR;
- goto cleanup;
- }
- }
- *modtail = NULL;
+Slapi_PBlock *
+slapi_add_entry_internal(
+ Slapi_Entry *e,
+ LDAPControl **controls,
+ int log_change )
+{
+ Slapi_PBlock *pb;
- if ( op->o_req_ndn.bv_len == 0 ) {
- rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
- goto cleanup;
- }
+ pb = slapi_pblock_new();
- op->oq_modify.rs_modlist = modlist;
-
- if ( op->o_bd->be_modify ) {
- int repl_user = be_isupdate( op );
- if ( !op->o_bd->be_update_ndn.bv_len || repl_user ) {
- int update = op->o_bd->be_update_ndn.bv_len;
- const char *text = NULL;
- char textbuf[SLAP_TEXT_BUFLEN];
- size_t textlen = sizeof( textbuf );
- slap_callback cb = { NULL, slap_replog_cb, NULL, NULL };
-
- rs.sr_err = slap_mods_check( modlist, update,
- &text, textbuf, textlen, NULL );
- if ( rs.sr_err != LDAP_SUCCESS ) {
- goto cleanup;
- }
+ 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 );
- if ( !repl_user ) {
- rs.sr_err = slap_mods_opattrs( op, modlist,
- modtail, &text, textbuf,
- textlen, 1 );
- if ( rs.sr_err != LDAP_SUCCESS ) {
- goto cleanup;
- }
- }
- if ( log_change ) op->o_callback = &cb;
- if ( (*op->o_bd->be_modify)( op, &rs ) ) {
- rs.sr_err = LDAP_OTHER;
- }
- } else {
- rs.sr_err = LDAP_REFERRAL;
- }
- } else {
- rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
- }
+ return pb;
+}
-cleanup:
+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 );
+ slap_modrdn2mods( pb->pb_op, pb->pb_rs );
+ slapi_int_set_operation_dn( pb );
+}
- if ( pPB != NULL )
- slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
+/* 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 ( dn.bv_val )
- slapi_ch_free( (void **)&dn.bv_val );
+ pb = slapi_pblock_new ();
- if ( modlist != NULL )
- slap_mods_free( modlist );
+ 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 );
- slapi_int_connection_destroy( &pConn );
+ return pb;
+}
- return pPB;
-#else
- return NULL;
-#endif /* LDAP_SLAPI */
+void
+slapi_delete_internal_set_pb( Slapi_PBlock *pb,
+ const char *dn,
+ LDAPControl **controls,
+ const char *uniqueid,
+ Slapi_ComponentId *plugin_identity,
+ int operation_flags )
+{
+ 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_search_internal(
+slapi_delete_internal(
char *ldn,
- int scope,
- char *filStr,
LDAPControl **controls,
- char **attrs,
- int attrsonly )
-{
-#ifdef LDAP_SLAPI
- Connection *c;
- Operation *op = NULL;
- Slapi_PBlock *pPB = NULL;
- struct berval dn = BER_BVNULL;
- Filter *filter=NULL;
- struct berval fstr = BER_BVNULL;
- AttributeName *an = NULL;
- const char *text = NULL;
-
- int manageDsaIt = SLAP_CONTROL_NONE;
- int isCritical;
- int i;
-
- SlapReply rs = { REP_RESULT };
-
- c = slapi_int_init_connection( NULL, LDAP_REQ_SEARCH );
- if ( c == NULL ) {
- rs.sr_err = LDAP_NO_MEMORY;
- goto cleanup;
- }
-
- op = (Operation *)c->c_pending_ops.stqh_first;
- pPB = (Slapi_PBlock *)op->o_pb;
- op->o_ctrls = controls;
-
- if ( ldn != NULL ) {
- dn.bv_val = slapi_ch_strdup(ldn);
- dn.bv_len = strlen(ldn);
- }
-
- rs.sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, NULL );
- if ( rs.sr_err != LDAP_SUCCESS ) {
- goto cleanup;
- }
-
- if ( scope != LDAP_SCOPE_BASE &&
- scope != LDAP_SCOPE_ONELEVEL &&
- scope != LDAP_SCOPE_SUBTREE ) {
- rs.sr_err = LDAP_PROTOCOL_ERROR;
- goto cleanup;
- }
-
- filter = slapi_str2filter(filStr);
- if ( filter == NULL ) {
- rs.sr_err = LDAP_PROTOCOL_ERROR;
- goto cleanup;
- }
-
- filter2bv( filter, &fstr );
-
- for ( i = 0; attrs != NULL && attrs[i] != NULL; i++ ) {
- ; /* count the number of attributes */
- }
-
- 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_oc_exclude = 0;
- an[i].an_name.bv_val = slapi_ch_strdup(attrs[i]);
- an[i].an_name.bv_len = strlen(attrs[i]);
- slap_bv2ad( &an[i].an_name, &an[i].an_desc, &text );
- }
- an[i].an_name.bv_val = NULL;
- }
-
- memset( &rs, 0, sizeof(rs) );
- rs.sr_type = REP_RESULT;
- rs.sr_err = LDAP_SUCCESS;
- rs.sr_entry = NULL; /* paranoia */
-
- if ( scope == LDAP_SCOPE_BASE ) {
- rs.sr_entry = NULL;
-
- if ( op->o_req_ndn.bv_len == 0 ) {
- rs.sr_err = root_dse_info( c, &rs.sr_entry, &rs.sr_text );
- }
-
- if( rs.sr_err != LDAP_SUCCESS ) {
- send_ldap_result( op, &rs );
- goto cleanup;
- } else if ( rs.sr_entry != NULL ) {
- rs.sr_err = test_filter( op, rs.sr_entry, filter );
-
- if ( rs.sr_err == LDAP_COMPARE_TRUE ) {
- rs.sr_type = REP_SEARCH;
- rs.sr_err = LDAP_SUCCESS;
- rs.sr_attrs = an;
- rs.sr_operational_attrs = NULL;
- rs.sr_flags = REP_ENTRY_MODIFIABLE;
-
- send_search_entry( op, &rs );
- }
-
- entry_free( rs.sr_entry );
-
- rs.sr_type = REP_RESULT;
- rs.sr_err = LDAP_SUCCESS;
-
- send_ldap_result( op, &rs );
-
- goto cleanup;
- }
- }
-
- if ( !op->o_req_ndn.bv_len && default_search_nbase.bv_len ) {
- slapi_ch_free( (void **)&op->o_req_dn.bv_val );
- slapi_ch_free( (void **)&op->o_req_ndn.bv_val );
-
- ber_dupbv( &op->o_req_dn, &default_search_base );
- ber_dupbv( &op->o_req_ndn, &default_search_nbase );
- }
-
- if ( slapi_control_present( controls,
- LDAP_CONTROL_MANAGEDSAIT, NULL, &isCritical ) ) {
- manageDsaIt = isCritical ? SLAP_CONTROL_CRITICAL : SLAP_CONTROL_NONCRITICAL;
- }
-
- op->o_bd = select_backend( &op->o_req_ndn, manageDsaIt, 1 );
- if ( op->o_bd == NULL ) {
- if ( manageDsaIt > SLAP_CONTROL_NONE ) {
- rs.sr_err = LDAP_NO_SUCH_OBJECT;
- } else {
- rs.sr_err = LDAP_PARTIAL_RESULTS;
- }
- goto cleanup;
- }
-
- op->o_dn = c->c_dn = op->o_bd->be_rootdn;
- op->o_ndn = c->c_ndn = op->o_bd->be_rootndn;
-
- op->oq_search.rs_scope = scope;
- op->oq_search.rs_deref = 0;
- op->oq_search.rs_slimit = SLAP_NO_LIMIT;
- op->oq_search.rs_tlimit = SLAP_NO_LIMIT;
- op->oq_search.rs_attrsonly = attrsonly;
- op->oq_search.rs_attrs = an;
- op->oq_search.rs_filter = filter;
- op->oq_search.rs_filterstr = fstr;
-
- if ( op->o_bd->be_search ) {
- if ( (*op->o_bd->be_search)( op, &rs ) != 0 ) {
- rs.sr_err = LDAP_OTHER;
- }
- } else {
- rs.sr_err = LDAP_UNWILLING_TO_PERFORM;
- }
-
-cleanup:
+ int log_change )
+{
+ Slapi_PBlock *pb;
- if ( pPB != NULL )
- slapi_pblock_set( pPB, SLAPI_PLUGIN_INTOP_RESULT, (void *)rs.sr_err );
+ pb = slapi_pblock_new();
- if ( dn.bv_val )
- slapi_ch_free( (void **)&dn.bv_val );
- if ( filter )
- slapi_filter_free( filter, 1 );
- if ( fstr.bv_val )
- slapi_ch_free( (void **)&fstr.bv_val );
- if ( an != NULL )
- slapi_ch_free( (void **)&an );
+ 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 );
- slapi_int_connection_destroy( &c );
+ return pb;
+}
- return pPB;
-#else
- return NULL;
#endif /* LDAP_SLAPI */
-}