goto add_only;
}
-
+
del_all:
rs->sr_err = backsql_modify_delete_all_values( op, rs, dbh, e_id, at );
if ( rs->sr_err != LDAP_SUCCESS ) {
*/
#undef BACKSQL_TRACE
+/*
+ * define if using MS SQL and workaround needed (see sql-wrap.c)
+ */
+#undef BACKSQL_MSSQL_WORKAROUND
+
/*
* define to enable values counting for attributes
*/
}
rs->sr_err = backsql_modify_internal( op, rs, dbh, oc,
- &bsi.bsi_base_id,
- op->oq_modify.rs_modlist );
+ &bsi.bsi_base_id, op->oq_modify.rs_modlist );
if ( rs->sr_err != LDAP_SUCCESS ) {
e = &m;
goto do_transact;
char textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' };
entry_clean( &r );
+ (void)backsql_free_entryID( op, &e_id, 0 );
bsi.bsi_e = &r;
- rs->sr_err = backsql_id2entry( &bsi, &e_id );
- if ( rs->sr_err != LDAP_SUCCESS ) {
+ rs->sr_err = backsql_init_search( &bsi, &new_ndn,
+ LDAP_SCOPE_BASE,
+ SLAP_NO_LIMIT, SLAP_NO_LIMIT,
+ (time_t)(-1), NULL, dbh, op, rs,
+ slap_anlist_all_attributes,
+ ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) );
+ switch ( rs->sr_err ) {
+ case LDAP_SUCCESS:
+ break;
+
+ case LDAP_REFERRAL:
+ if ( !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
+ dn_match( &new_ndn, &bsi.bsi_e->e_nname )
+ && manageDSAit )
+ {
+ rs->sr_err = LDAP_SUCCESS;
+ rs->sr_text = NULL;
+ rs->sr_matched = NULL;
+ if ( rs->sr_ref ) {
+ ber_bvarray_free( rs->sr_ref );
+ rs->sr_ref = NULL;
+ }
+ break;
+ }
e = &r;
+ /* fallthru */
+
+ default:
+ Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
+ "could not retrieve modrdnDN ID - no such entry\n",
+ 0, 0, 0 );
+ if ( !BER_BVISNULL( &r.e_nname ) ) {
+ /* FIXME: should always be true! */
+ e = &r;
+
+ } else {
+ e = NULL;
+ }
goto done;
}
+ e_id = bsi.bsi_base_id;
+
rs->sr_err = entry_schema_check( op->o_bd, &r,
NULL,
&rs->sr_text, textbuf, sizeof( textbuf ) );
-- referrals mapping: entries that should be treated as referrals are stored here
-- entry_id the "ldap_entries.id" of the entry that should be treated as a referral
-- url the URI of the referral
-insert into ldap_referrals (entry_id,url) values (4,'ldap://localhost/');
+insert into ldap_referrals (entry_id,url) values (4,'ldap://localhost:9010/');
values (4,'referral');
insert into ldap_referrals (entry_id,url)
-values (4,'http://localhost/');
+values (4,'ldap://localhost:9010/');
-- support procedures
-- entry_id the "ldap_entries.id" of the entry that should be treated as a referral
-- url the URI of the referral
insert into ldap_referrals (entry_id,url)
-values (4,'ldap://localhost/');
+values (4,'ldap://localhost:9010/');
-- entry_id the "ldap_entries.id" of the entry that should be treated as a referral
-- url the URI of the referral
insert into ldap_referrals (entry_id,url)
-values (4,'http://localhost/');
+values (4,'ldap://localhost:9010/');
-- procedures
-- referrals mapping: entries that should be treated as referrals are stored here
-- entry_id the "ldap_entries.id" of the entry that should be treated as a referral
-- url the URI of the referral
-insert into ldap_referrals (entry_id,url) values (4,'ldap://localhost/');
+insert into ldap_referrals (entry_id,url) values (4,'ldap://localhost:9010/');
-- procedures
-- these procedures are specific for this RDBMS and are used in mapping objectClass and attributeType creation/modify/deletion
values (4,'referral');
insert into ldap_referrals (entry_id,url)
-values (4,'http://localhost');
+values (4,'ldap://localhost:9010');
backsql_merge_from_tbls( bsi, &ldap_entry_objclasses );
backsql_strfcat( &bsi->bsi_flt_where, "lbl",
- (ber_len_t)STRLENOF( "2=2 OR (ldap_entries.id=ldap_entry_objclasses.entry_id AND ldap_entry_objclasses.oc_name='" /* ') */ ),
- "2=2 OR (ldap_entries.id=ldap_entry_objclasses.entry_id AND ldap_entry_objclasses.oc_name='" /* ') */,
+ (ber_len_t)STRLENOF( "(2=2 OR (ldap_entries.id=ldap_entry_objclasses.entry_id AND ldap_entry_objclasses.oc_name='" /* ')) */ ),
+ "(2=2 OR (ldap_entries.id=ldap_entry_objclasses.entry_id AND ldap_entry_objclasses.oc_name='" /* ')) */,
&bsi->bsi_oc->bom_oc->soc_cname,
- (ber_len_t)STRLENOF( /* (' */ "')" ),
- /* (' */ "')" );
+ (ber_len_t)STRLENOF( /* ((' */ "'))" ),
+ /* ((' */ "'))" );
bsi->bsi_status = LDAP_SUCCESS;
rc = 1;
goto done;
int sres;
Entry user_entry = { 0 },
base_entry = { 0 };
- int manageDSAit;
+ int manageDSAit = get_manageDSAit( op );
time_t stoptime = 0;
backsql_srch_info bsi = { 0 };
backsql_entryID *eid = NULL;
- struct berval nbase = BER_BVNULL,
- realndn = BER_BVNULL;
-
- manageDSAit = get_manageDSAit( op );
+ struct berval nbase = BER_BVNULL;
Debug( LDAP_DEBUG_TRACE, "==>backsql_search(): "
"base=\"%s\", filter=\"%s\", scope=%d,",
/* compute it anyway; root does not use it */
stoptime = op->o_time + op->ors_tlimit;
- realndn = op->o_req_ndn;
- if ( backsql_api_dn2odbc( op, rs, &realndn ) ) {
- Debug( LDAP_DEBUG_TRACE, " backsql_search(\"%s\"): "
- "backsql_api_dn2odbc(\"%s\") failed\n",
- op->o_req_ndn.bv_val, realndn.bv_val, 0 );
- rs->sr_err = LDAP_OTHER;
- rs->sr_text = "SQL-backend error";
- send_ldap_result( op, rs );
- goto done;
- }
-
/* init search */
bsi.bsi_e = &base_entry;
- rs->sr_err = backsql_init_search( &bsi, &realndn,
+ rs->sr_err = backsql_init_search( &bsi, &op->o_req_ndn,
op->ors_scope,
op->ors_slimit, op->ors_tlimit,
stoptime, op->ors_filter,
dbh, op, rs, op->ors_attrs,
( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) );
- if ( rs->sr_err != LDAP_SUCCESS ) {
+ switch ( rs->sr_err ) {
+ case LDAP_SUCCESS:
+ break;
+
+ case LDAP_REFERRAL:
+ if ( !BER_BVISNULL( &bsi.bsi_e->e_nname ) &&
+ dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname )
+ && manageDSAit )
+ {
+ rs->sr_err = LDAP_SUCCESS;
+ rs->sr_text = NULL;
+ rs->sr_matched = NULL;
+ if ( rs->sr_ref ) {
+ ber_bvarray_free( rs->sr_ref );
+ rs->sr_ref = NULL;
+ }
+ break;
+ }
+ /* fall thru */
+
+ default:
#ifdef SLAP_ACL_HONOR_DISCLOSE
if ( !BER_BVISNULL( &base_entry.e_nname )
&& ! access_allowed( op, &base_entry,
rs->sr_err = LDAP_NO_SUCH_OBJECT;
if ( rs->sr_ref ) {
ber_bvarray_free( rs->sr_ref );
+ rs->sr_ref = NULL;
}
rs->sr_matched = NULL;
rs->sr_text = NULL;
}
#endif /* SLAP_ACL_HONOR_DISCLOSE */
+
send_ldap_result( op, rs );
goto done;
#ifdef SLAP_ACL_HONOR_DISCLOSE
/* NOTE: __NEW__ "search" access is required
* on searchBase object */
- else {
+ {
slap_mask_t mask;
if ( get_assert( op ) &&
#endif /* BACKSQL_SYNCPROV */
done:;
- if ( !BER_BVISNULL( &realndn ) && realndn.bv_val != op->o_req_ndn.bv_val ) {
- ch_free( realndn.bv_val );
- }
-
(void)backsql_free_entryID( op, &bsi.bsi_base_id, 0 );
if ( bsi.bsi_attrs != NULL ) {
backsql_Prepare( SQLHDBC dbh, SQLHSTMT *sth, char *query, int timeout )
{
RETCODE rc;
- char drv_name[ 30 ];
- SWORD len;
rc = SQLAllocStmt( dbh, sth );
if ( rc != SQL_SUCCESS ) {
Debug( LDAP_DEBUG_TRACE, "==>backsql_Prepare()\n", 0, 0, 0 );
#endif /* BACKSQL_TRACE */
- SQLGetInfo( dbh, SQL_DRIVER_NAME, drv_name, sizeof( drv_name ), &len );
+#ifdef BACKSQL_MSSQL_WORKAROUND
+ {
+ char drv_name[ 30 ];
+ SWORD len;
+
+ SQLGetInfo( dbh, SQL_DRIVER_NAME, drv_name, sizeof( drv_name ), &len );
#ifdef BACKSQL_TRACE
- Debug( LDAP_DEBUG_TRACE, "backsql_Prepare(): driver name=\"%s\"\n",
- drv_name, 0, 0 );
+ Debug( LDAP_DEBUG_TRACE, "backsql_Prepare(): driver name=\"%s\"\n",
+ drv_name, 0, 0 );
#endif /* BACKSQL_TRACE */
- ldap_pvt_str2upper( drv_name );
- if ( !strncmp( drv_name, "SQLSRV32.DLL", sizeof( drv_name ) ) ) {
- /*
- * stupid default result set in MS SQL Server
- * does not support multiple active statements
- * on the same connection -- so we are trying
- * to make it not to use default result set...
- */
- Debug( LDAP_DEBUG_TRACE, "_SQLprepare(): "
- "enabling MS SQL Server default result "
- "set workaround\n", 0, 0, 0 );
- rc = SQLSetStmtOption( *sth, SQL_CONCURRENCY,
- SQL_CONCUR_ROWVER );
- if ( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO ) {
- Debug( LDAP_DEBUG_TRACE, "backsql_Prepare(): "
- "SQLSetStmtOption(SQL_CONCURRENCY,"
- "SQL_CONCUR_ROWVER) failed:\n",
- 0, 0, 0 );
- backsql_PrintErrors( SQL_NULL_HENV, dbh, *sth, rc );
- SQLFreeStmt( *sth, SQL_DROP );
- return rc;
+ ldap_pvt_str2upper( drv_name );
+ if ( !strncmp( drv_name, "SQLSRV32.DLL", STRLENOF( "SQLSRV32.DLL" ) ) ) {
+ /*
+ * stupid default result set in MS SQL Server
+ * does not support multiple active statements
+ * on the same connection -- so we are trying
+ * to make it not to use default result set...
+ */
+ Debug( LDAP_DEBUG_TRACE, "_SQLprepare(): "
+ "enabling MS SQL Server default result "
+ "set workaround\n", 0, 0, 0 );
+ rc = SQLSetStmtOption( *sth, SQL_CONCURRENCY,
+ SQL_CONCUR_ROWVER );
+ if ( rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO ) {
+ Debug( LDAP_DEBUG_TRACE, "backsql_Prepare(): "
+ "SQLSetStmtOption(SQL_CONCURRENCY,"
+ "SQL_CONCUR_ROWVER) failed:\n",
+ 0, 0, 0 );
+ backsql_PrintErrors( SQL_NULL_HENV, dbh, *sth, rc );
+ SQLFreeStmt( *sth, SQL_DROP );
+ return rc;
+ }
}
}
+#endif /* BACKSQL_MSSQL_WORKAROUND */
if ( timeout > 0 ) {
Debug( LDAP_DEBUG_TRACE, "_SQLprepare(): "