logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Ott  
#1 Posted : Monday, April 12, 2021 9:03:53 PM(UTC)
Ott

Rank: Member

Groups: Registered
Joined: 6/9/2017(UTC)
Posts: 17
Canada

Thanks: 1 times
Hi,

I'm trying to build a Custom Security Script to connect to Oracle using the sample Database Authentication script available in Seal Report. It looks like the sample script is meant to be used with SQL Server. Could you provide some guidance, or a sample that will work with the OraOLEDB.Oralce.1 provider.

Thanks,
Yves
epf  
#2 Posted : Tuesday, April 13, 2021 10:16:56 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 973
Switzerland

Thanks: 14 times
Was thanked: 168 time(s) in 162 post(s)
I think the code is generic,
if you set a working Oracle OleDb connection string in the parameter (user.Security.GetValue("oledb_connection_string")), it may work as the object below are DbConnection and DbCommand...
however I did not test this with Oracle, there are several ways to customize the Security Script.
good luck.
Ott  
#3 Posted : Tuesday, April 13, 2021 1:12:20 PM(UTC)
Ott

Rank: Member

Groups: Registered
Joined: 6/9/2017(UTC)
Posts: 17
Canada

Thanks: 1 times
I'm still having problems connecting. I modified the script as follows, hardcoding values for simplicity's sake:

@using System.Data
@using System.Data.Common
@using System.Data.SqlClient
@{
SecurityUser user = Model;

DbConnection connection = Helper.DbConnectionFromConnectionString(ConnectionType.OleDb, Helper.GetOleDbConnectionString(user.Security.GetValue("oledb_connection_string"), "Admin", "MyPassword"));
connection.Open();



When I test the script us the 'Test a login' option in the Seal Security Editor, I receive the error below. The error refers to a SQL Server, which makes me believe the script is SQL Server oriented, not generic.

ERROR: Authentication failed
User login name: admin
User display name: Admin

Error:
[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.
Ott  
#4 Posted : Tuesday, April 13, 2021 2:32:26 PM(UTC)
Ott

Rank: Member

Groups: Registered
Joined: 6/9/2017(UTC)
Posts: 17
Canada

Thanks: 1 times
I did more testing and found that the call to get the connection seems to be the issue:
Helper.GetOleDbConnectionString(user.Security.GetValue("oledb_connection_string"), user.Name, "MyPassword")

I replace the call with the following and the test login was successful:
Helper.GetOleDbConnectionString("Provider=OraOLEDB.Oracle.1;Persist Security Info=True;Data Source=MyDbSource", user.Name, "MyPassword")

I would prefer not to hardcode the connection string, do you have a suggestion to get the user.Security.GetValue() call to work?

Yves
epf  
#5 Posted : Tuesday, April 13, 2021 4:19:38 PM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 973
Switzerland

Thanks: 14 times
Was thanked: 168 time(s) in 162 post(s)
user.Security.GetValue("oledb_connection_string") will return the value of the parameter,
just under the 'Custom Security Script' property, there is the 'Parameters' parameter, if you edit this, you should be able to set your connection string...

all this is defined in the file "Database Authentication.cshtml" that you can also customized.

Edited by user Tuesday, April 13, 2021 4:21:21 PM(UTC)  | Reason: Not specified

Ott  
#6 Posted : Tuesday, April 13, 2021 4:31:03 PM(UTC)
Ott

Rank: Member

Groups: Registered
Joined: 6/9/2017(UTC)
Posts: 17
Canada

Thanks: 1 times
I'm not sure I understand what you're saying regarding the 'Parameters'. Hardcoding a value in the parameter is essentially the same as hardcoding a a value in the script. I don't see any benefits. I'm trying to get the connect string defined for the data source.

I had a look at the "Database Authentication.cshtml" script, its contents is different than what I see when I edit the script from Seal Security Editor. The script also contains extra binary characters when I open it with a text editor. Can you explain the differences and what tool I should use to edit the script?

Yves
epf  
#7 Posted : Wednesday, April 14, 2021 8:53:42 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 973
Switzerland

Thanks: 14 times
Was thanked: 168 time(s) in 162 post(s)
To get a connection string from an existing data source, just use the following code:
Code:
    var source = Repository.Instance.Sources.FirstOrDefault(i => i.Name.StartsWith("Northwind"));
    if (source != null) {
        System.Data.Common.DbConnection connection = source.GetOpenConnection();
    }

then you can use the connection which is already opened....


otherwise *.cshtml file are text files (UTF8) and can be edited with a NotePad or VisualStudio.

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.