|| ( (vals) && BER_BVISNULL( &((vals)[ 0 ]) ) ) \
)
+int
+backsql_modify_delete_all_values(
+ Operation *op,
+ SlapReply *rs,
+ SQLHDBC dbh,
+ backsql_entryID *e_id,
+ backsql_at_map_rec *at )
+{
+ backsql_info *bi = (backsql_info *)op->o_bd->be_private;
+ RETCODE rc;
+ SQLHSTMT asth;
+ BACKSQL_ROW_NTS row;
+
+ rc = backsql_Prepare( dbh, &asth, at->bam_query, 0 );
+ if ( rc != SQL_SUCCESS ) {
+ Debug( LDAP_DEBUG_TRACE,
+ " backsql_modify_delete_all_values(): "
+ "error preparing query\n", 0, 0, 0 );
+ backsql_PrintErrors( bi->db_env, dbh,
+ asth, rc );
+
+ if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
+ rs->sr_text = "SQL-backend error";
+ return rs->sr_err = LDAP_OTHER;
+ }
+ return LDAP_SUCCESS;
+ }
+
+#ifdef BACKSQL_ARBITRARY_KEY
+ rc = backsql_BindParamStr( asth, 1,
+ e_id->eid_keyval.bv_val,
+ BACKSQL_MAX_KEY_LEN );
+#else /* ! BACKSQL_ARBITRARY_KEY */
+ rc = backsql_BindParamID( asth, 1, &e_id->eid_keyval );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
+ if ( rc != SQL_SUCCESS ) {
+ Debug( LDAP_DEBUG_TRACE,
+ " backsql_modify_delete_all_values(): "
+ "error binding key value parameter\n",
+ 0, 0, 0 );
+ backsql_PrintErrors( bi->db_env, dbh,
+ asth, rc );
+ SQLFreeStmt( asth, SQL_DROP );
+
+ if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
+ rs->sr_text = "SQL-backend error";
+ return rs->sr_err = LDAP_OTHER;
+ }
+
+ return LDAP_SUCCESS;
+ }
+
+ rc = SQLExecute( asth );
+ if ( !BACKSQL_SUCCESS( rc ) ) {
+ Debug( LDAP_DEBUG_TRACE,
+ " backsql_modify_delete_all_values(): "
+ "error executing attribute query\n",
+ 0, 0, 0 );
+ backsql_PrintErrors( bi->db_env, dbh,
+ asth, rc );
+ SQLFreeStmt( asth, SQL_DROP );
+
+ if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
+ rs->sr_text = "SQL-backend error";
+ return rs->sr_err = LDAP_OTHER;
+ }
+
+ return LDAP_SUCCESS;
+ }
+
+ backsql_BindRowAsStrings( asth, &row );
+ for ( rc = SQLFetch( asth );
+ BACKSQL_SUCCESS( rc );
+ rc = SQLFetch( asth ) )
+ {
+ int i;
+ /* first parameter no, parameter order */
+ SQLUSMALLINT pno, po;
+ /* procedure return code */
+ int prc;
+
+ for ( i = 0; i < row.ncols; i++ ) {
+ SQLHSTMT sth;
+
+ rc = backsql_Prepare( dbh, &sth, at->bam_delete_proc, 0 );
+ if ( rc != SQL_SUCCESS ) {
+ Debug( LDAP_DEBUG_TRACE,
+ " backsql_modify_delete_all_values(): "
+ "error preparing query %s\n",
+ at->bam_delete_proc, 0, 0 );
+ backsql_PrintErrors( bi->db_env, dbh,
+ sth, rc );
+
+ if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
+ rs->sr_text = "SQL-backend error";
+ return rs->sr_err = LDAP_OTHER;
+ }
+ return LDAP_SUCCESS;
+ }
+
+ if ( BACKSQL_IS_DEL( at->bam_expect_return ) ) {
+ pno = 1;
+ SQLBindParameter( sth, 1,
+ SQL_PARAM_OUTPUT,
+ SQL_C_ULONG,
+ SQL_INTEGER,
+ 0, 0, &prc, 0, 0 );
+ } else {
+ pno = 0;
+ }
+ po = ( BACKSQL_IS_DEL( at->bam_param_order ) ) > 0;
+#ifdef BACKSQL_ARBITRARY_KEY
+ SQLBindParameter( sth, pno + 1 + po,
+ SQL_PARAM_INPUT,
+ SQL_C_CHAR, SQL_VARCHAR,
+ 0, 0, e_id->eid_keyval.bv_val,
+ 0, 0 );
+ Debug( LDAP_DEBUG_TRACE,
+ " backsql_modify_delete_all_values() arg%d=%s\n",
+ pno + 1 + po, e_id->eid_keyval.bv_val, 0 );
+#else /* ! BACKSQL_ARBITRARY_KEY */
+ SQLBindParameter( sth, pno + 1 + po,
+ SQL_PARAM_INPUT,
+ SQL_C_ULONG, SQL_INTEGER,
+ 0, 0, &e_id->eid_keyval, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE,
+ " backsql_modify_delete_all_values() arg%d=%lu\n",
+ pno + 1 + po, e_id->eid_keyval, 0 );
+#endif /* ! BACKSQL_ARBITRARY_KEY */
+
+ /*
+ * check for syntax needed here
+ * maybe need binary bind?
+ */
+ SQLBindParameter( sth, pno + 2 - po,
+ SQL_PARAM_INPUT,
+ SQL_C_CHAR, SQL_CHAR,
+ 0, 0, row.cols[ i ],
+ strlen( row.cols[ i ] ), 0 );
+
+ Debug( LDAP_DEBUG_TRACE,
+ " backsql_modify_delete_all_values(): "
+ "arg%d=%s; executing \"%s\"\n",
+ pno + 2 - po, row.cols[ i ],
+ at->bam_delete_proc );
+ rc = SQLExecute( sth );
+ if ( rc != SQL_SUCCESS ) {
+ Debug( LDAP_DEBUG_TRACE,
+ " backsql_modify_delete_all_values(): "
+ "delete_proc "
+ "execution failed\n",
+ 0, 0, 0 );
+ backsql_PrintErrors( bi->db_env,
+ dbh, sth, rc );
+
+ if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
+ SQLFreeStmt( sth, SQL_DROP );
+ rs->sr_text = "SQL-backend error";
+ return rs->sr_err = LDAP_OTHER;
+ }
+ }
+ SQLFreeStmt( sth, SQL_DROP );
+ }
+ }
+ backsql_FreeRow( &row );
+ SQLFreeStmt( asth, SQL_DROP );
+
+ return LDAP_SUCCESS;
+}
+
int
backsql_modify_internal(
Operation *op,
Debug( LDAP_DEBUG_TRACE, "==>backsql_modify_internal(): "
"traversing modifications list\n", 0, 0, 0 );
-#ifndef BACKSQL_REALLOC_STMT
- SQLAllocStmt( dbh, &sth );
-#endif /* BACKSQL_REALLOC_STMT */
-
for ( ml = modlist; ml != NULL; ml = ml->sml_next ) {
AttributeDescription *ad;
+ int sm_op;
+ static char *sm_ops[] = { "add", "delete", "replace", "increment", NULL };
+
+ BerVarray sm_values;
+#if 0
+ /* NOTE: some time we'll have to pass
+ * the normalized values as well */
+ BerVarray nvalues;
+#endif
backsql_at_map_rec *at = NULL;
struct berval *at_val;
- Modification *c_mod;
int i;
/* first parameter no, parameter order */
SQLUSMALLINT pno, po;
/* procedure return code */
int prc;
-#ifdef BACKSQL_REALLOC_STMT
- SQLAllocStmt( dbh, &sth );
-#endif /* BACKSQL_REALLOC_STMT */
-
- c_mod = &ml->sml_mod;
- ad = c_mod->sm_desc;
+ ad = ml->sml_mod.sm_desc;
+ sm_op = ( ml->sml_mod.sm_op & LDAP_MOD_OP );
+ sm_values = ml->sml_mod.sm_values;
+#if 0
+ sm_nvalues = ml->sml_mod.sm_nvalues;
+#endif
Debug( LDAP_DEBUG_TRACE, " backsql_modify_internal(): "
- "modifying attribute \"%s\" according to "
+ "modifying attribute \"%s\" (%s) according to "
"mappings for objectClass \"%s\"\n",
- ad->ad_cname.bv_val, BACKSQL_OC_NAME( oc ), 0 );
+ ad->ad_cname.bv_val, sm_ops[ sm_op ], BACKSQL_OC_NAME( oc ) );
- if ( backsql_attr_skip( ad, c_mod->sm_values ) ) {
+ if ( backsql_attr_skip( ad, sm_values ) ) {
continue;
}
Debug( LDAP_DEBUG_TRACE, " backsql_modify_internal(): "
"attribute \"%s\" is not registered "
"in objectClass \"%s\"\n",
- ad->ad_cname.bv_val, oc, 0 );
+ ad->ad_cname.bv_val, BACKSQL_OC_NAME( oc ), 0 );
if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
rs->sr_err = LDAP_UNWILLING_TO_PERFORM;
continue;
}
- switch( c_mod->sm_op ) {
+ switch ( sm_op ) {
case LDAP_MOD_REPLACE: {
- SQLHSTMT asth;
- BACKSQL_ROW_NTS row;
-
Debug( LDAP_DEBUG_TRACE, " backsql_modify_internal(): "
"replacing values for attribute \"%s\"\n",
at->bam_ad->ad_cname.bv_val, 0, 0 );
}
del_all:
- rc = backsql_Prepare( dbh, &asth, at->bam_query, 0 );
- if ( rc != SQL_SUCCESS ) {
- Debug( LDAP_DEBUG_TRACE,
- " backsql_modify_internal(): "
- "error preparing query\n", 0, 0, 0 );
- backsql_PrintErrors( bi->db_env, dbh,
- asth, rc );
-
- if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
- rs->sr_err = LDAP_OTHER;
- rs->sr_text = "SQL-backend error";
- goto done;
- }
-
- break;
- }
-
-#ifdef BACKSQL_ARBITRARY_KEY
- rc = backsql_BindParamStr( asth, 1,
- e_id->eid_keyval.bv_val,
- BACKSQL_MAX_KEY_LEN );
-#else /* ! BACKSQL_ARBITRARY_KEY */
- rc = backsql_BindParamID( asth, 1, &e_id->eid_keyval );
-#endif /* ! BACKSQL_ARBITRARY_KEY */
- if ( rc != SQL_SUCCESS ) {
- Debug( LDAP_DEBUG_TRACE,
- " backsql_modify_internal(): "
- "error binding key value parameter\n",
- 0, 0, 0 );
- backsql_PrintErrors( bi->db_env, dbh,
- asth, rc );
- SQLFreeStmt( asth, SQL_DROP );
-
- if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
- rs->sr_err = LDAP_OTHER;
- rs->sr_text = "SQL-backend error";
- goto done;
- }
-
- break;
- }
-
- rc = SQLExecute( asth );
- if ( !BACKSQL_SUCCESS( rc ) ) {
- Debug( LDAP_DEBUG_TRACE,
- " backsql_modify_internal(): "
- "error executing attribute query\n",
- 0, 0, 0 );
- backsql_PrintErrors( bi->db_env, dbh,
- asth, rc );
- SQLFreeStmt( asth, SQL_DROP );
-
- if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
- rs->sr_err = LDAP_OTHER;
- rs->sr_text = "SQL-backend error";
- goto done;
- }
-
- break;
- }
-
- backsql_BindRowAsStrings( asth, &row );
- rc = SQLFetch( asth );
- for ( ; BACKSQL_SUCCESS( rc ); rc = SQLFetch( asth ) ) {
- for ( i = 0; i < row.ncols; i++ ) {
- if ( BACKSQL_IS_DEL( at->bam_expect_return ) ) {
- pno = 1;
- SQLBindParameter(sth, 1,
- SQL_PARAM_OUTPUT,
- SQL_C_ULONG,
- SQL_INTEGER,
- 0, 0, &prc, 0, 0 );
- } else {
- pno = 0;
- }
- po = ( BACKSQL_IS_DEL( at->bam_param_order ) ) > 0;
-#ifdef BACKSQL_ARBITRARY_KEY
- SQLBindParameter( sth, pno + 1 + po,
- SQL_PARAM_INPUT,
- SQL_C_CHAR, SQL_VARCHAR,
- 0, 0, e_id->eid_keyval.bv_val,
- 0, 0 );
-#else /* ! BACKSQL_ARBITRARY_KEY */
- SQLBindParameter( sth, pno + 1 + po,
- SQL_PARAM_INPUT,
- SQL_C_ULONG, SQL_INTEGER,
- 0, 0, &e_id->eid_keyval, 0, 0 );
-#endif /* ! BACKSQL_ARBITRARY_KEY */
-
- /*
- * check for syntax needed here
- * maybe need binary bind?
- */
- SQLBindParameter(sth, pno + 2 - po,
- SQL_PARAM_INPUT,
- SQL_C_CHAR, SQL_CHAR,
- 0, 0, row.cols[ i ],
- strlen( row.cols[ i ] ), 0 );
-
- Debug( LDAP_DEBUG_TRACE,
- " backsql_modify_internal(): "
- "executing \"%s\"\n",
- at->bam_delete_proc, 0, 0 );
- rc = SQLExecDirect( sth,
- at->bam_delete_proc, SQL_NTS );
- if ( rc != SQL_SUCCESS ) {
- Debug( LDAP_DEBUG_TRACE,
- " backsql_modify_internal(): "
- "delete_proc "
- "execution failed\n",
- 0, 0, 0 );
- backsql_PrintErrors( bi->db_env,
- dbh, sth, rc );
-
- if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
- rs->sr_err = LDAP_OTHER;
- rs->sr_text = "SQL-backend error";
- goto done;
- }
- }
-#ifdef BACKSQL_REALLOC_STMT
- SQLFreeStmt( sth, SQL_DROP );
- SQLAllocStmt( dbh, &sth );
-#endif /* BACKSQL_REALLOC_STMT */
- }
+ rs->sr_err = backsql_modify_delete_all_values( op, rs, dbh, e_id, at );
+ if ( rs->sr_err != LDAP_SUCCESS ) {
+ goto done;
}
- backsql_FreeRow( &row );
- SQLFreeStmt( asth, SQL_DROP );
/* LDAP_MOD_DELETE gets here if all values must be deleted */
- if ( c_mod->sm_op == LDAP_MOD_DELETE ) {
+ if ( sm_op == LDAP_MOD_DELETE ) {
break;
}
}
* PASSTHROUGH - to add new attributes -- do NOT add break
*/
case LDAP_MOD_ADD:
- case SLAP_MOD_SOFTADD:
+ /* case SLAP_MOD_SOFTADD: */
add_only:;
if ( at->bam_add_proc == NULL ) {
Debug( LDAP_DEBUG_TRACE,
Debug( LDAP_DEBUG_TRACE, " backsql_modify_internal(): "
"adding new values for attribute \"%s\"\n",
at->bam_ad->ad_cname.bv_val, 0, 0 );
- for ( i = 0, at_val = c_mod->sm_values;
- at_val->bv_val != NULL;
- i++, at_val++ ) {
-
+ for ( i = 0, at_val = sm_values;
+ !BER_BVISNULL( at_val );
+ i++, at_val++ )
+ {
rc = backsql_Prepare( dbh, &sth, at->bam_add_proc, 0 );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE,
dbh, sth, rc );
if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
+ SQLFreeStmt( sth, SQL_DROP );
rs->sr_err = LDAP_OTHER;
rs->sr_text = "SQL-backend error";
goto done;
}
}
-#ifdef BACKSQL_REALLOC_STMT
SQLFreeStmt( sth, SQL_DROP );
- SQLAllocStmt( dbh, &sth );
-#endif /* BACKSQL_REALLOC_STMT */
}
break;
break;
}
- if ( c_mod->sm_values == NULL ) {
+ if ( sm_values == NULL ) {
Debug( LDAP_DEBUG_TRACE,
" backsql_modify_internal(): "
"no values given to delete "
"deleting values for attribute \"%s\"\n",
at->bam_ad->ad_cname.bv_val, 0, 0 );
- for ( i = 0, at_val = c_mod->sm_values;
- at_val->bv_val != NULL;
- i++, at_val++ ) {
+ for ( i = 0, at_val = sm_values;
+ !BER_BVISNULL( at_val );
+ i++, at_val++ )
+ {
+ rc = backsql_Prepare( dbh, &sth, at->bam_delete_proc, 0 );
+ if ( rc != SQL_SUCCESS ) {
+ Debug( LDAP_DEBUG_TRACE,
+ " backsql_modify_internal(): "
+ "error preparing delete query\n",
+ 0, 0, 0 );
+ backsql_PrintErrors( bi->db_env, dbh, sth, rc );
+
+ rs->sr_err = LDAP_OTHER;
+ rs->sr_text = "SQL-backend error";
+ goto done;
+ }
+
if ( BACKSQL_IS_DEL( at->bam_expect_return ) ) {
pno = 1;
SQLBindParameter( sth, 1,
" backsql_modify_internal(): "
"executing \"%s\"\n",
at->bam_delete_proc, 0, 0 );
- rc = SQLExecDirect( sth, at->bam_delete_proc,
- SQL_NTS );
+ rc = SQLExecute( sth );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE,
" backsql_modify_internal(): "
dbh, sth, rc );
if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
+ SQLFreeStmt( sth, SQL_DROP );
rs->sr_err = LDAP_OTHER;
rs->sr_text = "SQL-backend error";
goto done;
}
}
-#ifdef BACKSQL_REALLOC_STMT
SQLFreeStmt( sth, SQL_DROP );
- SQLAllocStmt( dbh, &sth );
-#endif /* BACKSQL_REALLOC_STMT */
+ }
+ break;
+
+ case LDAP_MOD_INCREMENT:
+ Debug( LDAP_DEBUG_TRACE, " backsql_modify_internal(): "
+ "increment not supported yet\n", 0, 0, 0 );
+ if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
+ rs->sr_err = LDAP_OTHER;
+ rs->sr_text = "SQL-backend error";
+ goto done;
}
break;
}
-#ifndef BACKSQL_REALLOC_STMT
- SQLFreeStmt( sth, SQL_RESET_PARAMS );
-#else /* BACKSQL_REALLOC_STMT */
- SQLFreeStmt( sth, SQL_DROP );
-#endif /* BACKSQL_REALLOC_STMT */
}
done:;
-
-#ifndef BACKSQL_REALLOC_STMT
- SQLFreeStmt( sth, SQL_DROP );
-#endif /* BACKSQL_REALLOC_STMT */
-
- Debug( LDAP_DEBUG_TRACE, "<==backsql_modify_internal(): %d%d%s\n",
- rs->sr_err, rs->sr_text ? ": " : "",
+ Debug( LDAP_DEBUG_TRACE, "<==backsql_modify_internal(): %d%s%s\n",
+ rs->sr_err,
+ rs->sr_text ? ": " : "",
rs->sr_text ? rs->sr_text : "" );
/*
Operation *op,
SlapReply *rs,
SQLHDBC dbh,
- SQLHSTMT *sth,
backsql_oc_map_rec *oc,
Attribute *at,
unsigned long new_keyval )
/* procedure return code */
int prc;
SQLUSMALLINT currpos;
+ SQLHSTMT sth;
at_rec = backsql_ad2at( oc, at->a_desc );
if ( at_rec == NULL ) {
- Debug( LDAP_DEBUG_TRACE, " backsql_add(\"%s\"): "
+ Debug( LDAP_DEBUG_TRACE, " backsql_add_attr(\"%s\"): "
"attribute \"%s\" is not registered "
"in objectclass \"%s\"\n",
op->oq_add.rs_e->e_name.bv_val,
}
if ( at_rec->bam_add_proc == NULL ) {
- Debug( LDAP_DEBUG_TRACE, " backsql_add(\"%s\"): "
+ Debug( LDAP_DEBUG_TRACE, " backsql_add_attr(\"%s\"): "
"add procedure is not defined "
"for attribute \"%s\" "
"of structuralObjectClass \"%s\"\n",
}
for ( i = 0, at_val = &at->a_vals[ i ];
- at_val->bv_val != NULL;
+ !BER_BVISNULL( at_val );
i++, at_val = &at->a_vals[ i ] )
{
char logbuf[] = "val[18446744073709551615UL], id=18446744073709551615UL";
}
}
-#ifdef BACKSQL_REALLOC_STMT
- rc = backsql_Prepare( dbh, sth, at_rec->bam_add_proc, 0 );
+ rc = backsql_Prepare( dbh, &sth, at_rec->bam_add_proc, 0 );
if ( rc != SQL_SUCCESS ) {
if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
return LDAP_SUCCESS;
}
-#endif /* BACKSQL_REALLOC_STMT */
if ( BACKSQL_IS_ADD( at_rec->bam_expect_return ) ) {
pno = 1;
- SQLBindParameter( *sth, 1, SQL_PARAM_OUTPUT,
+ SQLBindParameter( sth, 1, SQL_PARAM_OUTPUT,
SQL_C_ULONG, SQL_INTEGER,
0, 0, &prc, 0, 0 );
} else {
po = ( BACKSQL_IS_ADD( at_rec->bam_param_order ) ) > 0;
currpos = pno + 1 + po;
- SQLBindParameter( *sth, currpos,
+ SQLBindParameter( sth, currpos,
SQL_PARAM_INPUT, SQL_C_ULONG,
SQL_INTEGER, 0, 0, &new_keyval, 0, 0 );
currpos = pno + 2 - po;
* maybe need binary bind?
*/
- backsql_BindParamStr( *sth, currpos,
+ backsql_BindParamStr( sth, currpos,
at_val->bv_val, at_val->bv_len + 1 );
#ifdef LDAP_DEBUG
- snprintf( logbuf, sizeof( logbuf ), "val[%d], id=%ld",
+ snprintf( logbuf, sizeof( logbuf ), "val[%lu], id=%lu",
i, new_keyval );
- Debug( LDAP_DEBUG_TRACE, " backsql_add(\"%s\"): "
+ Debug( LDAP_DEBUG_TRACE, " backsql_add_attr(\"%s\"): "
"executing \"%s\" %s\n",
op->oq_add.rs_e->e_name.bv_val,
at_rec->bam_add_proc, logbuf );
#endif
-#ifndef BACKSQL_REALLOC_STMT
- rc = SQLExecDirect( *sth, at_rec->bam_add_proc, SQL_NTS );
-#else /* BACKSQL_REALLOC_STMT */
- rc = SQLExecute( *sth );
-#endif /* BACKSQL_REALLOC_STMT */
+ rc = SQLExecute( sth );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE,
- " backsql_add(\"%s\"): "
+ " backsql_add_attr(\"%s\"): "
"add_proc execution failed\n",
op->oq_add.rs_e->e_name.bv_val, 0, 0 );
- backsql_PrintErrors( bi->db_env, dbh, *sth, rc );
+ backsql_PrintErrors( bi->db_env, dbh, sth, rc );
if ( BACKSQL_FAIL_IF_NO_MAPPING( bi ) ) {
+ SQLFreeStmt( sth, SQL_DROP );
rs->sr_text = "SQL-backend error";
return rs->sr_err = LDAP_OTHER;
}
}
-#ifndef BACKSQL_REALLOC_STMT
- SQLFreeStmt( *sth, SQL_RESET_PARAMS );
-#else /* BACKSQL_REALLOC_STMT */
- SQLFreeStmt( *sth, SQL_DROP );
-#endif /* BACKSQL_REALLOC_STMT */
+ SQLFreeStmt( sth, SQL_DROP );
}
return LDAP_SUCCESS;
SQLHDBC dbh;
SQLHSTMT sth;
unsigned long new_keyval = 0;
- long i;
RETCODE rc;
backsql_oc_map_rec *oc = NULL;
- backsql_at_map_rec *at_rec = NULL;
backsql_entryID parent_id = BACKSQL_ENTRYID_INIT;
Entry p;
Attribute *at,
*at_objectClass = NULL;
- struct berval *at_val;
struct berval pdn;
- /* first parameter #, parameter order */
- SQLUSMALLINT pno, po;
- /* procedure return code */
- int prc;
struct berval realdn = BER_BVNULL,
realpdn = BER_BVNULL;
*/
if ( be_issuffix( op->o_bd, &op->oq_add.rs_e->e_nname ) ) {
pdn = slap_empty_bv;
+
} else {
dnParent( &op->oq_add.rs_e->e_nname, &pdn );
}
* if not attempting to add entry at suffix or with parent ""
*/
if ( ( ( !be_isroot( op ) && !be_shadow_update( op ) )
- || pdn.bv_len > 0 ) && !is_entry_glue( op->oq_add.rs_e ) )
+ || !BER_BVISEMPTY( &pdn ) ) && !is_entry_glue( op->oq_add.rs_e ) )
{
Debug( LDAP_DEBUG_TRACE, " backsql_add: %s denied\n",
- pdn.bv_len == 0 ? "suffix" : "entry at root",
+ BER_BVISEMPTY( &pdn ) ? "suffix" : "entry at root",
0, 0 );
/*
* Look for matched
rs->sr_err = backsql_dn2id( bi, NULL, dbh, &realpdn );
switch ( rs->sr_err ) {
case LDAP_NO_SUCH_OBJECT:
- if ( pdn.bv_len > 0 ) {
+ if ( !BER_BVISEMPTY( &pdn ) ) {
break;
}
/* fail over to next case */
rs->sr_text = "SQL-backend error";
goto done;
}
+
if ( op->o_noop ) {
SQLTransact( SQL_NULL_HENV, dbh, SQL_ROLLBACK );
}
SQLINTEGER value_len;
if ( BACKSQL_CREATE_NEEDS_SELECT( bi ) ) {
-#ifndef BACKSQL_REALLOC_STMT
- SQLFreeStmt( sth, SQL_RESET_PARAMS );
-#else /* BACKSQL_REALLOC_STMT */
SQLFreeStmt( sth, SQL_DROP );
rc = SQLAllocStmt( dbh, &sth );
if ( rc != SQL_SUCCESS ) {
rs->sr_text = "SQL-backend error";
goto done;
}
-#endif /* BACKSQL_REALLOC_STMT */
rc = SQLExecDirect( sth, oc->bom_create_keyval, SQL_NTS );
if ( rc != SQL_SUCCESS ) {
}
}
-#ifndef BACKSQL_REALLOC_STMT
- SQLFreeStmt( sth, SQL_RESET_PARAMS );
-#else /* BACKSQL_REALLOC_STMT */
SQLFreeStmt( sth, SQL_DROP );
-#endif /* BACKSQL_REALLOC_STMT */
Debug( LDAP_DEBUG_TRACE, " backsql_add(\"%s\"): "
"create_proc returned keyval=%ld\n",
op->oq_add.rs_e->e_name.bv_val, new_keyval, 0 );
for ( at = op->oq_add.rs_e->e_attrs; at != NULL; at = at->a_next ) {
- SQLUSMALLINT currpos;
-
Debug( LDAP_DEBUG_TRACE, " backsql_add(): "
"adding attribute \"%s\"\n",
at->a_desc->ad_cname.bv_val, 0, 0 );
continue;
}
- rs->sr_err = backsql_add_attr( op, rs, dbh, &sth, oc, at, new_keyval );
+ rs->sr_err = backsql_add_attr( op, rs, dbh, oc, at, new_keyval );
if ( rs->sr_err != LDAP_SUCCESS ) {
goto done;
}
}
-#ifdef BACKSQL_REALLOC_STMT
rc = backsql_Prepare( dbh, &sth, bi->insentry_query, 0 );
if ( rc != SQL_SUCCESS ) {
rs->sr_err = LDAP_OTHER;
rs->sr_text = "SQL-backend error";
goto done;
}
-#endif /* BACKSQL_REALLOC_STMT */
backsql_BindParamStr( sth, 1, realdn.bv_val, BACKSQL_MAX_DN_LEN );
SQLBindParameter( sth, 2, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
"parent_id=%ld, keyval=%ld\n",
oc->bom_id, parent_id.eid_id, new_keyval );
#endif /* ! BACKSQL_ARBITRARY_KEY */
-#ifndef BACKSQL_REALLOC_STMT
- rc = SQLExecDirect( sth, bi->insentry_query, SQL_NTS );
-#else /* BACKSQL_REALLOC_STMT */
rc = SQLExecute( sth );
-#endif /* BACKSQL_REALLOC_STMT */
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, " backsql_add(\"%s\"): "
"could not insert ldap_entries record\n",
/* FIXME: need ldap_entries.id of newly added entry */
if ( at_objectClass ) {
- rs->sr_err = backsql_add_attr( op, rs, dbh, &sth, oc, at_objectClass, new_keyval );
+ rs->sr_err = backsql_add_attr( op, rs, dbh, oc, at_objectClass, new_keyval );
if ( rs->sr_err != LDAP_SUCCESS ) {
goto done;
}
*/
if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
SQLTransact( SQL_NULL_HENV, dbh, SQL_COMMIT );
+
} else {
SQLTransact( SQL_NULL_HENV, dbh, SQL_ROLLBACK );
-
}
/*
*/
#undef BACKSQL_ARBITRARY_KEY
+/*
+ * define to the appropriate aliasing string
+ */
+#define BACKSQL_ALIASING "AS "
+/* #define BACKSQL_ALIASING "" */
+
+/*
+ * define to the appropriate quoting char
+ */
+/* #define BACKSQL_ALIASING_QUOTE '"' */
+/* #define BACKSQL_ALIASING_QUOTE '\'' */
+
/*
* API
*/
#include "ldap_pvt.h"
#include "proto-sql.h"
+typedef struct backsql_delete_attr_t {
+ Operation *op;
+ SlapReply *rs;
+ SQLHDBC dbh;
+ backsql_entryID *e_id;
+} backsql_delete_attr_t;
+
+#define DELETE_ATTR_STOP (-6)
+
+static int
+backsql_delete_attr_f( void *v_at, void *v_bda )
+{
+ backsql_at_map_rec *at = (backsql_at_map_rec *)v_at;
+ backsql_delete_attr_t *bda = (backsql_delete_attr_t *)v_bda;
+ int rc;
+
+ rc = backsql_modify_delete_all_values( bda->op,
+ bda->rs, bda->dbh, bda->e_id, at );
+
+ if ( rc != LDAP_SUCCESS ) {
+ return BACKSQL_AVL_STOP;
+ }
+
+ return BACKSQL_AVL_CONTINUE;
+}
+
+static int
+backsql_delete_all_attrs(
+ Operation *op,
+ SlapReply *rs,
+ SQLHDBC dbh,
+ backsql_entryID *e_id,
+ backsql_oc_map_rec *oc )
+{
+ backsql_delete_attr_t bda;
+ int rc;
+
+ bda.op = op;
+ bda.rs = rs;
+ bda.dbh = dbh;
+ bda.e_id = e_id;
+
+ rc = avl_apply( oc->bom_attrs, backsql_delete_attr_f, &bda,
+ BACKSQL_AVL_STOP, AVL_INORDER );
+ if ( rc == BACKSQL_AVL_STOP ) {
+ return rs->sr_err;
+ }
+
+ return LDAP_SUCCESS;
+}
+
int
backsql_delete( Operation *op, SlapReply *rs )
{
goto done;
}
- SQLAllocStmt( dbh, &sth );
-
rc = backsql_Prepare( dbh, &sth, oc->bom_delete_proc, 0 );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE,
rs->sr_text = "SQL-backend error";
goto done;
}
-#ifndef BACKSQL_REALLOC_STMT
- SQLFreeStmt( sth, SQL_RESET_PARAMS );
-#else /* BACKSQL_REALLOC_STMT */
SQLFreeStmt( sth, SQL_DROP );
- SQLAllocStmt( dbh, &sth );
-#endif /* BACKSQL_REALLOC_STMT */
- /* we should do the same for ldap_entry_objclasses and ldap_referrals,
- * for those RDBMSes that do not allow stored procedures... */
+ /* avl_apply ... */
+ rs->sr_err = backsql_delete_all_attrs( op, rs, dbh, &e_id, oc );
+ if ( rs->sr_err != LDAP_SUCCESS ) {
+ goto done;
+ }
+
+ /* delete "auxiliary" objectClasses, if any... */
rc = backsql_Prepare( dbh, &sth, bi->delobjclasses_query, 0 );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE,
}
SQLFreeStmt( sth, SQL_DROP );
+ /* delete referrals, if any... */
rc = backsql_Prepare( dbh, &sth, bi->delreferrals_query, 0 );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE,
}
SQLFreeStmt( sth, SQL_DROP );
+ /* delete entry... */
rc = backsql_Prepare( dbh, &sth, bi->delentry_query, 0 );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE,
#ifdef BACKSQL_TRACE
#ifdef BACKSQL_ARBITRARY_KEY
Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_values(): "
- "query=%s keyval=%s\n", at->bam_query,
+ "query=\"%s\" keyval=%s\n", at->bam_query,
bsi->bsi_c_eid->eid_keyval.bv_val, 0 );
#else /* !BACKSQL_ARBITRARY_KEY */
Debug( LDAP_DEBUG_TRACE, "backsql_get_attr_values(): "
- "query=%s keyval=%d\n", at->bam_query,
+ "query=\"%s\" keyval=%d\n", at->bam_query,
bsi->bsi_c_eid->eid_keyval, 0 );
#endif /* ! BACKSQL_ARBITRARY_KEY */
#endif /* BACKSQL_TRACE */
RETCODE rc;
backsql_entryID e_id = BACKSQL_ENTRYID_INIT,
pe_id = BACKSQL_ENTRYID_INIT,
- new_pid = BACKSQL_ENTRYID_INIT;
+ new_pe_id = BACKSQL_ENTRYID_INIT;
backsql_oc_map_rec *oc = NULL;
- struct berval p_dn, p_ndn,
+ struct berval p_dn = BER_BVNULL, p_ndn = BER_BVNULL,
*new_pdn = NULL, *new_npdn = NULL,
- new_dn, new_ndn;
+ new_dn = BER_BVNULL, new_ndn = BER_BVNULL;
LDAPRDN new_rdn = NULL;
LDAPRDN old_rdn = NULL;
Entry e;
- Modifications *mod;
+ Modifications *mod = NULL;
struct berval *newSuperior = op->oq_modrdn.rs_newSup;
+ char *next;
Debug( LDAP_DEBUG_TRACE, "==>backsql_modrdn() renaming entry \"%s\", "
"newrdn=\"%s\", newSuperior=\"%s\"\n",
goto modrdn_return;
}
- build_new_dn( &new_dn, new_pdn, &op->oq_modrdn.rs_newrdn, NULL );
+ build_new_dn( &new_dn, new_pdn, &op->oq_modrdn.rs_newrdn,
+ op->o_tmpmemctx );
rs->sr_err = dnNormalize( 0, NULL, NULL, &new_dn, &new_ndn,
- op->o_tmpmemctx );
+ op->o_tmpmemctx );
if ( rs->sr_err != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): "
"new dn is invalid (\"%s\") - aborting\n",
backsql_free_entryID( &pe_id, 0 );
- rs->sr_err = backsql_dn2id( bi, &new_pid, dbh, new_npdn );
+ rs->sr_err = backsql_dn2id( bi, &new_pe_id, dbh, new_npdn );
if ( rs->sr_err != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): "
"could not lookup new parent entry id\n", 0, 0, 0 );
#ifdef BACKSQL_ARBITRARY_KEY
Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): "
- "new parent entry id=%s\n", new_pid.eid_id.bv_val, 0, 0 );
+ "new parent entry id=%s\n", new_pe_id.eid_id.bv_val, 0, 0 );
#else /* ! BACKSQL_ARBITRARY_KEY */
Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): "
- "new parent entry id=%ld\n", new_pid.eid_id, 0, 0 );
+ "new parent entry id=%ld\n", new_pe_id.eid_id, 0, 0 );
#endif /* ! BACKSQL_ARBITRARY_KEY */
Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): "
"executing delentry_query\n", 0, 0, 0 );
- SQLAllocStmt( dbh, &sth );
+
+ rc = backsql_Prepare( dbh, &sth, bi->delentry_query, 0 );
+ if ( rc != SQL_SUCCESS ) {
+ Debug( LDAP_DEBUG_TRACE,
+ " backsql_modrdn(): "
+ "error preparing delentry_query\n", 0, 0, 0 );
+ backsql_PrintErrors( bi->db_env, dbh,
+ sth, rc );
+
+ rs->sr_text = "SQL-backend error";
+ rs->sr_err = LDAP_OTHER;
+ goto done;
+ }
+
#ifdef BACKSQL_ARBITRARY_KEY
SQLBindParameter( sth, 1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR,
0, 0, e_id.eid_id.bv_val, 0, 0 );
SQLBindParameter( sth, 1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER,
0, 0, &e_id.eid_id, 0, 0 );
#endif /* ! BACKSQL_ARBITRARY_KEY */
- rc = SQLExecDirect( sth, bi->delentry_query, SQL_NTS );
+ rc = SQLExecute( sth );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): "
"failed to delete record from ldap_entries\n",
0, 0, 0 );
backsql_PrintErrors( bi->db_env, dbh, sth, rc );
+ SQLFreeStmt( sth, SQL_DROP );
rs->sr_err = LDAP_OTHER;
rs->sr_text = "SQL-backend error";
send_ldap_result( op, rs );
- goto modrdn_return;
+ goto done;
}
- SQLFreeStmt( sth, SQL_RESET_PARAMS );
+ SQLFreeStmt( sth, SQL_DROP );
Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): "
"executing insentry_query\n", 0, 0, 0 );
+
+ rc = backsql_Prepare( dbh, &sth, bi->insentry_query, 0 );
+ if ( rc != SQL_SUCCESS ) {
+ Debug( LDAP_DEBUG_TRACE,
+ " backsql_modrdn(): "
+ "error preparing insentry_query\n", 0, 0, 0 );
+ backsql_PrintErrors( bi->db_env, dbh,
+ sth, rc );
+
+ rs->sr_text = "SQL-backend error";
+ rs->sr_err = LDAP_OTHER;
+ goto done;
+ }
+
backsql_BindParamStr( sth, 1, new_dn.bv_val, BACKSQL_MAX_DN_LEN );
SQLBindParameter( sth, 2, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
0, 0, &e_id.eid_oc_id, 0, 0 );
#ifdef BACKSQL_ARBITRARY_KEY
SQLBindParameter( sth, 3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR,
- 0, 0, new_pid.eid_id.bv_val, 0, 0 );
+ 0, 0, new_pe_id.eid_id.bv_val, 0, 0 );
SQLBindParameter( sth, 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR,
0, 0, e_id.eid_keyval.bv_val, 0, 0 );
#else /* ! BACKSQL_ARBITRARY_KEY */
SQLBindParameter( sth, 3, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
- 0, 0, &new_pid.eid_id, 0, 0 );
+ 0, 0, &new_pe_id.eid_id, 0, 0 );
SQLBindParameter( sth, 4, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER,
0, 0, &e_id.eid_keyval, 0, 0 );
#endif /* ! BACKSQL_ARBITRARY_KEY */
- rc = SQLExecDirect( sth, bi->insentry_query, SQL_NTS );
+ rc = SQLExecute( sth );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): "
"could not insert ldap_entries record\n", 0, 0, 0 );
backsql_PrintErrors( bi->db_env, dbh, sth, rc );
+ SQLFreeStmt( sth, SQL_DROP );
rs->sr_err = LDAP_OTHER;
rs->sr_text = "SQL-backend error";
send_ldap_result( op, rs );
- goto modrdn_return;
+ goto done;
}
+ SQLFreeStmt( sth, SQL_DROP );
/*
* Get attribute type and attribute value of our new rdn,
* we will need to add that to our new entry
*/
- if ( ldap_bv2rdn( &op->oq_modrdn.rs_newrdn, &new_rdn,
- (char **)&rs->sr_text,
- LDAP_DN_FORMAT_LDAP ) ) {
+ if ( ldap_bv2rdn( &op->oq_modrdn.rs_newrdn, &new_rdn, &next,
+ LDAP_DN_FORMAT_LDAP ) )
+ {
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, ERR,
" backsql_modrdn: can't figure out "
0, 0, 0 );
#endif
rs->sr_err = LDAP_INVALID_DN_SYNTAX;
- goto modrdn_return;
+ goto done;
}
#ifdef NEW_LOGGING
#endif
if ( op->oq_modrdn.rs_deleteoldrdn ) {
- if ( ldap_bv2rdn( &op->o_req_dn, &old_rdn,
- (char **)&rs->sr_text,
- LDAP_DN_FORMAT_LDAP ) ) {
+ if ( ldap_bv2rdn( &op->o_req_dn, &old_rdn, &next,
+ LDAP_DN_FORMAT_LDAP ) )
+ {
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, ERR,
" backsql_modrdn: can't figure out "
0, 0, 0 );
#endif
rs->sr_err = LDAP_OTHER;
- goto modrdn_return;
+ goto done;
}
}
oc = backsql_id2oc( bi, e_id.eid_oc_id );
rs->sr_err = backsql_modify_internal( op, rs, dbh, oc, &e_id, mod );
- if ( rs->sr_err == LDAP_SUCCESS ) {
+done:;
+ /*
+ * Commit only if all operations succeed
+ */
+ if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) {
+ SQLTransact( SQL_NULL_HENV, dbh, SQL_COMMIT );
- /*
- * Commit only if all operations succeed
- */
- SQLTransact( SQL_NULL_HENV, dbh,
- op->o_noop ? SQL_ROLLBACK : SQL_COMMIT );
+ } else {
+ SQLTransact( SQL_NULL_HENV, dbh, SQL_ROLLBACK );
}
-modrdn_return:
- SQLFreeStmt( sth, SQL_DROP );
-
- if ( new_dn.bv_val ) {
- ch_free( new_dn.bv_val );
+modrdn_return:;
+ if ( !BER_BVISNULL( &new_dn ) ) {
+ slap_sl_free( new_dn.bv_val, op->o_tmpmemctx );
}
- if ( new_ndn.bv_val ) {
- ch_free( new_ndn.bv_val );
+ if ( !BER_BVISNULL( &new_ndn ) ) {
+ slap_sl_free( new_ndn.bv_val, op->o_tmpmemctx );
}
/* LDAP v2 supporting correct attribute handling. */
}
if ( mod != NULL ) {
Modifications *tmp;
- for (; mod; mod=tmp ) {
+ for (; mod; mod = tmp ) {
tmp = mod->sml_next;
free( mod );
}
}
- if ( new_pid.eid_dn.bv_val ) {
- backsql_free_entryID( &pe_id, 0 );
+ if ( new_pe_id.eid_dn.bv_val ) {
+ backsql_free_entryID( &new_pe_id, 0 );
}
send_ldap_result( op, rs );
/*
* add.c
*/
+int backsql_modify_delete_all_values(
+ Operation *op,
+ SlapReply *rs,
+ SQLHDBC dbh,
+ backsql_entryID *e_id,
+ backsql_at_map_rec *at );
+
int backsql_modify_internal(
Operation *op,
SlapReply *rs,
-- delete_proc a procedure to delete the entry; it takes "keytbl.keycol" of the row to be deleted
-- expect_return a bitmap that marks whether create_proc (1) and delete_proc (2) return a value or not
insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,create_keyval,delete_proc,expect_return)
-values (1,'inetOrgPerson','persons','id','insert into persons (id,name,surname) values ((select max(id)+1 from persons),'''','''')',
- 'select max(id) from persons','delete from persons where id=?',0);
+values (1,'inetOrgPerson','persons','id','INSERT INTO persons (id,name,surname) VALUES ((SELECT max(id)+1 FROM persons),'''','''')',
+ 'SELECT max(id) FROM persons','DELETE FROM persons WHERE id=?',0);
insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,create_keyval,delete_proc,expect_return)
-values (2,'document','documents','id','insert into documents (id,title,abstract) values ((select max(id)+1 from documents),'''','''')',
- 'select max(id) from documents','delete from documents where id=?',0);
+values (2,'document','documents','id','INSERT INTO documents (id,title,abstract) VALUES ((SELECT max(id)+1 FROM documents),'''','''')',
+ 'SELECT max(id) FROM documents','DELETE FROM documents WHERE id=?',0);
insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,create_keyval,delete_proc,expect_return)
-values (3,'organization','institutes','id','insert into institutes (id,name) values ((select max(id)+1 from institutes),'''')',
- 'select max(id) from institutes','delete from institutes where id=?',0);
+values (3,'organization','institutes','id','INSERT INTO institutes (id,name) VALUES ((SELECT max(id)+1 FROM institutes),'''')',
+ 'SELECT max(id) FROM institutes','DELETE FROM institutes WHERE id=?',0);
-- attributeType mappings: describe how an attributeType for a certain objectClass maps to the SQL data.
-- id a unique number identifying the attribute
insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
values (2,1,'telephoneNumber','phones.phone','persons,phones',
- 'phones.pers_id=persons.id','insert into phones (id,phone,pers_id) values ((select max(id)+1 from phones),?,?)',
- 'delete from phones where phone=? and pers_id=?',3,0);
+ 'phones.pers_id=persons.id','INSERT INTO phones (id,phone,pers_id) VALUES ((SELECT max(id)+1 FROM phones),?,?)',
+ 'DELETE FROM phones WHERE phone=? AND pers_id=?',3,0);
insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
-values (4,1,'givenName','persons.name','persons',NULL,'update persons set name=? where id=?',NULL,3,0);
+values (4,1,'givenName','persons.name','persons',NULL,'UPDATE persons SET name=? WHERE id=?',NULL,3,0);
insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
-values (3,1,'sn','persons.surname','persons',NULL,'update persons set surname=? where id=?',NULL,3,0);
+values (3,1,'sn','persons.surname','persons',NULL,'UPDATE persons SET surname=? WHERE id=?',NULL,3,0);
insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
-values (5,1,'userPassword','persons.password','persons','persons.password IS NOT NULL','update persons set password=? where id=?',
- NULL,3,0);
+values (5,1,'userPassword','persons.password','persons','persons.password IS NOT NULL','UPDATE persons SET password=? WHERE id=?',
+ 'UPDATE persons SET password=NULL WHERE password=? AND id=?',3,0);
insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
values (6,1,'seeAlso','seeAlso.dn','ldap_entries AS seeAlso,documents,authors_docs,persons',
NULL,NULL,3,0);
insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
-values (7,2,'description','documents.abstract','documents',NULL,'update documents set abstract=? where id=?',NULL,3,0);
+values (7,2,'description','documents.abstract','documents',NULL,'UPDATE documents SET abstract=? WHERE id=?',NULL,3,0);
insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
-values (8,2,'documentTitle','documents.title','documents',NULL,'update documents set title=? where id=?',NULL,3,0);
+values (8,2,'documentTitle','documents.title','documents',NULL,'UPDATE documents SET title=? WHERE id=?',NULL,3,0);
insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
values (9,2,'documentAuthor','documentAuthor.dn','ldap_entries AS documentAuthor,documents,authors_docs,persons',
'documentAuthor.keyval=persons.id AND documentAuthor.oc_map_id=1 AND authors_docs.doc_id=documents.id AND authors_docs.pers_id=persons.id',
- 'insert into authors_docs (pers_id,doc_id) values ((select keyval from ldap_entries where ucase(cast(? as varchar(255)))=ucase(dn)),?)',
- 'delete from authors_docs where pers_id = (select keyval from ldap_entries where ucase(cast(? as varchar(255))=ucase(dn)) AND doc_id=?',3,0);
+ 'INSERT INTO authors_docs (pers_id,doc_id) VALUES ((SELECT keyval FROM ldap_entries WHERE ucase(cast(? AS VARCHAR(255)))=ucase(dn)),?)',
+ 'DELETE FROM authors_docs WHERE pers_id=(SELECT keyval FROM ldap_entries WHERE ucase(cast(? AS VARCHAR(255))=ucase(dn)) AND doc_id=?',3,0);
insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
-values (10,2,'documentIdentifier','''document ''||rtrim(cast(documents.id as char(16)))','documents',NULL,NULL,NULL,3,0);
+values (10,2,'documentIdentifier','''document ''||rtrim(cast(documents.id AS CHAR(16)))','documents',NULL,NULL,NULL,3,0);
insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
-values (11,3,'o','institutes.name','institutes',NULL,'update institutes set name=? where id=?',NULL,3,0);
+values (11,3,'o','institutes.name','institutes',NULL,'UPDATE institutes SET name=? WHERE id=?',NULL,3,0);
insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return)
values (12,3,'dc','lcase(institutes.name)','institutes,ldap_entries AS dcObject,ldap_entry_objclasses as auxObjectClass',
-- url the URI of the referral
insert into ldap_referrals (entry_id,url) values (4,'ldap://localhost/');
--- user-defined functions
-- create_proc a procedure to create the entry
-- delete_proc a procedure to delete the entry; it takes "keytbl.keycol" of the row to be deleted
-- expect_return a bitmap that marks whether create_proc (1) and delete_proc (2) return a value or not
-insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return) values (1,'inetOrgPerson','persons','id','select create_person()','select delete_person(?)',0);
+insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return) values (1,'inetOrgPerson','persons','id','SELECT create_person()','DELETE FROM persons WHERE id=?',0);
-insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return) values (2,'document','documents','id','select create_doc()','select delete_doc(?)',0);
+insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return) values (2,'document','documents','id','SELECT create_doc()','DELETE FROM documents WHERE id=?',0);
-insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return) values (3,'organization','institutes','id','select create_o()','select delete_o(?)',0);
+insert into ldap_oc_mappings (id,name,keytbl,keycol,create_proc,delete_proc,expect_return) values (3,'organization','institutes','id','SELECT create_o()','DELETE FROM institutes WHERE id=?',0);
-- attributeType mappings: describe how an attributeType for a certain objectClass maps to the SQL data.
-- id a unique number identifying the attribute
-- delete_proc a procedure to delete the attribute; it takes the value of the attribute that is added, and the "keytbl.keycol" of the entry it is associated to
-- param_order a mask that marks if the "keytbl.keycol" value comes before or after the value in add_proc (1) and delete_proc (2)
-- expect_return a mask that marks whether add_proc (1) and delete_proc(2) are expected to return a value or not
-insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (1,1,'cn','text(persons.name||'' ''||persons.surname)','persons',NULL,'select update_person_cn(?,?)',NULL,3,0);
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (1,1,'cn','text(persons.name||'' ''||persons.surname)','persons',NULL,'SELECT update_person_cn(?,?)',NULL,3,0);
-insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (2,1,'telephoneNumber','phones.phone','persons,phones','phones.pers_id=persons.id','select add_phone(?,?)','select delete_phone(?,?)',3,0);
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (2,1,'telephoneNumber','phones.phone','persons,phones','phones.pers_id=persons.id','SELECT add_phone(?,?)','DELETE FROM phones WHERE phone=? AND pers_id=?',3,0);
-insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (3,1,'givenName','persons.name','persons',NULL,'update persons set name=? where id=?',NULL,3,0);
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (3,1,'givenName','persons.name','persons',NULL,'UPDATE persons SET name=? WHERE id=?',NULL,3,0);
-insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (4,1,'sn','persons.surname','persons',NULL,'update persons set surname=? where id=?',NULL,3,0);
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (4,1,'sn','persons.surname','persons',NULL,'UPDATE persons SET surname=? WHERE id=?',NULL,3,0);
-insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (5,1,'userPassword','persons.password','persons','persons.password IS NOT NULL','update persons set password=? where id=?',NULL,3,0);
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (5,1,'userPassword','persons.password','persons','persons.password IS NOT NULL','UPDATE persons SET password=? WHERE id=?','UPDATE persons SET password=NULL WHERE password=? AND id=?',3,0);
insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (6,1,'seeAlso','seeAlso.dn','ldap_entries AS seeAlso,documents,authors_docs,persons','seeAlso.keyval=documents.id AND seeAlso.oc_map_id=2 AND authors_docs.doc_id=documents.id AND authors_docs.pers_id=persons.id',NULL,NULL,3,0);
-insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (7,2,'description','documents.abstract','documents',NULL,'update documents set abstract=? where id=?',NULL,3,0);
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (7,2,'description','documents.abstract','documents',NULL,'UPDATE documents SET abstract=? WHERE id=?',NULL,3,0);
-insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (8,2,'documentTitle','documents.title','documents',NULL,'update documents set title=? where id=?',NULL,3,0);
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (8,2,'documentTitle','documents.title','documents',NULL,'UPDATE documents SET title=? WHERE id=?',NULL,3,0);
-insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (9,2,'documentAuthor','documentAuthor.dn','ldap_entries AS documentAuthor,documents,authors_docs,persons','documentAuthor.keyval=persons.id AND documentAuthor.oc_map_id=1 AND authors_docs.doc_id=documents.id AND authors_docs.pers_id=persons.id','select add_doc_author(?,?)','select delete_doc_author(?,?)',3,0);
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (9,2,'documentAuthor','documentAuthor.dn','ldap_entries AS documentAuthor,documents,authors_docs,persons','documentAuthor.keyval=persons.id AND documentAuthor.oc_map_id=1 AND authors_docs.doc_id=documents.id AND authors_docs.pers_id=persons.id','INSERT INTO authors_docs (pers_id,doc_id) VALUES ((SELECT ldap_entries.keyval FROM ldap_entries WHERE upper(?)=upper(ldap_entries.dn)),?)','DELETE FROM authors_docs WHERE authors_docs.pers_id=(SELECT ldap_entries.keyval FROM ldap_entries WHERE upper(?)=upper(ldap_entries.dn)) AND authors_docs.doc_id=?',3,0);
insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (10,2,'documentIdentifier','''document ''||text(documents.id)','documents',NULL,NULL,NULL,3,0);
-insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (11,3,'o','institutes.name','institutes',NULL,'update institutes set name=? where id=?',NULL,3,0);
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (11,3,'o','institutes.name','institutes',NULL,'UPDATE institutes SET name=? WHERE id=?',NULL,3,0);
-insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (12,3,'dc','lower(institutes.name)','institutes,ldap_entries AS dcObject,ldap_entry_objclasses as auxObjectClass','institutes.id=dcObject.keyval AND dcObject.oc_map_id=3 AND dcObject.id=auxObjectClass.entry_id AND auxObjectClass.oc_name=''dcObject''',NULL,NULL,3,0);
+insert into ldap_attr_mappings (id,oc_map_id,name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,expect_return) values (12,3,'dc','lower(institutes.name)','institutes,ldap_entries AS dcObject,ldap_entry_objclasses AS auxObjectClass','institutes.id=dcObject.keyval AND dcObject.oc_map_id=3 AND dcObject.id=auxObjectClass.entry_id AND auxObjectClass.oc_name=''dcObject''',NULL,NULL,3,0);
-- entries mapping: each entry must appear in this table, with a unique DN rooted at the database naming context
select $2 as return
' language 'sql';
-create function delete_person (int) returns int
-as '
- delete from phones where pers_id = $1;
- delete from authors_docs where pers_id = $1;
- delete from persons where id = $1;
- select $1 as return
-' language 'sql';
-
create function add_phone (varchar, int) returns int
as '
select setval (''phones_id_seq'', (select case when max(id) is null then 1 else max(id) end from phones));
select max(id) from phones
' language 'sql';
-create function delete_phone (varchar, int) returns int
-as '
- delete from phones where phone = $1 and pers_id = $2;
- select $2 as result
-' language 'sql';
-
create function create_doc () returns int
as '
select setval (''documents_id_seq'', (select case when max(id) is null then 1 else max(id) end from documents));
select max(id) from documents
' language 'sql';
-create function delete_doc (int) returns int
-as '
- delete from documents where id = $1;
- select $1 as return
-' language 'sql';
-
create function create_o () returns int
as '
select setval (''institutes_id_seq'', (select case when max(id) is null then 1 else max(id) end from institutes));
select max(id) from institutes
' language 'sql';
-create function delete_o (int) returns int
-as '
- delete from institutes where id = $1;
- select $1 as return
-' language 'sql';
-
-create function add_doc_author (varchar, int) returns int
-as '
- insert into authors_docs (pers_id,doc_id) values ((
- select ldap_entries.keyval
- from ldap_entries
- where upper($1) = upper(ldap_entries.dn)
- ),$2);
- select $2 as return
-' language 'sql';
-
-create function delete_doc_author (varchar, int) returns int
-as '
- delete from authors_docs where authors_docs.pers_id = (
- select ldap_entries.keyval
- from ldap_entries
- where upper($1) = upper(ldap_entries.dn)
- ) and authors_docs.doc_id = $2;
- select $2 as return
-' language 'sql';
-
{
struct berbuf bb = BB_NULL;
+#ifdef BACKSQL_ALIASING_QUOTE
+ backsql_strfcat( &bb, "lblcbclblbcbl",
+ (ber_len_t)STRLENOF( "SELECT " ), "SELECT ",
+ &at_map->bam_sel_expr,
+ (ber_len_t)STRLENOF( " " BACKSQL_ALIASING ), " " BACKSQL_ALIASING,
+ BACKSQL_ALIASING_QUOTE,
+ &at_map->bam_ad->ad_cname,
+ BACKSQL_ALIASING_QUOTE,
+ (ber_len_t)STRLENOF( " FROM " ), " FROM ",
+ &at_map->bam_from_tbls,
+ (ber_len_t)STRLENOF( " WHERE " ), " WHERE ",
+ &oc_map->bom_keytbl,
+ '.',
+ &oc_map->bom_keycol,
+ (ber_len_t)STRLENOF( "=?" ), "=?" );
+#else /* ! BACKSQL_ALIASING_QUOTE */
backsql_strfcat( &bb, "lblblblbcbl",
(ber_len_t)STRLENOF( "SELECT " ), "SELECT ",
&at_map->bam_sel_expr,
- (ber_len_t)STRLENOF( " AS " ), " AS ",
+ (ber_len_t)STRLENOF( " " BACKSQL_ALIASING ), " " BACKSQL_ALIASING,
&at_map->bam_ad->ad_cname,
(ber_len_t)STRLENOF( " FROM " ), " FROM ",
&at_map->bam_from_tbls,
'.',
&oc_map->bom_keycol,
(ber_len_t)STRLENOF( "=?" ), "=?" );
+#endif /* ! BACKSQL_ALIASING_QUOTE */
if ( !BER_BVISNULL( &at_map->bam_join_where ) ) {
backsql_strfcat( &bb, "lb",
&bsi->bsi_oc->bom_oc->soc_cname,
'\'' );
}
+#ifdef BACKSQL_ALIASING_QUOTE
+ backsql_strfcat( &bsi->bsi_sel, "lclcl",
+ (ber_len_t)STRLENOF( " " BACKSQL_ALIASING ),
+ " " BACKSQL_ALIASING,
+ BACKSQL_ALIASING_QUOTE,
+ (ber_len_t)STRLENOF( "objectClass" ),
+ "objectClass",
+ BACKSQL_ALIASING_QUOTE,
+ (ber_len_t)STRLENOF( ",ldap_entries.dn " BACKSQL_ALIASING "dn" ),
+ ",ldap_entries.dn " BACKSQL_ALIASING "dn" );
+#else /* ! BACKSQL_ALIASING_QUOTE */
backsql_strfcat( &bsi->bsi_sel, "l",
- (ber_len_t)STRLENOF( " AS objectClass,ldap_entries.dn AS dn" ),
- " AS objectClass,ldap_entries.dn AS dn" );
+ (ber_len_t)STRLENOF( " " BACKSQL_ALIASING "objectClass,ldap_entries.dn " BACKSQL_ALIASING "dn" ),
+ " " BACKSQL_ALIASING "objectClass,ldap_entries.dn " BACKSQL_ALIASING "dn" );
+#endif /* ! BACKSQL_ALIASING_QUOTE */
backsql_strfcat( &bsi->bsi_from, "lb",
(ber_len_t)STRLENOF( " FROM ldap_entries," ),
#define MAX_ATTR_LEN 16384
-typedef struct backsql_conn {
- int ldap_cid;
+typedef struct backsql_db_conn {
+ unsigned long ldap_cid;
SQLHDBC dbh;
} backsql_db_conn;
s = q;
BACKSQL_NEXT_WORD;
- if ( !strcasecmp( s, "as" ) ) {
+ if ( strcasecmp( s, "AS" ) == 0 ) {
s = q;
BACKSQL_NEXT_WORD;
}
-#if 0
- backsql_strcat( &res, " AS ", s, NULL );
- /* oracle doesn't understand AS :( and other RDBMSes don't need it */
-#endif
-
- /* table alias */
- backsql_strfcat( &res, "cs", ' ', s );
+ /* oracle doesn't understand "AS" :( and other RDBMSes don't need it */
+#ifdef BACKSQL_ALIASING_QUOTE
+ backsql_strfcat( &res, "scsc", " " BACKSQL_ALIASING,
+ BACKSQL_ALIASING_QUOTE, s, BACKSQL_ALIASING_QUOTE );
+#else /* ! BACKSQL_ALIASING */
+ backsql_strcat( &res, " " BACKSQL_ALIASING, s, NULL );
+#endif /* ! BACKSQL_ALIASING */
return res.bb_val.bv_val;
}
# refldap://localhost/dc=example,dc=com??sub
+# Testing invalid filter...
# Testing exact search...
dn: cn=Mitya Kovalev,dc=example,dc=com
objectClass: inetOrgPerson
# refldap://localhost/dc=example,dc=com??sub
-# Testing NOT search on sn...
# Testing attribute inheritance in filter...
dn: dc=example,dc=com
objectClass: organization
-dn: documentTitle=book2,dc=example,dc=com
-objectClass: document
-description: abstract2
-documentTitle: book2
-documentAuthor: cn=Mitya Kovalev,dc=example,dc=com
-documentAuthor: cn=Lev Tolstoij,dc=example,dc=com
-documentIdentifier: document 2
-
dn: documentTitle=War and Peace,dc=example,dc=com
objectClass: document
description: Historical novel
documentTitle: War and Peace
-documentAuthor: cn=Lev Tolstoij,dc=example,dc=com
+documentAuthor: cn=Lev Tolstoij,dc=subnet,dc=example,dc=com
documentIdentifier: document 3
+dn: documentTitle=Renamed Book,dc=example,dc=com
+objectClass: document
+description: abstract2
+documentTitle: Renamed Book
+documentAuthor: cn=Mitya Kovalev,dc=example,dc=com
+documentAuthor: cn=Lev Tolstoij,dc=subnet,dc=example,dc=com
+documentIdentifier: document 2
+
dn: dc=example,dc=com
objectClass: organization
objectClass: dcObject
o: SubNet
dc: subnet
-dn: o=Another Org,dc=example,dc=com
+dn: o=Renamed Org,dc=example,dc=com
objectClass: organization
-o: Another Org
+o: Renamed Org
dn: cn=Mitya Kovalev,dc=example,dc=com
objectClass: inetOrgPerson
cn: Mitya Kovalev
sn: Kovalev
-seeAlso: documentTitle=book2,dc=example,dc=com
+seeAlso: documentTitle=Renamed Book,dc=example,dc=com
givenName: Mitya
telephoneNumber: 332-2334
telephoneNumber: 222-3234
telephoneNumber: +1 800 123 4567
-dn: cn=Lev Tolstoij,dc=example,dc=com
-objectClass: inetOrgPerson
-cn: Lev Tolstoij
-sn: Tolstoij
-seeAlso: documentTitle=book2,dc=example,dc=com
-seeAlso: documentTitle=War and Peace,dc=example,dc=com
-givenName: Lev
-telephoneNumber: +39 02 XXXX ZZZZ
-telephoneNumber: +39 333 ZZZ 1234
-
dn: cn=Some One,dc=example,dc=com
objectClass: inetOrgPerson
objectClass: simpleSecurityObject
sn: User
givenName: SubNet
+dn: cn=Lev Tolstoij,dc=subnet,dc=example,dc=com
+objectClass: inetOrgPerson
+cn: Lev Tolstoij
+sn: Tolstoij
+seeAlso: documentTitle=Renamed Book,dc=example,dc=com
+seeAlso: documentTitle=War and Peace,dc=example,dc=com
+givenName: Lev
+telephoneNumber: +39 02 XXXX ZZZZ
+telephoneNumber: +39 333 ZZZ 1234
+
exit $RC
fi
+echo "Testing invalid filter..."
+echo "# Testing invalid filter..." >> $SEARCHOUT
+$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
+ "(foo=)" >> $SEARCHOUT 2>&1
+
+RC=$?
+if test $RC != 0 ; then
+ echo "ldapsearch failed ($RC)!"
+ test $KILLSERVERS != no && kill -HUP $KILLPIDS
+ exit $RC
+fi
+
echo "Testing exact search..."
echo "# Testing exact search..." >> $SEARCHOUT
$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
#### Needs work...
echo "Testing NOT presence search... (disabled)"
-###echo "# Testing NOT search on sn..." >> $SEARCHOUT
+###echo "# Testing NOT presence search..." >> $SEARCHOUT
###$LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" \
### '(!(sn=*))' >> $SEARCHOUT 2>&1
###
givenName: Lev
telephoneNumber: +39 02 XXXX YYYY
telephoneNumber: +39 02 XXXX ZZZZ
+userPassword: tanja
# Adding a person with an "auxiliary" objectClass...
dn: cn=Some One,${BASEDN}
delete: objectClass
objectClass: simpleSecurityObject
-
+
+# Deleting userPasswords
+dn: cn=Lev Tolstoij,${BASEDN}
+changetype: modify
delete: userPassword
-
# Renaming an organization
dn: o=An Org,${BASEDN}
changetype: modrdn
-newrdn: o=Another Org
+newrdn: o=Renamed Org
+deleteoldrdn: 1
+
+# Renaming a person
+dn: cn=Lev Tolstoij,${BASEDN}
+changetype: modrdn
+newrdn: cn=Lev Tolstoij
+deleteoldrdn: 0
+newsuperior: dc=subnet,${BASEDN}
+
+# Renaming a book
+dn: documentTitle=book2,${BASEDN}
+changetype: modrdn
+newrdn: documentTitle=Renamed Book
deleteoldrdn: 1
EOMODS