dynamic database connection not set in laravel - database

I am developing a multi database with common login laravel apps where user database is identified from a common table in default database.
After login it alters the default database setting to user defined database.
But it just goes to default database again in the next page request.
I alter the database as follows:
$config = \Config::get('database.connections.mysql');
$config['database'] = $check_db[0]->database_name;
config()->set('database.connections.mysql', $config);
DB::purge('mysql');
DB::reconnect('mysql');
Is there any other way to make it persistent through out the user session ?

Related

MongoDB live clone

I am looking for a way to create a live copy of my mongoDB. My requirement is that this new DB deployment should be completely independent of the existing DB server so, that the access role can be different from the main DB.
My needs are:
Transfer live data from main DB to this DB as soon as new data is entered
Main DB should not be accessible from outside network (internet)
New DB should have only one readOnly user who can read data from internet after authentication (username/password against authenticationDatabase)
Main DB does not have authentication enabled and it should be as it is
Think of it as if I want to create a mirror of application data without sharing authentication logic. I tried to add new DB in the replica set but it requires same auth policies. Also, I tried creating read-only replica with no voting rights but it did not work as the new DB needs user roles and once the role is added, replication stops as auth fails for internal nodes.
Is there any way to replicate/stream to new DB, so that only application data can be migrated? Also, if there is any other strategy then I can also try that as long as requirement does not change.

How do I recreate a user/login on a SQL Azure Active Geo-Replication Secondary

I have a Premium P2 SQL Azure Database for my Production App, and for security reasons I've created DB Specific Schemas/Views/Roles and a specific DB User account for reading the Data from SSRS Queries.
Lets just call the server PRIMARY and my database MyApp
The setup script for this is below.
-- On Primary Master
CREATE LOGIN ssrsuser WITH password='******'
-- On Primary MyApp
CREATE USER ssrsuser FOR LOGIN ssrsuser
CREATE ROLE [ssrsreader] AUTHORIZATION [db_owner]
GRANT SELECT ON SCHEMA :: [App] TO [ssrsreader]
GRANT SELECT ON SCHEMA :: [Reports] TO [ssrsreader]
EXEC sp_addrolemember 'ssrsreader', 'ssrsuser'
So our users were putting a LOT of load on the Prod DB and we decided it was time to move the reporting functions off to a secondary sync'd slave database.
Since we're using the SQL Azure Premium Tier, we can enable Active Geo-Replication with a read-only secondary copy. In fact MS even say that it's suitable for read-only workloads such as reporting.
So I've setup the SECONDARY server, enabled the seeding, it's now complete and I can access the readonly copy using the SECONDARY admin user and password.
But the SECONDARY server doesn't have a login for ssrsuser and I while I can create one in SECONDARY.master, I can't DROP RECREATE the user since the SECONDARY.MyApp database is in readonly mode.
Is there any otherway to get around this. I really don't want to have to put the SECONDARY server admin user & password into SSRS connection strings.
There is no need to regenerate SID for ssruser in the user database. It is already there as a result of replication. All you need to do is associate that SID with a LOGIN in the master in the secondary server. This article provides the details.
https://azure.microsoft.com/en-us/documentation/articles/sql-database-geo-replication-security-config/
I hope this helps.

Sails.js Dynamically Switching Database based on users

I am currently building a project that requires switching between different databases according to the user logged in.
Every registered user has it's own database however the tables (the structure) within the databases are the same.
e.g. user login by authenticating at the default database, if true then get the databaseName from the default database accordingly and then connect to that database from then on.
Is there any way to achieve this?
Thanks!

How to hide database or database object from sa and window authentication?

I have created Winforms application which stores some sensitive data like username and password.
The system used by many users. I am using SQL Server Express for storing data.
The application downloads data from a remote server by sync framework. I want to create only one user for that database so I can sync that database.
My problem is that I want to hide the database from all users which are using the application and also from the sa & Windows authentication accounts. So no one can see the other usernames or passwords.
How can I do this?
If I understand well, be best way to do it is :
keep one administrative login (one login that is member of sysadmin). It will be you. You need at least one admin.
disable sa : ALTER LOGIN [sa] DISABLE;
for all other logins, add them as users in the database, but don't give them any permission. They won't be able to see anything
use an application role (which is deprecated) OR create a user without login and use EXECUTE AS (which is the new way to go): you can learn more about it here : http://msdn.microsoft.com/en-us/library/bb669062(v=vs.110).aspx and http://msdn.microsoft.com/en-us/library/bb669087(v=vs.110).aspx. That will allow you to set other permissions for your users only when the conect through the application.

mapping/Associating the users created and saved in jazn-data.xml file in an adf fusion application to the database table

Is there any way by which I can map my users created in the jazn-data.xml file in adf application to the database table. Want to use query result in via method or bean return parameter.
You need to configure an sqlauthenticator in you WebLogic server (in the security realm).
If you got that working, you should be able use the default ADF Security settings to login with your users from your WLS.

Resources