Example: FTP server logon exit program in ILE RPG code

 

This is an example of a simple File Transfer Protocol (FTP) Server Logon exit program. It is written in ILE RPG.

This code is not complete, but provides a starting point to help you create your own program.

By using the code examples, you agree to the terms of the Code license and disclaimer information.

(Preformatted text in the following example will flow outside the frame.)

       *Module Description ************************************************
       *                                                                  *
       ********************************************************************
       *                                                                  *
       * 


This program is only an example and has NOT undergone any * * formal review or testing. * * * ******************************************************************** * * * PROGRAM FUNCTION * * * * This program demonstrates some of the abilities an FTP Server * * Logon Exit Program can have. * * * ******************************************************************** F/SPACE 3 ******************************************************************** * * * INDICATOR USAGE * * * * IND. DESCRIPTION * * * * LR - CLOSE FILES ON EXIT * * * ******************************************************************** F/EJECT ******************************************************************** * DATA STRUCTURES USED BY THIS PROGRAM * ******************************************************************** * * Define constants * 1 D Anonym C CONST('ANONYMOUS ') D Text1 C CONST('Anonymous (') D Text2 C CONST(') FTP logon') D InvalidNet C CONST('10.') C/EJECT ******************************************************************** * VARIABLE DEFINITIONS AND LISTS USED BY THIS PROGRAM * ******************************************************************** C/SPACE 2 * * Define binary parameters * D DS D APPIDds 1 4B 0 D USRLENds 5 8B 0 D AUTLENds 9 12B 0 D IPLENds 13 16B 0 D RETCDds 17 20B 0 * C *LIKE DEFINE APPIDds APPIDIN C *LIKE DEFINE USRLENds USRLENIN C *LIKE DEFINE AUTLENds AUTLENIN C *LIKE DEFINE IPLENds IPLENIN C *LIKE DEFINE RETCDds RETCDOUT * * Define parameter list * C *Entry PLIST * Input parameters: C PARM APPIDIN Application ID * possible values: 1 = FTP Server Program C PARM USRIN 999 User ID C PARM USRLENIN Length of User ID C PARM AUTIN 999 Authentication Strg C PARM AUTLENIN Length of Auth. Strg C PARM IPADDRIN 15 Client IP Address C PARM IPLENIN Length of IP Address * Return parameters: C PARM RETCDOUT Return Code (Out) * possible values: 0 = Reject Logon * 1 = Continue Logon * 2 = Continue Logon, * override current * library * 3 = Continue Logon, * override user prf, * password * 4 = Continue Logon, * override user prf, * password, current * library * 5 = Accept logon with * user prf returned * 6 = Accept logon with * user prf returned, * override current * library C PARM USRPRFOUT 10 User Profile (Out) C PARM PASSWDOUT 10 Password (Out) C PARM CURLIBOUT 10 Current Lib. (Out) C/EJECT ******************************************************************** * THE MAIN PROGRAM * ******************************************************************** * * Check for ANONYMOUS user * 1 C USRLENIN SUBST(P) USRIN:1 User 10 C User IFEQ Anonym C MOVEL Anonym USRPRFOUT * * Check if the user entered something as a e-mail address * C AUTLENIN IFGT *ZERO E-mail addr. entered * * Check if the E-mail address is a valid one * C Z-ADD 0 i 3 0 C '@' SCAN AUTIN:1 i Valid E-mail address * contains @ character * C i IFGT 0 Found a '@' C AUTLENIN SUBST(P) AUTIN:1 Email 30 C Z-ADD 5 RETCDOUT Accept Logon * * Log Anonymous FTP Logon to message queue QSYSOPR * (The logging should be done to a secure physical file!!!!!!!) * C Text1 CAT(p) Email:0 Message 43 C Message CAT(p) Text2:0 Message C Message DSPLY 'QSYSOPR' * C ELSE Invalid E-mail addr C Z-ADD 0 RETCDOUT Reject Logon attempt C ENDIF * C ELSE No E-mail address C Z-ADD 0 RETCDOUT Reject Logon attempt C ENDIF * C ELSE * * Any Other User: Proceed with Normal Logon Processing, but the Client address must not belong * to network 10.xxx.xxx.xxx * C 3 SUBST IPADDRIN:1 TheNet 3 C TheNet IFEQ InvalidNet Wrong Net C Z-ADD 0 RETCDOUT Reject Logon attempt C ELSE Right Net C Z-ADD 1 RETCDOUT Continue with Logon C ENDIF * C ENDIF * C EVAL *INLR = *ON C RETURN

 

Parent topic:

FTP server logon exit point