7.7. Validating a user-id and password

The Get Profile Handle API (QSYGETPH) will be used to check a user-id and password.

The QSYGETPH API is listed under "Security APIs" in the IBM manuals, and you'll find it at this location: http://publib.boulder.ibm.com/pubs/html/as400/v4r5/ic2924/info/apis/QSYGETPH.htm

The manual page tells us that the parameters to the QSYGETPH API look like this:

Required Parameter Group:
1 User ID Input Char(10)
2 Password Input Char(10)
3 Profile handle Output Char(12)
Optional parameter:
4 Error code I/O Char(*)

So, our prototype in RPG will look like this:

         D GetProfile      PR                  ExtPgm('QSYGETPH')
         D   UserID                      10A   const
         D   Password                    10A   const
         D   Handle                      12A
         D   ErrorCode                32766A   options(*varsize)

Please add that to your JOBINFO_H member.

Or, if you prefer, you could download my copy of JOBINFO_H, available here: http://www.scottklement.com/rpg/socktut/qrpglesrc.jobinfo_h

When we call this API, we will pass it a user-id and password, and it'll either return a "profile handle" in the Handle parameter, or it'll give us an error in the ErrorCode parameter.

We'll use this profile handle for the API that we discuss in the next topic.

To call the GetProfile API, we'll do something like this:

         c                   callp     GetProfile(UserID: Passwd: Handle:
         c                                dsEC)
         c                   if        dsECBytesA > 0
         C** handle "invalid user profile" error
         c                   endif