Sign On Exit Program

Exit Program Overview

Setting a session's Sign On Method to ExitPgm will result in Webulator/400 call a user written exit program to determine how a session should be signed on. Webulator/400 uses the output of the user exit program and performs the sign on action on for the user. Currently, Webulator/400 only supports one data structure that can be passed to the exit program as its parameter list.

QAPP0100 Parameter Structure

Parameter Description              In/Out   Type
1         Query String             Input    Char(*)
2         Length Of Query String   Input    Binary(4)
3         Client IP Address        Input    Char(15)
4         CCSID                    Input    Binary(4)
5         Allow Operation          Output   Char(1)
6         User Profile             Output   Char(10)
7         Password                 Output   Char(10)
8         Current Library          Output   Char(10)
9         Program To Call          Output   Char(10)
10        Initial Menu             Output   Char(10)
11        Session Termination URL  Output   Char(300)

Query String
INPUT:CHAR(*)
This is the user defined information that appears at the end of a Webulator/400 URL.
For example, www.inetmi.com:5061/?QueryStringID=Value
If no information is appended, then it is set to a NULL pointer.
Length of Query String
INPUT:BINARY(4)
The length, in bytes, of any query string parameter content from the URL.
The length is set to zero if no query string parameter is provided.
Client IP address
INPUT:CHAR(15)
The Internet Protocol (IP) (dotted decimal) address of the client, which is extracted from the connected socket information. Please note that this may actually be a firewall address, router, or other identifier, and not the actual client IP address.
CCSID
INPUT:BINARY(4)
The CCSID of the data to use for conversions between EBCDIC and ASCII.
Allow operation
OUTPUT:BINARY(4)
Indicates whether the Webulator/400 session should be accepted.

The possible values are:

0 - Reject the request from the client browser.
User profile, password, current library, program to call, and initial menu output parameters are ignored and an error is sent to the client.
1 - Accept the request from the client browser.
The exit program supplies the user profile, password, current library, program to call and initial menu output parameters.
User profile
OUTPUT:CHAR(10)
The user profile to be used for the sign-on procedure.
This parameter is required.
It must be left justified and padded with blanks.
Password
OUTPUT:CHAR(10)
The password to be used for the sign-on procedure.
This parameter is required.
It must be left justified and padded with blanks.
Current library
OUTPUT:CHAR(10)
The library in which the program to be called is located.
This parameter is optional.
It must be left justified and padded with blanks.
If you do not supply a library, Webulator/400 uses the default of *USRPRF.
Program to call
OUTPUT:CHAR(10)
The name of the program to be called.
This parameter is optional.
It must be left justified and padded with blanks.
If you do not supply a program name, Webulator/400 uses the default of *USRPRF.
Initial menu
OUTPUT:CHAR(10)
The name of the initial menu to display.
This parameter is optional.
It must be left justified and padded with blanks.
If you do not supply a menu name, Webulator/400 uses the default of *USRPRF.

Exit Program Example

Signon Exit programs can be written in any programming language on the AS/400. Below you will find a simple example written in CL and C. Both samples show the basics of how to accept parameter structure and returns a valid userid and password to Webulator/400. The intent of these samples is to give you a basic skeleton that you can use for your own exit program.

CL Exit Program Sample

PGM        PARM(&QRYSTR &LQRYSTR &IP &CCSID &ALLOW     + 
                &USERID &PASSWD &LIB &PROG &MENU &URL)                    
/*------------------------------------------*/ 
/* Accept QAPP0100 parameter structure      */ 
/*------------------------------------------*/ 
DCL        VAR(&QRYSTR)  TYPE(*CHAR) LEN(300)              
DCL        VAR(&LQRYSTR) TYPE(*CHAR) LEN(4)               
DCL        VAR(&IP)      TYPE(*CHAR)                        
DCL        VAR(&CCSID)   TYPE(*DEC)                         
DCL        VAR(&ALLOW)   TYPE(*CHAR)                        
DCL        VAR(&USERID)  TYPE(*CHAR) LEN(10)                
DCL        VAR(&PASSWD)  TYPE(*CHAR) LEN(10)                
DCL        VAR(&LIB)     TYPE(*CHAR) LEN(10)                
DCL        VAR(&PROG)    TYPE(*CHAR) LEN(10)                
DCL        VAR(&MENU)    TYPE(*CHAR) LEN(10)                
DCL        VAR(&URL)     TYPE(*CHAR) LEN(300)      

/* Change ALLOW to 1 to specify OK to signon */                                                            
CHGVAR     VAR(&ALLOW)  VALUE('1')               
/* Hardcode a valid user ID */                                                            
CHGVAR     VAR(&USERID)  VALUE('QUSER     ')      
/* Hardcode a valid password */                                                            
CHGVAR     VAR(&PASSWD)  VALUE('QUSER     ')      
/* Do not change default lib, prog or menu */                                                            
CHGVAR     VAR(&LIB)    VALUE('          ')      
CHGVAR     VAR(&PROG)   VALUE('          ')      
CHGVAR     VAR(&MENU)   VALUE('          ')      
/* Set term URL to value passed on qry string */                                                            
CHGVAR     VAR(&URL)    VALUE(&QRYSTR)             
                                                            
RETURN                                           
ENDPGM                                           

C Exit Program Sample


#include  
#include  
#include  

/* Prototypes */
void CheckValues  (char *,int,char *,int,char *,char *,char *,char *,char *,char *,char *); 

/**********************************************************************/ 
/* Input:                                                             */ 
/*   chat * argv[1]        - Query string value                       */ 
/*   int    argv[2]        - Length of query string                   */ 
/*   char * argv[3]        - IP address of the remote host system.    */ 
/*   int    argv[4]        - CCSID of the query string value          */ 
/* Output:                                                            */ 
/*   char * argv[5]        - Allow operation '0'=No, '1'=Yes          */ 
/*   char * argv[6]        - User profile to be used                  */ 
/*   char * argv[7]        - Password to be used                      */ 
/*   char * argv[8]        - Program library to be used               */ 
/*   char * argv[9]        - Program name to be used                  */ 
/*   char * argv[10]       - Menu panel to be used                    */ 
/*   char * argv[11]       - Termination URL to be used               */ 
/**********************************************************************/ 
void main(int argc, char *argv[]) 
{ 
     exitpgm(argv[1], 
             *((int *)(argv[2])), 
             argv[3], 
             *((int *)(argv[4])), 
             argv[5], 
             argv[6], 
             argv[7], 
             argv[8], 
             argv[9], 
             argv[10], 
             argv[11]); 
  return; 
}            /* End main */ 


void CheckValues(char *QueryString, 
                 int QueryStringLength, 
                 char *IPaddr, 
                 int  CCSID, 
                 char Allow, 
                 char *UserID, 
                 char *Password, 
                 char *Library, 
                 char *Program, 
                 char *Menu,
                 char *TerminationURL)
{
     /* change here for your logic */ 
     memcpy(UserID,   "QUSER     ", 10); 
     memcpy(Password, "QUSER     ", 10); 
     memcpy(Library,  "          ", 10); 
     memcpy(Program,  "          ", 10); 
     memcpy(Menu,     "          ", 10); 
     Allow = '1';

     return;  
}