This is a migrated thread and some comments may be shown as answers.

Change connection string based on user

2 Answers 241 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kyle Smith
Top achievements
Rank 1
Kyle Smith asked on 20 Jun 2018, 01:43 PM

Is it possible to change a report connection string based on user? We have several instances of a web application (each with their own database). We have multiple reports for this web application and would like to not have to deploy a new set to the report server for each instance. Instead, it would be nice if we could have the report select a connection string based on the user accessing the Telerik Report Server. Is this possible?

We previously had reports deployed with the standalone Telerik Report Viewer, and the reports used the connection string based on the web.config of the site. However, we changed to using Telerik Report Server to obtain the report subscription and data alerts features.

2 Answers, 1 is accepted

Sort by
0
Accepted
Todor
Telerik team
answered on 25 Jun 2018, 08:45 AM
Hi Kyle,

The requirement can be achieved relatively easy for reports without parameters fetching their AvailableValues from an SqlDataSource, which connection string should be modified dynamically.

In the Report or other Data item (Table, List, etc.) where the connection string is supposed to be changed dynamically introduce a new Binding.
The Binding can use the exposed UserIdentity properties to set the connection string based on the user. For example:
Property path                   |   Expression
 
DataSource.ConnectionString     |   = IIF(UserIdentity.Name = "user1", "user1_ConnectionString",
                    |       IIF(UserIdentity.Name = "user2", "user2_ConnectionString",
                    |       IIF(UserIdentity.Name = "user3", "user3_ConnectionString",AND SO ON...)))

Note that DataSource.ConnectionString property is not listed in the dropdown and must be typed manually.

The proposed approach cannot be used to modify the Connection String of Report Parameter -> AvailableValues -> DataSource as report parameters do not expose Bindings. 

Regards,
Todor
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Kyle Smith
Top achievements
Rank 1
answered on 25 Jun 2018, 12:18 PM
Thank you! I'll give this a shot--sounds like it does exactly what I want.
Tags
General Discussions
Asked by
Kyle Smith
Top achievements
Rank 1
Answers by
Todor
Telerik team
Kyle Smith
Top achievements
Rank 1
Share this question
or