Wednesday, August 24, 2005

Passing a password to Viewer

In the 10.1.2 release (aka the 'Drake' release), the use of passwords in URLs has been discontinued for security reasons. Specifically, you cannot send passwords using the HTML Form GET method. What would happen when you enter a Discoverer URL of the form http://[Discoverer Viewer host name]:[port number]/discoverer/viewer?us=[user name]&pw][password]….? The password is not recognized and the user is instead redirected to a Viewer login screen.

So what do you do? Well, the solution is fairly straightforward. Use public or SSO connections! Ok, so that may not be acceptable to everyone :-)
So what do you do? The answer is you can use a simple HTML form with a
POST method to perform this action.

Let's see with an example:
Create this simple (really simple) html page as shown below.

This would display in your browser as a small and ugly looking page (but form is not the objective here, function is - and that was a really bad pun).

You will see two things of interest in the HTML code:
- All the required fields have their values pre-filled: the username, password, EUL, database, workbook, and the worksheet to open. Instead of using workbook and worksheet names I am using their identifiers - this is simply good practice IMO.
- All these fields are hidden. You could make them visible also (as we will see later), but if the objective is to simply provide a button a user can click to open a worksheet in Viewer, this will do just fine.
On clicking this button Discoverer Viewer launches, runs, and displays the ProfitSales worksheet from the RegionAnalysis workbook.

You could obviously make this prettier if you wanted. Another interesting tweak you can do is to also pass in the required page item value so that the worksheet opens with the required page item. To pass this page item value you use the URL parameter pi_[page item name]=[page item value]. Here my page item is called 'Region' and the value I am interested in is 'West'. The URL parameter name-value pair would therefore be 'pi_Region=West'. The HTML source is shown below.
Note that the page item parameter is case sEnsiTivE. Therefore pi_region will not work.

And the page as displayed in the browser will look like this:

The resultant Viewer page looks like this:

Note: this can just as easily be applied to Discoverer Plus. You would need to use the appropriate URL parameters in the HTML form.
[Thanks to Jonathan]

website statistics