Connection, Operation and Backend structures.
Ensure that SLAPI_MODIFY_MODS is set to an array of LDAPMods.
}
#if defined( LDAP_SLAPI )
- slapi_pblock_set( pb, SLAPI_BACKEND, (void *)be );
- slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
- slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op );
+ slapi_backend_set_pb( pb, be );
+ slapi_connection_set_pb( pb, conn );
+ slapi_operation_set_pb( pb, op );
slapi_pblock_set( pb, SLAPI_ADD_ENTRY, (void *)e );
slapi_pblock_set( pb, SLAPI_ADD_TARGET, (void *)dn.bv_val );
slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
- slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls );
rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_ADD_FN, pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
Slapi_PBlock *pb = op->o_pb;
#if defined( LDAP_SLAPI )
- slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
- slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op );
+ slapi_connection_set_pb( pb, conn );
+ slapi_operation_set_pb( pb, op );
#endif /* defined( LDAP_SLAPI ) */
for ( i = 0; i < nbackends; i++ ) {
}
#if defined( LDAP_SLAPI )
- slapi_pblock_set( pb, SLAPI_BACKEND, (void *)be );
- slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
- slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op );
+ slapi_backend_set_pb( pb, be );
+ slapi_connection_set_pb( pb, conn );
+ slapi_operation_set_pb( pb, op );
slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
slapi_pblock_set( pb, SLAPI_BIND_METHOD, (void *)method );
slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
suffix_alias( be, &ndn );
#if defined( LDAP_SLAPI )
- slapi_pblock_set( pb, SLAPI_BACKEND, (void *)be );
- slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
- slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op );
- slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
+ slapi_backend_set_pb( pb, be );
+ slapi_connection_set_pb( pb, conn );
+ slapi_operation_set_pb( pb, op );
+ slapi_pblock_set( pb, SLAPI_COMPARE_TARGET, (void *)dn.bv_val );
slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
- slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls );
slapi_pblock_set( pb, SLAPI_COMPARE_TYPE, (void *)desc.bv_val );
slapi_pblock_set( pb, SLAPI_COMPARE_VALUE, (void *)&value );
suffix_alias( be, &ndn );
#if defined( LDAP_SLAPI )
- slapi_pblock_set( pb, SLAPI_BACKEND, (void *)be );
- slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
- slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op );
- slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
+ slapi_backend_set_pb( pb, be );
+ slapi_connection_set_pb( pb, conn );
+ slapi_operation_set_pb( pb, op );
+ slapi_pblock_set( pb, SLAPI_DELETE_TARGET, (void *)dn.bv_val );
slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
- slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls );
rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_DELETE_FN, pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
goto done;
}
- rc = slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
+ rc = slapi_connection_set_pb( pb, conn );
if ( rc != LDAP_SUCCESS ) {
rc = LDAP_OPERATIONS_ERROR;
goto done;
}
- rc = slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op);
+ rc = slapi_operation_set_pb( pb, op );
if ( rc != LDAP_SUCCESS ) {
rc = LDAP_OPERATIONS_ERROR;
goto done;
#include "slap.h"
#include "slapi.h"
+#ifdef LDAP_SLAPI
+static LDAPMod **Modifications2LDAPMods (Modifications *modlist);
+static void FreeLDAPMods (LDAPMod **);
+#endif /* LDAP_SLAPI */
+
int
do_modify(
Connection *conn,
ber_len_t len;
Modifications *modlist = NULL;
Modifications **modtail = &modlist;
+#ifdef LDAP_SLAPI
+ LDAPMod **modv = NULL;
+#endif
#ifdef LDAP_DEBUG
Modifications *tmp;
#endif
int rc;
const char *text;
int manageDSAit;
-
Slapi_PBlock *pb = op->o_pb;
#ifdef NEW_LOGGING
suffix_alias( be, &ndn );
#if defined( LDAP_SLAPI )
- slapi_pblock_set( pb, SLAPI_BACKEND, (void *)be );
- slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
- slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op );
- slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
- slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls );
+ slapi_backend_set_pb( pb, be );
+ slapi_connection_set_pb( pb, conn );
+ slapi_operation_set_pb( pb, op );
+ slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn.bv_val );
slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
+ modv = Modifications2LDAPMods(modlist);
+ slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv);
rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
if ( rc != 0 && rc != LDAP_OTHER ) {
free( ndn.bv_val );
if ( modlist != NULL )
slap_mods_free( modlist );
+ if ( modv != NULL )
+ FreeLDAPMods( modv );
return rc;
}
*modtail = NULL;
return LDAP_SUCCESS;
}
+
+#ifdef LDAP_SLAPI
+/*
+ * Synthesise an LDAPMod array from a Modifications list to pass
+ * to SLAPI.
+ */
+static LDAPMod **Modifications2LDAPMods(Modifications *modlist)
+{
+ LDAPMod *mods, **modv;
+ int i, j;
+ Modifications *ml;
+
+ /* based on back-ldap/modify.c */
+ for (i = 0, ml = modlist; ml != NULL; i++, ml = ml->sml_next)
+ ;
+
+ mods = (LDAPMod *)ch_malloc(i * sizeof(LDAPMod));
+ if (mods == NULL) {
+ return NULL;
+ }
+
+ modv = (LDAPMod **)ch_malloc((i + 1) * sizeof(LDAPMod *));
+ if (modv == NULL) {
+ ch_free(mods);
+ return NULL;
+ }
+
+ for (i = 0, ml = modlist; ml != NULL; ml = ml->sml_next) {
+ if (ml->sml_desc->ad_type->sat_no_user_mod) {
+ continue;
+ }
+ modv[i] = &mods[i];
+ mods[i].mod_op = ml->sml_op | LDAP_MOD_BVALUES;
+ mods[i].mod_type = ml->sml_desc->ad_cname.bv_val;
+ if (ml->sml_bvalues != NULL) {
+ for (j = 0; ml->sml_bvalues[j].bv_val != NULL; j++)
+ ;
+ mods[i].mod_bvalues = (struct berval **)ch_malloc((j + 1) *
+ sizeof(struct berval *));
+ for (j = 0; ml->sml_bvalues[j].bv_val != NULL; j++)
+ mods[i].mod_bvalues[j] = &ml->sml_bvalues[j];
+ } else {
+ mods[i].mod_bvalues = NULL;
+ }
+ i++;
+ }
+ modv[i] = NULL;
+
+ return modv;
+}
+
+/*
+ * Free a contiguous block of LDAP modifications.
+ */
+void FreeLDAPMods(LDAPMod **modv)
+{
+ int i;
+ LDAPMod *mods;
+
+ mods = modv[0];
+
+ for (i = 0; modv[i] != NULL; i++) {
+ ch_free(modv[i]->mod_bvalues);
+ }
+ ch_free(mods);
+ ch_free(modv);
+}
+#endif /* LDAP_SLAPI */
+
suffix_alias( be, &ndn );
#if defined( LDAP_SLAPI )
- slapi_pblock_set( pb, SLAPI_BACKEND, (void *)be );
- slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
- slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op );
- slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)dn.bv_val );
+ slapi_backend_set_pb( pb, be );
+ slapi_connection_set_pb( pb, conn );
+ slapi_operation_set_pb( pb, op );
+ slapi_pblock_set( pb, SLAPI_MODRDN_TARGET, (void *)dn.bv_val );
slapi_pblock_set( pb, SLAPI_MODRDN_NEWRDN, (void *)newrdn.bv_val );
slapi_pblock_set( pb, SLAPI_MODRDN_NEWSUPERIOR,
(void *)newSuperior.bv_val );
slapi_pblock_set( pb, SLAPI_MODRDN_DELOLDRDN, (void *)deloldrdn );
- slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls );
slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_MODRDN_FN, pb );
suffix_alias( be, &nbase );
#if defined( LDAP_SLAPI )
- slapi_pblock_set( pb, SLAPI_BACKEND, (void *)be );
- slapi_pblock_set( pb, SLAPI_CONNECTION, (void *)conn );
- slapi_pblock_set( pb, SLAPI_OPERATION, (void *)op );
- slapi_pblock_set( pb, SLAPI_BIND_TARGET, (void *)base.bv_val );
+ slapi_backend_set_pb( pb, be );
+ slapi_connection_set_pb( pb, conn );
+ slapi_operation_set_pb( pb, op );
+ slapi_pblock_set( pb, SLAPI_SEARCH_TARGET, (void *)base.bv_val );
slapi_pblock_set( pb, SLAPI_SEARCH_SCOPE, (void *)scope );
slapi_pblock_set( pb, SLAPI_SEARCH_DEREF, (void *)deref );
slapi_pblock_set( pb, SLAPI_SEARCH_SIZELIMIT, (void *)sizelimit );
slapi_pblock_set( pb, SLAPI_SEARCH_FILTER, (void *)filter );
slapi_pblock_set( pb, SLAPI_SEARCH_STRFILTER, (void *)fstr.bv_val );
slapi_pblock_set( pb, SLAPI_SEARCH_ATTRSONLY, (void *)attrsonly );
- slapi_pblock_set( pb, SLAPI_REQCONTROLS, (void *)op->o_ctrls );
slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)(1) );
rc = doPluginFNs( be, SLAPI_PLUGIN_PRE_SEARCH_FN, pb );