Connect Postgresql users data to TRS users and change connection string depends on user

0 Answers 135 Views
ConnectionString General Discussions
Raniel
Top achievements
Rank 1
Iron
Iron
Raniel asked on 05 Oct 2022, 03:16 AM
Hello, we have a bunch of users stored in our Postgresql, I would like to ask on how to connect it in our TRS users so that I wouldn't manually create them inside the TRS and how to change the connection string of the reports and also the Report Title  base on user.
Dimitar
Telerik team
commented on 07 Oct 2022, 02:17 PM

I am not sure that I understand the question completely. From what I could understand, your PostgreSQL database has a couple of users stored on it and you wish to use them instead of creating TRS accounts for that? We do not support such functionality, they need to be TRS users to access the TRS features.

Have you considered using the Guest User instead? The guest user is just a general user for viewing reports but if you are redirecting to the TRS from another application, for example, you could store the user information somewhere on that user's browser, like the Local Storage, and then you may get that information to dynamically switch the connection of the previewed report - Assign connection string dynamically using report parameter and bindings | Telerik Reporting

Raniel
Top achievements
Rank 1
Iron
Iron
commented on 10 Oct 2022, 02:39 AM

Yes, that's what I meant. Using the users already created from our database to connect it on TRS but since it is not supported, its okay. I will just manually create them.

I am not sure of Guest User, I tried it before but it is not applicable since all users should have an account. No, I wont be redirecting to TRS from another application, just a plain login, like if user A accessing the TRS, he will see the report with connectionstring A reports, if user user B login, he will see the report with connectionstring B reports.

 Assign connection string dynamically using report parameter and bindings | Telerik Reporting - Does this do the job? coz I haven't tried this one yet.

Dimitar
Telerik team
commented on 12 Oct 2022, 01:32 PM

Yes, the report parameters approach does work, however, since TRS is being used directly, in order to implement this approach you would need to edit the view used for previewing reports. All TRS views are located inside the Views folder. The report viewer preview is at the following path:

C:\Program Files (x86)\Progress\Telerik Report Server\Telerik.ReportServer.Web\Views\Report\Preview.cshtml

This is where the report viewer is initialized when the report is previewed and this is where you can add the custom code that passed the connection string for the given user as a parameter to the report.

Other than that, you could also try to set up the connection string using the UserIdentity. Basically, you may create a user function that takes the UserIdentity.Name and returns the connection string for the respective user. Just like the report parameter example, the string that this custom method will return has to be bound to the DataSource of the given report item.

For more information on using custom functions in TRS, please see the How to configure Telerik Report Server to use reports with custom functions | Telerik Report Server article.

Raniel
Top achievements
Rank 1
Iron
Iron
commented on 14 Oct 2022, 06:00 AM | edited

Hi, I followed the answer from the forum regarding on UserIdentity.Name and I'm getting this error where I can't establish connection to the database. What did I missed? Do I still need to put the connectionstring inside the configuration file?

Change connection string based on user


Dimitar
Telerik team
commented on 18 Oct 2022, 12:45 PM

The error message suggests that there is some kind of issue with the connection string's formatting.

Please refer to PostgreSQL connection strings - ConnectionStrings.com and ensure that you are passing a valid connection string. Check whether the Report Parameter's value is exactly as you would expect.

No answers yet. Maybe you can help?

Tags
ConnectionString General Discussions
Asked by
Raniel
Top achievements
Rank 1
Iron
Iron
Share this question
or