Stuff
OS/400 Edition
Volume 1, Number 16 -- September 12, 2002

A Telnet Exit Program Tells You Who's Knocking At Your Door


by Shannon O'Donnell

Sometimes you need to know when a particular user or group of users is signing on to your system, or you want to direct certain messages to a certain group of users when they log on. But to do so, the first thing you need is a way to know who is logging on to your system. You can accomplish all of that, as well as a whole host of other things, by using of a Telnet exit program.

display

Exit Points

Like many other system functions, such as FTP, Telnet access can be monitored by attaching a program to the Telnet server's exit point. Before we go any further, let's define a couple of terms.

Telnet is an application, just like FTP, that is based on the TCP/IP protocol. Generally speaking, you use Telnet to connect one computer to another via TCP/IP. Telnet exists, in one form or another, on pretty much every computing platform in the world. In fact, you may be surprised to learn that a basic Telnet application has been shipping with Microsoft Windows for many years. To access it, click the Window's Start button, then click the Run button, and, finally, type in the command "telnet" and click OK.

IBM has been using Telnet on the AS/400 since way back when. In fact, IBM's Client Access Express PC5250 emulation product uses an advanced (or specialized) version of Telnet, called TN5250, to allow you to start an emulation session with the AS/400.

An exit point is a spot defined within various IBM applications where you can attach your own programs in order to perform your own customized processing in those applications. For example, you might attach a CL program to the FTP exit point to track FTP activity. Each exit point has a predefined parameter list, which must also exist in your custom application. It is through this parameter list that the application--in our case, the Telnet application--will pass various information to your custom application, and into which you may pass information back to the IBM application.

You can view and work with all the exit points on your system by going to an AS/400 command line and entering the Work with Registration Information (WRKREGINF) command. The exit point that we will be working with for our sample application is named:

Parameter List

As I mentioned earlier, your exit point application must use a predefined parameter list in order to communicate correctly with the IBM application (Telnet, in this case). The problem for most of us non-IBM programmers comes in trying to figure out what the parameter list for a given IBM exit point should be. Exit point parameter information is not widely published for some reason, and as a result, when you want to write an exit program for an IBM exit point, you usually end up having to scour IBM's Web site, AS/400 forums, and other nooks and crannies until you find what you need. 'But there is another way to find the parameter list information you need without a lot of searching.

If you install the System Openness Includes licensed program, which is included on the OS/400 installation CD's that come with your AS/400, you will get a library named QSYSINC installed on your system. Inside the QSYSINC library is a file named QRPGLESRC (as well as files named QRPGSRC, QCBLLESRC, and the like). In the QRPGLESRC file, you will find source members for pretty much every IBM exit point.

When you look at a source member, you'll see that it contains sample source of the exit point parameter list. When you want to write your own exit point application, you can simply copy the source from the sample source members in library QSYSINC into your own app, and you're ready to go. The one thing you won't find, sadly, is any documentation on how to use the parameter list or the particular exit point that it is for, so proceed with caution, and test, test, test!

For our Telnet exit point application, we'll use the sample source defined in a member named ETGDEVEX. Create a new RPG IV source member in your own library and copy the ETGDEVEX source into it.

Sample Telnet Application

Once you have the parameter list, the rest of your work is really easy. While not heavily documented, the sample source you get from QSYSINC does include some very basic information about each parameter item. Usually, this is enough that you can easily figure out how to use it for your own needs.

For example, a Telnet application might want to log who is signing on to your AS/400. You can get this information from the parameter named ETGUP. When the Telnet server passes control to the exit point application (your program), the field named ETGUP will contain the user ID of the person attempting to log on to your system. Based on that value, you may choose to either allow or disallow this person access. If you do allow access, you may want to log, to a database, who is signing on, as well as the date and time. In addition, you may want to send a message to a particular user, or group of users, when they log on. Perhaps some sort of tickler system that reminds them of upcoming appointments. Use your imagination. You can probably think of a lot of uses for an application such as this.

Attach to Exit Point

After you've written your custom exit point application, you need to attach it to the correct exit point. Use the WRKREGINF command to display the list of available exit points and scroll down until you see the exit point named QIBM_QTB_DEVINIT. This is the "Telnet Device Initialization" exit point. This is where you'll attach your own program. Follow the on-screen instructions for attaching your exit program to this exit point.

If you also want to track when your users are logging off of your system, you can repeat the steps described above and write an exit point program for the QIBM_QTG_DEVTERM ("Telnet Device Termination") exit point. The program attached to this exit point will be called every time someone logs off of your AS/400.

Try It

You now have the information you need to start writing exit point programs to create a very tightly controlled system. You've been given a powerful gift. Use it wisely, grasshopper.


Sponsored By
WORKSRIGHT SOFTWARE

On June 30, 2002,
$$$$$$$$    Postal Rates went UP!    $$$$$$$$

On July 1, 2002,
$$$$$    you wanted your postage bill to go down.    $$$$$

We have the solution! CASS certify your mailing names and addresses and presort your outgoing mail and save. Our CASS certification software ensures that your address files have valid ZIP Code and address information. Our presort software ensures that you can properly prepare you mail for delivery to your Post Office.

WorksRight Software, Inc. is the number-one source for iSeries and AS/400 CASS, presort, ZIP Code, and area code software and data.

Visit our Web site - www.worksright.com - to learn more about our CASS and presorting software, or contact WorksRight Software, Inc., phone 601-856-8337,
e-mail software@worksright.com .


THIS ISSUE
SPONSORED BY:

ASNA
T.L. Ashford
ASC
COMMON
Profound Logic Software
WorksRight Software


BACK ISSUES

TABLE OF CONTENTS
Java by Example with WebSphere Development Studio Client

DB2 Library Contents in Operations Navigator

Processing Command-Line Arguments in Qshell Scripts

How to Create Custom JSP Tags

Calling PC Commands from RPG

A Telnet Exit Program Tells You Who's Knocking At Your Door


Editors
Shannon O'Donnell
Kevin Vandever

Managing Editor
Shannon Pastore

Contributing Editors:
Howard Arner
Joe Hertvik
Ted Holt
David Morris
Richard Shaler

Publisher and
Advertising Director:

Jenny Thomas

Contact the Editors
Do you have a gripe, inside dope or an opinion?
Email the editors:
editors@itjungle.com



Last Updated: 9/12/02
Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.