We have set of dashboards ready. As of now this dashboards point to only one data source. But we have requirement like based on User login in pentaho we need to check this login user points to which database and based on this we need to dynamically change the dashboard connection and get the result on pentaho dashboard from that specific database.
For this we have one master database. Inside this DB we have one table along with following columns Username ,Server name and Database Name.
Now we are facing problem like how can I make dynamic connection using this master table based on user login in pentaho BI server?
So far I have check this url https://forums.pentaho.com/threads/136669-Dynamic-Datasource/. But I am not getting like how this "SelectedDatabase" parameter set based on user login? Can anyone help to resolve this problem?
Inside CDA connections, the logged in user is available as ${[security:principalName]}. Below is a sample CDA definition that should retrieve the desired ServerName and DatabaseName.
<DataAccess access="public" connection="datamart" id="master_table" type="sql">
<Name>master_table</Name>
<Cache duration="3600" enabled="true"/>
<Columns/>
<Parameters>
<Parameter access="private" default="${[security:principalName]}" name="PRM_USER" type="String"/>
</Parameters>
<Query>
select ServerName, DatabaseName
from MasterTable
where UserName = ${PRM_USER};
</Query>
</DataAccess>
You would need to call this early (change priority) and then use the resultset to configure the datasource for the dashboard.
This is the Pentaho documentation for multitenancy, you want the Sharding type. It looks like it takes some code to make it work in a secure way.
https://help.pentaho.com/Documentation/7.1/0R0/070/Multi-Tenancy