IBMlogo
IBM eNetwork Communications Server for Windows NT
Host Publisher Feature, Version 6.01
[Next|Previous|Contents]

Host Publisher Hints and Tips

User ID Management

One problem with using 3270 logons to retrieve data in a server environment is that a given account can only be logged on once. To service multiple requests simultaneously, different accounts must be used for each request.

Some sample code is provided to help manage account logons to allow multiple requests to be serviced in this environment. When you download and install the Host Simulator and samples, a file called UserIdPassword.exe is installed in the Library subdirectory of your Host Publisher installation directory. Run UserIdPassword.exe to extract the sample code. See the file Readme.html for further installation instructions.

The sample code is straightforward. It is not supported, but the source code is provided so that you can tailor it to your needs.

Code is provided to get a userid and its password, release a userid, and to release all the userids (to clean up, if necessary).

The Approach

The technique provided uses a database to keep track of the accounts. Using Dynascript on a Web page, you can reserve an account to use, pass it to an integration object, and release it.

Because the page server only evaluates Dynascript after all the other DYNA tags in a Web page, it is not possible to reserve a userid using Dynascript, use it in other DYNA tags, and release the userid again. There are two other approaches that work.

Two Web pages can be used. Dynascript on the first page reserves a userid. The userid is passed to a second page, where it is used and released. The drawback to this approach is that the user must follow a link to the second page. If the link is not followed, the userid remains reserved indefinitely. A second drawback is that if the user bookmarks the second page and then revisits it, they attempt to use a userid they have not reserved.

A better approach is to put most or all of the Web page inside Dynascript. You can use Dynascript to reserve a userid, invoke a host access integration object, and release the userid. This minimizes the chances of losing userids.

Before continuing, you might want to review the Scripting section on use of Dynascript in Web pages.

Warning: This technique fails if the page is scoped to client; be sure it is scoped to page (the default setting). (If the page is scoped to client, the integration object might remain logged in with the userid even after the script has returned the userid to the databaose.)

The account database

The account database is a Microsoft Access database with a single table.
FieldName FieldType(Size) Comment
userid text(50) KEY
password text(50)  
available text(1) "1" = available
"0" = in use
sortfield autonumber Used to sort the IDs during the select

A Java integration object uses JDBC to access the database. The Java methods provided are:

  1. String userid getNextUserID( )
    Call the getNextUserID method to obtain a UserID from the userid pool.
  2. String getNextPassword( )
    Call the getNextPassword method to obtain a Password for the UserID returned in step 1. The getNextPassword method should always be called AFTER the getNextUserID method (order is important).
  3. void releaseUserID(String userid)
    Call the releaseUserID method to release the userid to the pool of available userids.
  4. void releaseAllUserIDs( )
    Call the releaseAllUserIDs method to release ALL userid's marked as "in use" in the idpass.mdb database. This method is intended to be used as a system administration tool and probably should not be used on a web page that is visible to users.

Example

Here is an example of how Dynascript can be used to reserve a userid, retrieve some host access data, and release the userid.

Script Comments
<DYNASCRIPT language=JavaScript> Begin script
oUserIDManager = IObjects.Get("useridmanager"); Create an integration object to reference the useridmanager.
vUserID = oUserIDManager.GetItem("getNextUserID");
vPassword = oUserIDManager.GetItem("getNextPassword");
Get the user ID and the corresponding password.
Environment.PARAMS.SetProp("userid",vUserID);
Environment.PARAMS.SetProp("password",vPassword);
Put the user ID and password into Web parameters so the host access integration object can use them.
var oDate = IObjects.Get("hostdate");
Document.Writeln("The date is: " + oDate.GetItem("date");
Create a host access integration object, get some data from it, and output it as part of the Web page.
oUserIDManager.GetItem("releaseUserID"); Release the user ID.
</DYNASCRIPT> End the DYNAscript.

[Next|Previous|Contents]
IBM eNetwork Communications Server for Windows NT
Host Publisher Feature, Version 6.01