int backsql_modrdn( Operation *op, SlapReply *rs ) { backsql_info *bi = (backsql_info*)op->o_bd->be_private; SQLHDBC dbh = SQL_NULL_HDBC; SQLHSTMT sth = SQL_NULL_HSTMT; RETCODE rc; backsql_entryID e_id = BACKSQL_ENTRYID_INIT, n_id = BACKSQL_ENTRYID_INIT; backsql_srch_info bsi = { 0 }; backsql_oc_map_rec *oc = NULL; struct berval pdn = BER_BVNULL, pndn = BER_BVNULL, *new_pdn = NULL, *new_npdn = NULL, new_dn = BER_BVNULL, new_ndn = BER_BVNULL, realnew_dn = BER_BVNULL; Entry r = { 0 }, p = { 0 }, n = { 0 }, *e = NULL; int manageDSAit = get_manageDSAit( op ); struct berval *newSuperior = op->oq_modrdn.rs_newSup; Debug( LDAP_DEBUG_TRACE, "==>backsql_modrdn() renaming entry \"%s\", " "newrdn=\"%s\", newSuperior=\"%s\"\n", op->o_req_dn.bv_val, op->oq_modrdn.rs_newrdn.bv_val, newSuperior ? newSuperior->bv_val : "(NULL)" ); rs->sr_err = backsql_get_db_conn( op, &dbh ); if ( rs->sr_err != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "could not get connection handle - exiting\n" ); rs->sr_text = ( rs->sr_err == LDAP_OTHER ) ? "SQL-backend error" : NULL; e = NULL; goto done; } bsi.bsi_e = &r; rs->sr_err = backsql_init_search( &bsi, &op->o_req_ndn, LDAP_SCOPE_BASE, (time_t)(-1), NULL, dbh, op, rs, slap_anlist_all_attributes, ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY | BACKSQL_ISF_GET_OC ) ); switch ( rs->sr_err ) { case LDAP_SUCCESS: break; case LDAP_REFERRAL: if ( manageDSAit && !BER_BVISNULL( &bsi.bsi_e->e_nname ) && dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname ) ) { 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" ); if ( !BER_BVISNULL( &r.e_nname ) ) { /* FIXME: should always be true! */ e = &r; } else { e = NULL; } goto done; } Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): entry id=" BACKSQL_IDFMT "\n", BACKSQL_IDARG(e_id.eid_id) ); if ( get_assert( op ) && ( test_filter( op, &r, get_assertion( op ) ) != LDAP_COMPARE_TRUE ) ) { rs->sr_err = LDAP_ASSERTION_FAILED; e = &r; goto done; } if ( backsql_has_children( op, dbh, &op->o_req_ndn ) == LDAP_COMPARE_TRUE ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "entry \"%s\" has children\n", op->o_req_dn.bv_val ); rs->sr_err = LDAP_NOT_ALLOWED_ON_NONLEAF; rs->sr_text = "subtree rename not supported"; e = &r; goto done; } /* * Check for entry access to target */ if ( !access_allowed( op, &r, slap_schema.si_ad_entry, NULL, ACL_WRITE, NULL ) ) { Debug( LDAP_DEBUG_TRACE, " no access to entry\n" ); rs->sr_err = LDAP_INSUFFICIENT_ACCESS; goto done; } dnParent( &op->o_req_dn, &pdn ); dnParent( &op->o_req_ndn, &pndn ); /* * namingContext "" is not supported */ if ( BER_BVISEMPTY( &pdn ) ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "parent is \"\" - aborting\n" ); rs->sr_err = LDAP_UNWILLING_TO_PERFORM; rs->sr_text = "not allowed within namingContext"; e = NULL; goto done; } /* * Check for children access to parent */ bsi.bsi_e = &p; e_id = bsi.bsi_base_id; memset( &bsi.bsi_base_id, 0, sizeof( bsi.bsi_base_id ) ); rs->sr_err = backsql_init_search( &bsi, &pndn, LDAP_SCOPE_BASE, (time_t)(-1), NULL, dbh, op, rs, slap_anlist_all_attributes, BACKSQL_ISF_GET_ENTRY ); Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): old parent entry id is " BACKSQL_IDFMT "\n", BACKSQL_IDARG(bsi.bsi_base_id.eid_id) ); if ( rs->sr_err != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): " "could not retrieve renameDN ID - no such entry\n" ); e = &p; goto done; } if ( !access_allowed( op, &p, slap_schema.si_ad_children, NULL, newSuperior ? ACL_WDEL : ACL_WRITE, NULL ) ) { Debug( LDAP_DEBUG_TRACE, " no access to parent\n" ); rs->sr_err = LDAP_INSUFFICIENT_ACCESS; goto done; } if ( newSuperior ) { (void)backsql_free_entryID( &bsi.bsi_base_id, 0, op->o_tmpmemctx ); /* * namingContext "" is not supported */ if ( BER_BVISEMPTY( newSuperior ) ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "newSuperior is \"\" - aborting\n" ); rs->sr_err = LDAP_UNWILLING_TO_PERFORM; rs->sr_text = "not allowed within namingContext"; e = NULL; goto done; } new_pdn = newSuperior; new_npdn = op->oq_modrdn.rs_nnewSup; /* * Check for children access to new parent */ bsi.bsi_e = &n; rs->sr_err = backsql_init_search( &bsi, new_npdn, LDAP_SCOPE_BASE, (time_t)(-1), NULL, dbh, op, rs, slap_anlist_all_attributes, ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) ); if ( rs->sr_err != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): " "could not retrieve renameDN ID - no such entry\n" ); e = &n; goto done; } n_id = bsi.bsi_base_id; Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): new parent entry id=" BACKSQL_IDFMT "\n", BACKSQL_IDARG(n_id.eid_id) ); if ( !access_allowed( op, &n, slap_schema.si_ad_children, NULL, ACL_WADD, NULL ) ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "no access to new parent \"%s\"\n", new_pdn->bv_val ); rs->sr_err = LDAP_INSUFFICIENT_ACCESS; e = &n; goto done; } } else { n_id = bsi.bsi_base_id; new_pdn = &pdn; new_npdn = &pndn; } memset( &bsi.bsi_base_id, 0, sizeof( bsi.bsi_base_id ) ); if ( newSuperior && dn_match( &pndn, new_npdn ) ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "newSuperior is equal to old parent - ignored\n" ); newSuperior = NULL; } if ( newSuperior && dn_match( &op->o_req_ndn, new_npdn ) ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "newSuperior is equal to entry being moved " "- aborting\n" ); rs->sr_err = LDAP_OTHER; rs->sr_text = "newSuperior is equal to old DN"; e = &r; goto done; } build_new_dn( &new_dn, new_pdn, &op->oq_modrdn.rs_newrdn, op->o_tmpmemctx ); build_new_dn( &new_ndn, new_npdn, &op->oq_modrdn.rs_nnewrdn, op->o_tmpmemctx ); Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): new entry dn is \"%s\"\n", new_dn.bv_val ); realnew_dn = new_dn; if ( backsql_api_dn2odbc( op, rs, &realnew_dn ) ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(\"%s\"): " "backsql_api_dn2odbc(\"%s\") failed\n", op->o_req_dn.bv_val, realnew_dn.bv_val ); SQLFreeStmt( sth, SQL_DROP ); rs->sr_text = "SQL-backend error"; rs->sr_err = LDAP_OTHER; e = NULL; goto done; } Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "executing renentry_stmt\n" ); rc = backsql_Prepare( dbh, &sth, bi->sql_renentry_stmt, 0 ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "error preparing renentry_stmt\n" ); backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); rs->sr_text = "SQL-backend error"; rs->sr_err = LDAP_OTHER; e = NULL; goto done; } rc = backsql_BindParamBerVal( sth, 1, SQL_PARAM_INPUT, &realnew_dn ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "error binding DN parameter for objectClass %s\n", oc->bom_oc->soc_cname.bv_val ); backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); rs->sr_text = "SQL-backend error"; rs->sr_err = LDAP_OTHER; e = NULL; goto done; } rc = backsql_BindParamID( sth, 2, SQL_PARAM_INPUT, &n_id.eid_id ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "error binding parent ID parameter for objectClass %s\n", oc->bom_oc->soc_cname.bv_val ); backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); rs->sr_text = "SQL-backend error"; rs->sr_err = LDAP_OTHER; e = NULL; goto done; } rc = backsql_BindParamID( sth, 3, SQL_PARAM_INPUT, &e_id.eid_keyval ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "error binding entry ID parameter for objectClass %s\n", oc->bom_oc->soc_cname.bv_val ); backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); rs->sr_text = "SQL-backend error"; rs->sr_err = LDAP_OTHER; e = NULL; goto done; } rc = backsql_BindParamID( sth, 4, SQL_PARAM_INPUT, &e_id.eid_id ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "error binding ID parameter for objectClass %s\n", oc->bom_oc->soc_cname.bv_val ); backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); rs->sr_text = "SQL-backend error"; rs->sr_err = LDAP_OTHER; e = NULL; goto done; } rc = SQLExecute( sth ); if ( rc != SQL_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(): " "could not rename ldap_entries record\n" ); backsql_PrintErrors( bi->sql_db_env, dbh, sth, rc ); SQLFreeStmt( sth, SQL_DROP ); rs->sr_err = LDAP_OTHER; rs->sr_text = "SQL-backend error"; e = NULL; goto done; } SQLFreeStmt( sth, SQL_DROP ); assert( op->orr_modlist != NULL ); slap_mods_opattrs( op, &op->orr_modlist, 1 ); assert( e_id.eid_oc != NULL ); oc = e_id.eid_oc; rs->sr_err = backsql_modify_internal( op, rs, dbh, oc, &e_id, op->orr_modlist ); slap_graduate_commit_csn( op ); if ( rs->sr_err != LDAP_SUCCESS ) { e = &r; goto done; } if ( BACKSQL_CHECK_SCHEMA( bi ) ) { char textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' }; backsql_entry_clean( op, &r ); (void)backsql_free_entryID( &e_id, 0, op->o_tmpmemctx ); bsi.bsi_e = &r; rs->sr_err = backsql_init_search( &bsi, &new_ndn, LDAP_SCOPE_BASE, (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 ( manageDSAit && !BER_BVISNULL( &bsi.bsi_e->e_nname ) && dn_match( &new_ndn, &bsi.bsi_e->e_nname ) ) { 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" ); 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, &r, NULL, 0, 0, NULL, &rs->sr_text, textbuf, sizeof( textbuf ) ); if ( rs->sr_err != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_modrdn(\"%s\"): " "entry failed schema check -- aborting\n", r.e_name.bv_val ); e = NULL; goto done; } } done:; if ( e != NULL ) { if ( !access_allowed( op, e, slap_schema.si_ad_entry, NULL, ACL_DISCLOSE, NULL ) ) { rs->sr_err = LDAP_NO_SUCH_OBJECT; rs->sr_text = NULL; rs->sr_matched = NULL; if ( rs->sr_ref ) { ber_bvarray_free( rs->sr_ref ); rs->sr_ref = NULL; } } } /* * Commit only if all operations succeed */ if ( sth != SQL_NULL_HSTMT ) { SQLUSMALLINT CompletionType = SQL_ROLLBACK; if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) { CompletionType = SQL_COMMIT; } SQLTransact( SQL_NULL_HENV, dbh, CompletionType ); } if ( op->o_noop && rs->sr_err == LDAP_SUCCESS ) { rs->sr_err = LDAP_X_NO_OPERATION; } send_ldap_result( op, rs ); slap_graduate_commit_csn( op ); if ( !BER_BVISNULL( &realnew_dn ) && realnew_dn.bv_val != new_dn.bv_val ) { ch_free( realnew_dn.bv_val ); } if ( !BER_BVISNULL( &new_dn ) ) { slap_sl_free( new_dn.bv_val, op->o_tmpmemctx ); } if ( !BER_BVISNULL( &new_ndn ) ) { slap_sl_free( new_ndn.bv_val, op->o_tmpmemctx ); } if ( !BER_BVISNULL( &e_id.eid_ndn ) ) { (void)backsql_free_entryID( &e_id, 0, op->o_tmpmemctx ); } if ( !BER_BVISNULL( &n_id.eid_ndn ) ) { (void)backsql_free_entryID( &n_id, 0, op->o_tmpmemctx ); } if ( !BER_BVISNULL( &r.e_nname ) ) { backsql_entry_clean( op, &r ); } if ( !BER_BVISNULL( &p.e_nname ) ) { backsql_entry_clean( op, &p ); } if ( !BER_BVISNULL( &n.e_nname ) ) { backsql_entry_clean( op, &n ); } if ( rs->sr_ref ) { ber_bvarray_free( rs->sr_ref ); rs->sr_ref = NULL; } Debug( LDAP_DEBUG_TRACE, "<==backsql_modrdn()\n" ); return rs->sr_err; }
int backsql_id2entry( backsql_srch_info *bsi, backsql_entryID *eid ) { Operation *op = bsi->bsi_op; backsql_info *bi = (backsql_info *)op->o_bd->be_private; int i; int rc; Debug( LDAP_DEBUG_TRACE, "==>backsql_id2entry()\n", 0, 0, 0 ); assert( bsi->bsi_e != NULL ); memset( bsi->bsi_e, 0, sizeof( Entry ) ); if ( bi->sql_baseObject && BACKSQL_IS_BASEOBJECT_ID( &eid->eid_id ) ) { Entry *e; e = entry_dup( bi->sql_baseObject ); if ( e == NULL ) { return LDAP_NO_MEMORY; } *bsi->bsi_e = *e; free( e ); goto done; } ber_dupbv_x( &bsi->bsi_e->e_name, &eid->eid_dn, op->o_tmpmemctx ); ber_dupbv_x( &bsi->bsi_e->e_nname, &eid->eid_ndn, op->o_tmpmemctx ); bsi->bsi_e->e_attrs = NULL; bsi->bsi_e->e_private = NULL; if ( eid->eid_oc == NULL ) { eid->eid_oc = backsql_id2oc( bsi->bsi_op->o_bd->be_private, eid->eid_oc_id ); } bsi->bsi_oc = eid->eid_oc; bsi->bsi_c_eid = eid; #ifndef BACKSQL_ARBITRARY_KEY /* FIXME: unused */ bsi->bsi_e->e_id = eid->eid_id; #endif /* ! BACKSQL_ARBITRARY_KEY */ rc = attr_merge_normalize_one( bsi->bsi_e, slap_schema.si_ad_objectClass, &bsi->bsi_oc->bom_oc->soc_cname, bsi->bsi_op->o_tmpmemctx ); if ( rc != LDAP_SUCCESS ) { backsql_entry_clean( op, bsi->bsi_e ); return rc; } if ( bsi->bsi_attrs == NULL || ( bsi->bsi_flags & BSQL_SF_ALL_USER ) ) { Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(): " "retrieving all attributes\n", 0, 0, 0 ); avl_apply( bsi->bsi_oc->bom_attrs, backsql_get_attr_vals, bsi, 0, AVL_INORDER ); } else { Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(): " "custom attribute list\n", 0, 0, 0 ); for ( i = 0; !BER_BVISNULL( &bsi->bsi_attrs[ i ].an_name ); i++ ) { backsql_at_map_rec **vat; AttributeName *an = &bsi->bsi_attrs[ i ]; int j; /* if one of the attributes listed here is * a subtype of another, it must be ignored, * because subtypes are already dealt with * by backsql_supad2at() */ for ( j = 0; !BER_BVISNULL( &bsi->bsi_attrs[ j ].an_name ); j++ ) { /* skip self */ if ( j == i ) { continue; } /* skip subtypes */ if ( is_at_subtype( an->an_desc->ad_type, bsi->bsi_attrs[ j ].an_desc->ad_type ) ) { goto next; } } rc = backsql_supad2at( bsi->bsi_oc, an->an_desc, &vat ); if ( rc != 0 || vat == NULL ) { Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(): " "attribute \"%s\" is not defined " "for objectlass \"%s\"\n", an->an_name.bv_val, BACKSQL_OC_NAME( bsi->bsi_oc ), 0 ); continue; } for ( j = 0; vat[j]; j++ ) { backsql_get_attr_vals( vat[j], bsi ); } ch_free( vat ); next:; } } if ( bsi->bsi_flags & BSQL_SF_RETURN_ENTRYUUID ) { Attribute *a_entryUUID, **ap; a_entryUUID = backsql_operational_entryUUID( bi, eid ); if ( a_entryUUID != NULL ) { for ( ap = &bsi->bsi_e->e_attrs; *ap; ap = &(*ap)->a_next ); *ap = a_entryUUID; } } if ( ( bsi->bsi_flags & BSQL_SF_ALL_OPER ) || an_find( bsi->bsi_attrs, slap_bv_all_operational_attrs ) || an_find( bsi->bsi_attrs, &slap_schema.si_ad_structuralObjectClass->ad_cname ) ) { ObjectClass *soc = NULL; if ( BACKSQL_CHECK_SCHEMA( bi ) ) { Attribute *a; const char *text = NULL; char textbuf[ 1024 ]; size_t textlen = sizeof( textbuf ); struct berval bv[ 2 ], *nvals; int rc = LDAP_SUCCESS; a = attr_find( bsi->bsi_e->e_attrs, slap_schema.si_ad_objectClass ); if ( a != NULL ) { nvals = a->a_nvals; } else { bv[ 0 ] = bsi->bsi_oc->bom_oc->soc_cname; BER_BVZERO( &bv[ 1 ] ); nvals = bv; } rc = structural_class( nvals, &soc, NULL, &text, textbuf, textlen, op->o_tmpmemctx ); if ( rc != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(%s): " "structural_class() failed %d (%s)\n", bsi->bsi_e->e_name.bv_val, rc, text ? text : "" ); backsql_entry_clean( op, bsi->bsi_e ); return rc; } if ( !bvmatch( &soc->soc_cname, &bsi->bsi_oc->bom_oc->soc_cname ) ) { if ( !is_object_subclass( bsi->bsi_oc->bom_oc, soc ) ) { Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(%s): " "computed structuralObjectClass %s " "does not match objectClass %s associated " "to entry\n", bsi->bsi_e->e_name.bv_val, soc->soc_cname.bv_val, bsi->bsi_oc->bom_oc->soc_cname.bv_val ); backsql_entry_clean( op, bsi->bsi_e ); return rc; } Debug( LDAP_DEBUG_TRACE, "backsql_id2entry(%s): " "computed structuralObjectClass %s " "is subclass of objectClass %s associated " "to entry\n", bsi->bsi_e->e_name.bv_val, soc->soc_cname.bv_val, bsi->bsi_oc->bom_oc->soc_cname.bv_val ); } } else { soc = bsi->bsi_oc->bom_oc; } rc = attr_merge_normalize_one( bsi->bsi_e, slap_schema.si_ad_structuralObjectClass, &soc->soc_cname, bsi->bsi_op->o_tmpmemctx ); if ( rc != LDAP_SUCCESS ) { backsql_entry_clean( op, bsi->bsi_e ); return rc; } } done:; Debug( LDAP_DEBUG_TRACE, "<==backsql_id2entry()\n", 0, 0, 0 ); return LDAP_SUCCESS; }
int backsql_modify( Operation *op, SlapReply *rs ) { backsql_info *bi = (backsql_info*)op->o_bd->be_private; SQLHDBC dbh = SQL_NULL_HDBC; backsql_oc_map_rec *oc = NULL; backsql_srch_info bsi = { 0 }; Entry m = { 0 }, *e = NULL; int manageDSAit = get_manageDSAit( op ); SQLUSMALLINT CompletionType = SQL_ROLLBACK; /* * FIXME: in case part of the operation cannot be performed * (missing mapping, SQL write fails or so) the entire operation * should be rolled-back */ Debug( LDAP_DEBUG_TRACE, "==>backsql_modify(): modifying entry \"%s\"\n", op->o_req_ndn.bv_val, 0, 0 ); rs->sr_err = backsql_get_db_conn( op, &dbh ); if ( rs->sr_err != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_modify(): " "could not get connection handle - exiting\n", 0, 0, 0 ); /* * FIXME: we don't want to send back * excessively detailed messages */ rs->sr_text = ( rs->sr_err == LDAP_OTHER ) ? "SQL-backend error" : NULL; goto done; } bsi.bsi_e = &m; rs->sr_err = backsql_init_search( &bsi, &op->o_req_ndn, LDAP_SCOPE_BASE, (time_t)(-1), NULL, dbh, op, rs, slap_anlist_all_attributes, ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY | BACKSQL_ISF_GET_OC ) ); switch ( rs->sr_err ) { case LDAP_SUCCESS: break; case LDAP_REFERRAL: if ( manageDSAit && !BER_BVISNULL( &bsi.bsi_e->e_nname ) && dn_match( &op->o_req_ndn, &bsi.bsi_e->e_nname ) ) { 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 = &m; /* fallthru */ default: Debug( LDAP_DEBUG_TRACE, "backsql_modify(): " "could not retrieve modifyDN ID - no such entry\n", 0, 0, 0 ); if ( !BER_BVISNULL( &m.e_nname ) ) { /* FIXME: should always be true! */ e = &m; } else { e = NULL; } goto done; } #ifdef BACKSQL_ARBITRARY_KEY Debug( LDAP_DEBUG_TRACE, " backsql_modify(): " "modifying entry \"%s\" (id=%s)\n", bsi.bsi_base_id.eid_dn.bv_val, bsi.bsi_base_id.eid_id.bv_val, 0 ); #else /* ! BACKSQL_ARBITRARY_KEY */ Debug( LDAP_DEBUG_TRACE, " backsql_modify(): " "modifying entry \"%s\" (id=%ld)\n", bsi.bsi_base_id.eid_dn.bv_val, bsi.bsi_base_id.eid_id, 0 ); #endif /* ! BACKSQL_ARBITRARY_KEY */ if ( get_assert( op ) && ( test_filter( op, &m, get_assertion( op ) ) != LDAP_COMPARE_TRUE )) { rs->sr_err = LDAP_ASSERTION_FAILED; e = &m; goto done; } slap_mods_opattrs( op, &op->orm_modlist, 1 ); assert( bsi.bsi_base_id.eid_oc != NULL ); oc = bsi.bsi_base_id.eid_oc; if ( !acl_check_modlist( op, &m, op->orm_modlist ) ) { rs->sr_err = LDAP_INSUFFICIENT_ACCESS; e = &m; goto done; } rs->sr_err = backsql_modify_internal( op, rs, dbh, oc, &bsi.bsi_base_id, op->orm_modlist ); if ( rs->sr_err != LDAP_SUCCESS ) { e = &m; goto do_transact; } if ( BACKSQL_CHECK_SCHEMA( bi ) ) { char textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' }; backsql_entry_clean( op, &m ); bsi.bsi_e = &m; rs->sr_err = backsql_id2entry( &bsi, &bsi.bsi_base_id ); if ( rs->sr_err != LDAP_SUCCESS ) { e = &m; goto do_transact; } rs->sr_err = entry_schema_check( op, &m, NULL, 0, 0, NULL, &rs->sr_text, textbuf, sizeof( textbuf ) ); if ( rs->sr_err != LDAP_SUCCESS ) { Debug( LDAP_DEBUG_TRACE, " backsql_modify(\"%s\"): " "entry failed schema check -- aborting\n", m.e_name.bv_val, 0, 0 ); e = NULL; goto do_transact; } } do_transact:; /* * Commit only if all operations succeed */ if ( rs->sr_err == LDAP_SUCCESS && !op->o_noop ) { assert( e == NULL ); CompletionType = SQL_COMMIT; } SQLTransact( SQL_NULL_HENV, dbh, CompletionType ); done:; if ( e != NULL ) { if ( !access_allowed( op, e, slap_schema.si_ad_entry, NULL, ACL_DISCLOSE, NULL ) ) { rs->sr_err = LDAP_NO_SUCH_OBJECT; rs->sr_text = NULL; rs->sr_matched = NULL; if ( rs->sr_ref ) { ber_bvarray_free( rs->sr_ref ); rs->sr_ref = NULL; } } } if ( op->o_noop && rs->sr_err == LDAP_SUCCESS ) { rs->sr_err = LDAP_X_NO_OPERATION; } send_ldap_result( op, rs ); slap_graduate_commit_csn( op ); if ( !BER_BVISNULL( &bsi.bsi_base_id.eid_ndn ) ) { (void)backsql_free_entryID( &bsi.bsi_base_id, 0, op->o_tmpmemctx ); } if ( !BER_BVISNULL( &m.e_nname ) ) { backsql_entry_clean( op, &m ); } if ( bsi.bsi_attrs != NULL ) { op->o_tmpfree( bsi.bsi_attrs, op->o_tmpmemctx ); } if ( rs->sr_ref ) { ber_bvarray_free( rs->sr_ref ); rs->sr_ref = NULL; } Debug( LDAP_DEBUG_TRACE, "<==backsql_modify()\n", 0, 0, 0 ); return rs->sr_err; }
int backsql_db_config( BackendDB *be, const char *fname, int lineno, int argc, char **argv ) { backsql_info *bi = (backsql_info *)be->be_private; Debug( LDAP_DEBUG_TRACE, "==>backsql_db_config()\n", 0, 0, 0 ); assert( bi != NULL ); if ( !strcasecmp( argv[ 0 ], "dbhost" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing hostname in \"dbhost\" directive\n", fname, lineno, 0 ); return 1; } bi->sql_dbhost = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): hostname=%s\n", bi->sql_dbhost, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "dbuser" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing username in \"dbuser\" directive\n", fname, lineno, 0 ); return 1; } bi->sql_dbuser = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): dbuser=%s\n", bi->sql_dbuser, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "dbpasswd" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing password in \"dbpasswd\" directive\n", fname, lineno, 0 ); return 1; } bi->sql_dbpasswd = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "dbpasswd=%s\n", /* bi->sql_dbpasswd */ "xxxx", 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "dbname" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing database name in \"dbname\" " "directive\n", fname, lineno, 0 ); return 1; } bi->sql_dbname = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): dbname=%s\n", bi->sql_dbname, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "concat_pattern" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing pattern" "in \"concat_pattern\" directive\n", fname, lineno, 0 ); return 1; } if ( backsql_split_pattern( argv[ 1 ], &bi->sql_concat_func, 2 ) ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "unable to parse pattern \"%s\"\n" "in \"concat_pattern\" directive\n", fname, lineno, argv[ 1 ] ); return 1; } Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "concat_pattern=\"%s\"\n", argv[ 1 ], 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "subtree_cond" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing SQL condition " "in \"subtree_cond\" directive\n", fname, lineno, 0 ); return 1; } ber_str2bv( argv[ 1 ], 0, 1, &bi->sql_subtree_cond ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "subtree_cond=%s\n", bi->sql_subtree_cond.bv_val, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "children_cond" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing SQL condition " "in \"children_cond\" directive\n", fname, lineno, 0 ); return 1; } ber_str2bv( argv[ 1 ], 0, 1, &bi->sql_children_cond ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "children_cond=%s\n", bi->sql_children_cond.bv_val, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "dn_match_cond" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing SQL condition " "in \"dn_match_cond\" directive\n", fname, lineno, 0 ); return 1; } ber_str2bv( argv[ 1 ], 0, 1, &bi->sql_dn_match_cond ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "children_cond=%s\n", bi->sql_dn_match_cond.bv_val, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "oc_query" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing SQL statement " "in \"oc_query\" directive\n", fname, lineno, 0 ); return 1; } bi->sql_oc_query = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "oc_query=%s\n", bi->sql_oc_query, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "at_query" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing SQL statement " "in \"at_query\" directive\n", fname, lineno, 0 ); return 1; } bi->sql_at_query = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "at_query=%s\n", bi->sql_at_query, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "insentry_stmt" ) || !strcasecmp( argv[ 0 ], "insentry_query" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing SQL statement " "in \"insentry_stmt\" directive\n", fname, lineno, 0 ); return 1; } bi->sql_insentry_stmt = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "insentry_stmt=%s\n", bi->sql_insentry_stmt, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "create_needs_select" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing { yes | no }" "in \"create_needs_select\" directive\n", fname, lineno, 0 ); return 1; } if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) { bi->sql_flags |= BSQLF_CREATE_NEEDS_SELECT; } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) { bi->sql_flags &= ~BSQLF_CREATE_NEEDS_SELECT; } else { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "\"create_needs_select\" directive arg " "must be \"yes\" or \"no\"\n", fname, lineno, 0 ); return 1; } Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "create_needs_select =%s\n", BACKSQL_CREATE_NEEDS_SELECT( bi ) ? "yes" : "no", 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "upper_func" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing function name " "in \"upper_func\" directive\n", fname, lineno, 0 ); return 1; } ber_str2bv( argv[ 1 ], 0, 1, &bi->sql_upper_func ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "upper_func=%s\n", bi->sql_upper_func.bv_val, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "upper_needs_cast" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing { yes | no }" "in \"upper_needs_cast\" directive\n", fname, lineno, 0 ); return 1; } if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) { bi->sql_flags |= BSQLF_UPPER_NEEDS_CAST; } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) { bi->sql_flags &= ~BSQLF_UPPER_NEEDS_CAST; } else { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "\"upper_needs_cast\" directive arg " "must be \"yes\" or \"no\"\n", fname, lineno, 0 ); return 1; } Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "upper_needs_cast =%s\n", BACKSQL_UPPER_NEEDS_CAST( bi ) ? "yes" : "no", 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "strcast_func" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing function name " "in \"strcast_func\" directive\n", fname, lineno, 0 ); return 1; } ber_str2bv( argv[ 1 ], 0, 1, &bi->sql_strcast_func ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "strcast_func=%s\n", bi->sql_strcast_func.bv_val, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "delentry_stmt" ) || !strcasecmp( argv[ 0 ], "delentry_query" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing SQL statement " "in \"delentry_stmt\" directive\n", fname, lineno, 0 ); return 1; } bi->sql_delentry_stmt = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "delentry_stmt=%s\n", bi->sql_delentry_stmt, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "renentry_stmt" ) || !strcasecmp( argv[ 0 ], "renentry_query" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing SQL statement " "in \"renentry_stmt\" directive\n", fname, lineno, 0 ); return 1; } bi->sql_renentry_stmt = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "renentry_stmt=%s\n", bi->sql_renentry_stmt, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "delobjclasses_stmt" ) || !strcasecmp( argv[ 0 ], "delobjclasses_query" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing SQL statement " "in \"delobjclasses_stmt\" directive\n", fname, lineno, 0 ); return 1; } bi->sql_delobjclasses_stmt = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "delobjclasses_stmt=%s\n", bi->sql_delobjclasses_stmt, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "has_ldapinfo_dn_ru" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing { yes | no }" "in \"has_ldapinfo_dn_ru\" directive\n", fname, lineno, 0 ); return 1; } if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) { bi->sql_flags |= BSQLF_HAS_LDAPINFO_DN_RU; bi->sql_flags |= BSQLF_DONTCHECK_LDAPINFO_DN_RU; } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) { bi->sql_flags &= ~BSQLF_HAS_LDAPINFO_DN_RU; bi->sql_flags |= BSQLF_DONTCHECK_LDAPINFO_DN_RU; } else { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "\"has_ldapinfo_dn_ru\" directive arg " "must be \"yes\" or \"no\"\n", fname, lineno, 0 ); return 1; } Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "has_ldapinfo_dn_ru=%s\n", BACKSQL_HAS_LDAPINFO_DN_RU( bi ) ? "yes" : "no", 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "fail_if_no_mapping" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing { yes | no }" "in \"fail_if_no_mapping\" directive\n", fname, lineno, 0 ); return 1; } if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) { bi->sql_flags |= BSQLF_FAIL_IF_NO_MAPPING; } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) { bi->sql_flags &= ~BSQLF_FAIL_IF_NO_MAPPING; } else { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "\"fail_if_no_mapping\" directive arg " "must be \"yes\" or \"no\"\n", fname, lineno, 0 ); return 1; } Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "fail_if_no_mapping=%s\n", BACKSQL_FAIL_IF_NO_MAPPING( bi ) ? "yes" : "no", 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "allow_orphans" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing { yes | no }" "in \"allow_orphans\" directive\n", fname, lineno, 0 ); return 1; } if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) { bi->sql_flags |= BSQLF_ALLOW_ORPHANS; } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) { bi->sql_flags &= ~BSQLF_ALLOW_ORPHANS; } else { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "\"allow_orphans\" directive arg " "must be \"yes\" or \"no\"\n", fname, lineno, 0 ); return 1; } Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "allow_orphans=%s\n", BACKSQL_ALLOW_ORPHANS( bi ) ? "yes" : "no", 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "baseobject" ) ) { if ( be->be_suffix == NULL ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): : " "must be defined after \"suffix\"\n", fname, lineno, 0 ); return 1; } if ( bi->sql_baseObject ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): : " "\"baseObject\" already provided (will be overwritten)\n", fname, lineno, 0 ); entry_free( bi->sql_baseObject ); } switch ( argc ) { case 1: return create_baseObject( be, fname, lineno ); case 2: return read_baseObject( be, argv[ 1 ] ); default: Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "trailing values " "in \"baseObject\" directive?\n", fname, lineno, 0 ); return 1; } } else if ( !strcasecmp( argv[ 0 ], "sqllayer" ) ) { if ( backsql_api_config( bi, argv[ 1 ], argc - 2, &argv[ 2 ] ) ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "unable to load sqllayer \"%s\"\n", fname, lineno, argv[ 1 ] ); return 1; } } else if ( !strcasecmp( argv[ 0 ], "id_query" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing SQL condition " "in \"id_query\" directive\n", fname, lineno, 0 ); return 1; } bi->sql_id_query = ch_strdup( argv[ 1 ] ); Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "id_query=%s\n", bi->sql_id_query, 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "use_subtree_shortcut" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing { yes | no }" "in \"use_subtree_shortcut\" directive\n", fname, lineno, 0 ); return 1; } if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) { bi->sql_flags |= BSQLF_USE_SUBTREE_SHORTCUT; } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) { bi->sql_flags &= ~BSQLF_USE_SUBTREE_SHORTCUT; } else { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "\"use_subtree_shortcut\" directive arg " "must be \"yes\" or \"no\"\n", fname, lineno, 0 ); return 1; } Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "use_subtree_shortcut=%s\n", BACKSQL_USE_SUBTREE_SHORTCUT( bi ) ? "yes" : "no", 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "fetch_all_attrs" ) ) { if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing { yes | no }" "in \"fetch_all_attrs\" directive\n", fname, lineno, 0 ); return 1; } if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) { bi->sql_flags |= BSQLF_FETCH_ALL_ATTRS; } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) { bi->sql_flags &= ~BSQLF_FETCH_ALL_ATTRS; } else { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "\"fetch_all_attrs\" directive arg " "must be \"yes\" or \"no\"\n", fname, lineno, 0 ); return 1; } Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "fetch_all_attrs=%s\n", BACKSQL_FETCH_ALL_ATTRS( bi ) ? "yes" : "no", 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "fetch_attrs" ) ) { char *str, *s, *next; const char *delimstr = ","; if ( argc < 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing <attrlist>" "in \"fetch_all_attrs <attrlist>\" directive\n", fname, lineno, 0 ); return 1; } str = ch_strdup( argv[ 1 ] ); for ( s = ldap_pvt_strtok( str, delimstr, &next ); s != NULL; s = ldap_pvt_strtok( NULL, delimstr, &next ) ) { if ( strlen( s ) == 1 ) { if ( *s == '*' ) { bi->sql_flags |= BSQLF_FETCH_ALL_USERATTRS; argv[ 1 ][ s - str ] = ','; } else if ( *s == '+' ) { bi->sql_flags |= BSQLF_FETCH_ALL_OPATTRS; argv[ 1 ][ s - str ] = ','; } } } ch_free( str ); bi->sql_anlist = str2anlist( bi->sql_anlist, argv[ 1 ], delimstr ); if ( bi->sql_anlist == NULL ) { return -1; } } else if ( !strcasecmp( argv[ 0 ], "check_schema" ) ) { if ( argc != 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing { yes | no }" "in \"check_schema\" directive\n", fname, lineno, 0 ); return 1; } if ( strcasecmp( argv[ 1 ], "yes" ) == 0 ) { bi->sql_flags |= BSQLF_CHECK_SCHEMA; } else if ( strcasecmp( argv[ 1 ], "no" ) == 0 ) { bi->sql_flags &= ~BSQLF_CHECK_SCHEMA; } else { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "\"check_schema\" directive arg " "must be \"yes\" or \"no\"\n", fname, lineno, 0 ); return 1; } Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config(): " "check_schema=%s\n", BACKSQL_CHECK_SCHEMA( bi ) ? "yes" : "no", 0, 0 ); } else if ( !strcasecmp( argv[ 0 ], "aliasing_keyword" ) ) { if ( argc != 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing arg " "in \"aliasing_keyword <string>\" directive\n", fname, lineno, 0 ); return 1; } if ( ! BER_BVISNULL( &bi->sql_aliasing ) ) { ch_free( bi->sql_aliasing.bv_val ); } ber_str2bv( argv[ 1 ], strlen( argv[ 1 ] ) + 1, 1, &bi->sql_aliasing ); /* add a trailing space... */ bi->sql_aliasing.bv_val[ bi->sql_aliasing.bv_len - 1] = ' '; } else if ( !strcasecmp( argv[ 0 ], "aliasing_quote" ) ) { if ( argc != 2 ) { Debug( LDAP_DEBUG_TRACE, "<==backsql_db_config (%s line %d): " "missing arg " "in \"aliasing_quote <string>\" directive\n", fname, lineno, 0 ); return 1; } if ( ! BER_BVISNULL( &bi->sql_aliasing_quote ) ) { ch_free( bi->sql_aliasing_quote.bv_val ); } ber_str2bv( argv[ 1 ], 0, 1, &bi->sql_aliasing_quote ); } else { return SLAP_CONF_UNKNOWN; } return 0; }