Validation Lists: Secure iSeries Web Sites Without User Profiles

IBM i (OS/400, i5/OS)
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times
Over the last few months, I've been teaching a seminar on CGI Web programming using RPG IV. The seminar has gone well, and I may do more of them in the future.

During the seminars, attendees asked if it was possible to secure a section of a Web site or the entire Web site without creating a unique OS/400 user profile object for each user.

Imagine a Web site with 50,000 or perhaps 50 million Web users. Now, consider that in order to secure a specific location on your Web site, you would have to create an equal number of user profiles on the system to maintain security. This could be a lot of burden on the system. In addition, it would become difficult to maintain unique user profile names because there are only 10 characters available for a user profile name. This is where validation list objects come into play.

A validation list is an OS/400 object that may contain identification data, encrypted data, and descriptive data. A validation list may also be used to secure a folder on the IFS. By creating a validation list, adding "Web user IDs" and passwords to the list, then securing a folder with the validation list, you end up with a new model for user profiles: Web user profiles. The best part is that the user IDs stored in a validation list may be up to 100 bytes long, and their passwords may be up to 600 bytes long (encrypted). Additionally, you may store up to 1,000 bytes of miscellaneous data for each validation list entry. That's enough space to save all the information for most Web users.

Because validation lists are OS/400 objects, they are restricted to 10-character names and are placed in a library. You can use the Create Validation List (CRTVLDL) command to create the validation list and the Delete Validation List (DLTVLDL) command to delete the validation list. The bad news is that there are no validation list commands other than Create and Delete. There are only APIs.

Validation List APIs

Actually, there are two sets of validation list APIs. There are the traditional QSYADVLE-style APIs with eight-character names that can be called from any programming language (including RPG III), and there are the QsyAddValidationLstEntry-style APIs that may be called only from ILE languages, such as C, C++, and RPG IV.

The table below shows both types.

Any Language
ILE Languages
Add Validation List Entry
Change Validation List Entry
Find Validation List Entry
Open Validation List

Get List Entries From Handle

Find List Entries From Handle

Close Validation List

Find First Validation List Entry

Find Next Validation List Entry

Find Validation List Entry

Find Validation List Entry Attributes

Remove Validation List Entry
Verify Validation List Entry

Add Validation List Certificate
Check Validation List Certificate
List Validation List Certificates

The validation list APIs with traditional API names, such as QSYADVLE, are called from RPG IV using the traditional CALL/PARM syntax or with the CALLP and a program prototype. The other APIs, such as QsyAddValidationLstEntry, may be called with a prototype from RPG IV, but they are really designed to be called from C or C++.

Using Validation Lists

While you can get some interesting function out of the validation list APIs, typically you want to do the following:

  • Create a validation list
  • Add entries to a validation list
  • Remove entries from a validation list

Creating a validation list is easy; just issue the CRTVLDL command, specifying the validation list name and its library. Note, the object type is *VLDL.

Adding and removing entries from a validation list requires the use of the APIs. I have written two simple RPG IV procedure wrappers for the QSYADVLE and QSYRMVLE APIs. But rather than post the source code here, in the newsletter, I am featuring only the syntax for the procedures themselves. The source code for these procedures is shown at the end of this article.

Add Validation List Entry (ADDVLDLE)

The ADDVLDLE procedure adds an entry to an existing validation list object. If the validation doesn't exist or there is a duplicate entry, the procedure fails. The syntax for ADDVLDLE is as follows:

int = AddVldle( vldl-name : vldl-library : entry : password [ : extra-data ] )

VLDL-NAME is the name of the validation list object. This parameter is required.

VLDL-LIBRARY is the name of the library that contains the validation list. This parameter is required.

ENTRY specifies the user ID to add to this validation list entry. This parameter is required and is case-sensitive.

PASSWORD specifies the password that the user will need to type. It is stored encrypted in the validation list. This parameter is required and is case-sensitive.

EXTRA-DATA specifies any additional data to store with the user validation list entry. This parameter is optional.

Remove Validation List Entry (RMVVLDLE)

The RMVVLDLE procedure deletes an entry to an existing validation list object if the validation doesn't exist. The syntax for RMVVLDLE is as follows:

int = RmvVldle( vldl-name : vldl-library : entry  )

VLDL-NAME is the name of the validation list object. This parameter is required.

VLDL-LIBRARY is the name of the library that contains the validation list. This parameter is required.

ENTRY specifies the user ID to be removed. This parameter is required and is case-sensitive.

Using a Validation List to Secure Your Web Site

You can secure your Web site with a validation list, OS/400 object-level security, or both. To secure the Web site with a validation list, add the Protection directive to your HTTP configuration file. In that Protection directive, you will specify the validation list name.

Once the Protection directive has been added and the HTTP server is ended and restarted, the IFS directory specified within the context of the Protection statement will be secured. Only those Web users whose user IDs appear in the validation list will be permitted to view and access Web pages in that directory.

In order to gain access, Web users will be required to enter their user ID and password, exactly as it appears in the validation list. Unlike traditional OS/400 user profiles and passwords, validation list user profiles and passwords are case-sensitive. Using the wrong case is perhaps the single biggest typographical error users make when entering these values. Be sure you let your Web users know that user IDs and passwords are case-sensitive.

To activate security using validation lists, specify the validation list name on the PasswdFile statement within the Protection directive of your HTTP configuration file (WRKCFGHTTP). Look at the spelling of this statement; it is "PasswdFile." Strange abbreviations run rampant in the HTTP configuration file world.

In the following example, a validation list named WEBUSERS in the QUSRSYS library is used to secure access to the IFS directory named /mywebsites/rpgiv/files/secure. All files and subdirectories in that folder are also secured by this Protection directive.

Protection MYSECURITY {
            ServerID  RPGIVNETWORK
            Authtype Basic
            PasswdFile QUSRSYS/WEBUSERS
            GroupFile /mywebsites/rpgiv/files/secure

With the above Protection directive in place, anyone attempting to access a file in the /mywebsites/rpgiv/files/secure IFS folder will be prompted to enter a user ID and password. The system will then match the information that's entered against the entries in a validation list named WEBUSERS. Note the ServerID statement that is included this Protection directive. The ServerID statement is used to specify information that is displayed when the system prompts the user for a user ID and password. In other words, it informs the end-user of the name of the system they are about to sign on to. This name can be anything and does not need to be a real system name.

Validation List Summary

A validation list and a few lines in the HTTP configuration file can secure your Web site's private pages from prying eyes. Also, you could create a members-only section of your Web site, providing access only to those who have paid a registration fee.

Source Code

Validation List Wrapper RPG IV Source

      ** Validation List Helper procedures
      ** (c) Copyright 2002 by Robert Cozzi, Jr.
      ** Permission to use granted to the public
      ** provided proper Accreditation is given.
      ** System API Includes for Validation Lists
      /copy qsysinc/qrpglesrc,qsyvldl

      ** Validation list Procedure prototypes
      /copy newsletter/qrpglesrc,vldl

     PAddVldle         B                   Export
     D AddVldle        PI
     D VldlName                      10A   Const
     D VldlLib                       10A   Value
     D VldlEntry                    100A   Const Varying
     D VldlPwd                      600A   Const Varying
     D VldlEx                      1000A   Const Varying options(*NOPASS)

     D  Api_Error      S             16A   INZ(*ALLX'00')
     D VldList         S             21A
     D QsyAddVldLstE   PR                  Extpgm('QSYADVLE')
     D  VldLst                             LIKE(VLDList)
     D  EntryInfo                          LIKE(QSYEIDI)
     D  EncryptData                        LIKE(QSYEEDI)
     D  ExtraData                          LIKE(QSYEDI)
     D  Atrribute                          LIKE(QSYAR01)
     D  api_ErrorDS                        LIKE(api_Error)
     C                   if        VldlLib = *BLANKS
     C                   Eval      VldlLib = '*LIBL'
     C                   Endif
     C                   Eval      VldList = VldlName + VldlLib

     C                   Eval      QsyEIDI  = *ALLX'00'
     C                   Eval      QsyEEDI  = *ALLX'00'
     C                   Eval      QsyEDI   = *ALLX'00'
     C                   Eval      QSYAR01  = *ALLX'00'
      ** Validation list Entry
     C                   Eval      QSYEIDL  = %Len(%TrimR(VldlEntry))
     C                   Eval      QSYCCSID03 = 0
     C                   Eval      QSYEID = VldlEntry
      ** Password
     C                   Eval      QSYEDL = %Len(%TrimR(VldlPwd))
     C                   Eval      QSYCCSID04 = -1
     C                   Eval      QSYED = VldlPwd
      ** Additional Data
     C                   If        %Parms >= 5
     C                   Eval      QSYEDL00 = %Len(%TrimR(VldlEx))
     C                   Eval      QSYCCSID05 = 0
     C                   Eval      QSYED00 = VldlEx
     C                   endif
      ** Attributes
     C                   Eval      QSYAR01  = *ALLX'00'
      ** Create the validation list entry
     C                   CallP     QSyAddVldLstE( VldList : Qsyeidi :
     C                               Qsyeedi : QSyEDI : Qsyar01 : api_Error)
     PAddVldle         E

Validation List Procedure Prototypes

** Add Validation List Entry
      ** (c) Copyright 2002 by Robert Cozzi, Jr.
      ** Permission to use granted to the public
      ** provided proper Accreditation is given.
     D AddVldle        PR
     D VldLName                      10A   Const
     D VldLLib                       10A   Value
     D VldLEntry                    100A   Const Varying
     D VldLPwd                      600A   Const Varying
     D VldLExData                  1000A   Const Varying options(*NOPASS)

Validation List Test Program

Note: To compile the test program with PDM option 14, you will need to create a binding directory. Please see the inline comments for compiling instructions.

      ** To compile use option 14 in PDM after creating a
      ** binding directory, or use the following commands:
      **                 ACTGRP(QILE)  <-- Any name you want.
      ** -------------------------------------------------

      ** The prototype for the Library list procedure(s).
     D VldlName        S             20A   Inz('COZZI')
     D VldlLibrary     S             20A   Inz('NEWSLETTER')
     D VldlEntry       S            100A   VARYING
     D VldlPwd         S            600A   VARYING
     C                   Eval      VldlEntry = This email address is being protected from spambots. You need JavaScript enabled to view it.'
     C                   Eval      VldlPwd   = 'rosebud'
     C                   CallP     AddVldlE(VldlName : VldlLibrary :
     C                                VldlEntry : VldlPwd)
     C                   Eval      *INLR = *ON