6

login required for dynamic parameter with a comman... - SAP Community

 7 months ago
source link: https://community.sap.com/t5/technology-q-a/login-required-for-dynamic-parameter-with-a-command-data-source/qaq-p/13595123
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

login required for dynamic parameter with a command data source

We have a dot net application for viewing crystal reports which ships with our software to display both pre-supplied reports and end users custom reports.  It uses Table.ApplyLogOnInfo to point to an end users SQL server and database and set a SQL user and pass for each table in the report and all sub reports.

One of our end users has created a report with a dynamic parameter based on a command and this causes Crystal to display a login screen that reads:

Enter Parameter values: Server name (disabled), User Name, Password, Use Single Signon Key (set to false and disabled)

If we enter the SQL username and password - the report then works fine, displaying the list of values from the DB.  I've tried this in Crystal 13 SP33 and SP35, 32 bit in a viewer compiled in VS2019

How do we avoid this login screen?  Stepping through the code in debug, ApplyLogOnInfo is being applied to the command and TestConnectivity returns true.

This can be recreated with a pretty simple report:

Using a system DSN to SQL Server using SQL Server auth

I create a simple command of the form: 'select field from table'

I then create a new dynamic parameter and set the field in this command as the datasource

I then drop this parameter on to the report

When this report is sent to our viewer it then loops through all tables on the report (and all tables in any sub reports - not relevant in this example)

For each table:

foreach (Table tbl in rep.Database.Tables)

we clone the logoninfo, modify it as desired and apply it:

TableLogOnInfo info = (TableLogOnInfo)tbl.LogOnInfo.Clone();
info.ConnectionInfo = CrystalSupport.GetConnectionInfo(ServerName, database, UserID, Password, Provider);
tbl.ApplyLogOnInfo(info);

We then test it and it comes back fine:

if (tbl.TestConnectivity())

The routine to configure the connectionInfo is as follows (this was written long ago, not by me, and I don't necessarily know what all these properties are! I would imagine a lot of it came from an example?):

private static ConnectionInfo GetConnectionInfo(string serverName, string databaseName, string userId, string password, string provider)
{
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.Type = ConnectionInfoType.SQL;
connectionInfo.ServerName = serverName;
connectionInfo.DatabaseName = databaseName;
connectionInfo.UserID = userId;
connectionInfo.Password = password;

CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag connectionAttributes = new CrystalDecisions.ReportAppServer.DataDefModel.PropertyBag();
connectionAttributes.EnsureCapacity(11);
connectionAttributes.Add("Connect Timeout", "15");
connectionAttributes.Add("Data Source", connectionInfo.ServerName);
connectionAttributes.Add("General Timeout", "0");
connectionAttributes.Add("Initial Catalog", connectionInfo.DatabaseName);
connectionAttributes.Add("Integrated Security", "false");
connectionAttributes.Add("Locale Identifier", "1033");
connectionAttributes.Add("OLE DB Services", "-5");
connectionAttributes.Add("Provider", provider);
connectionAttributes.Add("Tag with column collation when possible", "0");
connectionAttributes.Add("Use DSN Default Properties", false);
connectionAttributes.Add("Use Encryption for Data", "0");

DbConnectionAttributes attributes = new DbConnectionAttributes();
attributes.Collection.Add(new NameValuePair2("Database DLL", "crdb_ado.dll"));
attributes.Collection.Add(new NameValuePair2("QE_DatabaseName", connectionInfo.DatabaseName));
attributes.Collection.Add(new NameValuePair2("QE_DatabaseType", "OLE DB (ADO)"));
attributes.Collection.Add(new NameValuePair2("QE_LogonProperties", connectionAttributes));
attributes.Collection.Add(new NameValuePair2("QE_ServerDescription", connectionInfo.ServerName));
attributes.Collection.Add(new NameValuePair2("SSO Enabled", "false"));

connectionInfo.Attributes = attributes;

return connectionInfo;
}

So... this process has worked for years on tables.  And successfully applies and tests on commands.  But when a dynamic parameter uses this command as a data source - it prompts for a log in.  Does anyone have any ideas what I can do to get this logged in via code?

Thanks!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK