/********************************************************************/ /* CHKPDWC - Check a user profile / password for validity */ /* */ /* Copyright 2006, Craig Pelkie, ALL RIGHTS RESERVED */ /* craig@web400.com 2006-08-16 */ /* */ /********************************************************************/ /* You are allowed to modify and use this program for any purpose */ /* that you see fit, with the express restriction that you shall */ /* retain the copyright notice shown above in all copies of the */ /* program that you create. */ /* */ /* This program has not been exhaustively tested. Your usage of */ /* this program is at your own risk. Craig Pelkie expressly */ /* disclaims any warranty of merchantability or fitness for */ /* any purpose and shall not be liable for any damages that */ /* may result from your use of this program. */ /********************************************************************/ /* Parameters */ /* */ /* IN CHAR(10) &userId - the user ID (user profile) to check */ /* IN CHAR(10) &passWord - the password for the user ID */ /* */ /* OUT DEC(5 0) &returnCode - the return code */ /* 1 - CPF2203: User profile not correct */ /* 2 - CPF2204: User profile not found */ /* 3 - CPF2213: Not able to allocate user profile */ /* 4 - CPF2225: Not able to allocate internal system object */ /* 5 - CPF22E2: Password not correct for user profile */ /* 6 - CPF22E3: User profile is disabled */ /* 7 - CPF22E4: Password for user profile has expired */ /* 8 - CPF22E5: No password associated with user profile */ /* 9 - CPF22E6: Maximum number of profile handles generated */ /* 10 - CPF22E9: *USE authority to user profile required */ /* 11 - CPF4AB8: Insufficient authority for user profile */ /* 9999 - CPF9999: "catch all" error message */ /********************************************************************/ chkpwdc: pgm parm(&userId + &passWord + &returnCode) /********************************************************************/ /* (A) */ /* Parameter definitions */ /* */ /* &userId - the user ID (user profile) to check */ /* &passWord - the password for the user ID */ /* &returnCode - the return code */ /********************************************************************/ dcl &userId *char 10 dcl &passWord *char 10 dcl &returnCode *dec (5 0) /********************************************************************/ /* (B) */ /* Program work field definitions */ /* */ /* &bBytesAv - bytes available (binary field) */ /* &bBytesProv - bytes provided (binary field) */ /* &bPwdCcsid - password CCSID (binary field) */ /* &pPwdLength - password length (binary field) */ /* &errorCode - API error code structure */ /* &errorMsg - the error message ID returned in &errorCode */ /* &hProfile - profile handle */ /* */ /* &bytesAv - bytes available (returned) in &errorCode */ /* &bytesProv - bytes provided for &errorCode */ /* &pwdCcsid - password CCSID */ /* &pwdLength - length of password parameter */ /********************************************************************/ dcl &bBytesAv *char 4 dcl &bBytesProv *char 4 dcl &bPwdCcsid *char 4 dcl &bPwdLength *char 4 dcl &errorCode *char 64 dcl &errorMsg *char 7 dcl &hProfile *char 12 dcl &bytesAv *dec (5 0) dcl &bytesProv *dec (5 0) value(64) dcl &pwdCcsid *dec (5 0) value( 0) dcl &pwdLength *dec (5 0) value(10) /********************************************************************/ /* (C) */ /* Error message constants - errors returned from QSYGETPH API */ /********************************************************************/ /* CPF2203 - User profile &1 not correct */ dcl &ERR_2203 *char 7 value('CPF2203') /* CPF2204 - User profile &1 not found */ dcl &ERR_2204 *char 7 value('CPF2204') /* CPF2213 - Not able to allocate user profile &1 */ dcl &ERR_2213 *char 7 value('CPF2213') /* CPF2225 - Not able to allocate internal system object */ dcl &ERR_2225 *char 7 value('CPF2225') /* CPF22E2 - Password not correct for user profile &1 */ dcl &ERR_22E2 *char 7 value('CPF22E2') /* CPF22E3 - User profile &1 is disabled */ dcl &ERR_22E3 *char 7 value('CPF22E3') /* CPF22E4 - Password for user profile &1 has expired */ dcl &ERR_22E4 *char 7 value('CPF22E4') /* CPF22E5 - No password associated with user profile &1 */ dcl &ERR_22E5 *char 7 value('CPF22E5') /* CPF22E6 - Maximum number of profile handles have been ... */ dcl &ERR_22E6 *char 7 value('CPF22E6') /* CPF22E9 - *USE authority to user profile &1 required */ dcl &ERR_22E9 *char 7 value('CPF22E9') /* CPF4AB8 - Insufficient authority for user profile &1 */ dcl &ERR_4AB8 *char 7 value('CPF4AB8') /********************************************************************/ /* (D) */ /* Return code values */ /********************************************************************/ /* Normal return, no error (user ID / password validated) */ dcl &RC_OK *dec (5 0) value(0) /* RC_2203 - User profile &1 not correct */ dcl &RC_2203 *dec (5 0) value(1) /* RC_2204 - User profile &1 not found */ dcl &RC_2204 *dec (5 0) value(2) /* RC_2213 - Not able to allocate user profile &1 */ dcl &RC_2213 *dec (5 0) value(3) /* RC_2225 - Not able to allocate internal system object */ dcl &RC_2225 *dec (5 0) value(4) /* RC_22E2 - Password not correct for user profile &1 */ dcl &RC_22E2 *dec (5 0) value(5) /* RC_22E3 - User profile &1 is disabled */ dcl &RC_22E3 *dec (5 0) value(6) /* RC_22E4 - Password for user profile &1 has expired */ dcl &RC_22E4 *dec (5 0) value(7) /* RC_22E5 - No password associated with user profile &1 */ dcl &RC_22E5 *dec (5 0) value(8) /* RC_22E6 - Maximum number of profile handles have been ... */ dcl &RC_22E6 *dec (5 0) value(9) /* RC_22E9 - *USE authority to user profile &1 required */ dcl &RC_22E9 *dec (5 0) value(10) /* RC_4AB8 - Insufficient authority for user profile &1 */ dcl &RC_4AB8 *dec (5 0) value(11) /* RC_9999 - "Function check" (default message) */ dcl &RC_9999 *dec (5 0) value(9999) /********************************************************************/ /* (E) */ /* Convert decimal values to binary for API call */ /********************************************************************/ chgvar %bin(&bBytesProv) &bytesProv chgvar %bin(&bPwdCcsid ) &pwdCcsid chgvar %bin(&bPwdLength) &pwdLength /********************************************************************/ /* (F) */ /* Initialize the error code structure "bytes provided" field to */ /* the total length of the error code structure */ /********************************************************************/ chgvar %sst(&errorCode 1 4) value(&bBytesProv) /********************************************************************/ /* (G) */ /* Call Get Profile Handle API */ /********************************************************************/ call qsygetph parm(&userId + &passWord + &hProfile + &errorCode + &bPwdLength + &bPwdCcsid) /********************************************************************/ /* (H) */ /* Check for "bytes available" *GT 0, indicates error on call */ /********************************************************************/ chgvar &bBytesAv value(%sst(&errorCode 5 4)) chgvar &bytesAv value(%bin(&bBytesAv)) /********************************************************************/ /* (I) */ /* No error, set return code to RC_OK, release the profile handle */ /********************************************************************/ if (&bytesAv *eq 0) then(do) chgvar &returnCode &RC_OK call qsyrlsph parm(&hProfile) enddo /********************************************************************/ /* (J) */ /* Error, extract error message ID from &errorCode, set return code */ /********************************************************************/ else do chgvar &returnCode &RC_9999 /* default RC value */ chgvar &errorMsg %sst(&errorCode 9 7) if (&errorMsg *EQ &ERR_2203) + then(chgvar &returnCode &RC_2203) if (&errorMsg *EQ &ERR_2204) + then(chgvar &returnCode &RC_2204) if (&errorMsg *EQ &ERR_2213) + then(chgvar &returnCode &RC_2213) if (&errorMsg *EQ &ERR_2225) + then(chgvar &returnCode &RC_2225) if (&errorMsg *EQ &ERR_22E2) + then(chgvar &returnCode &RC_22E2) if (&errorMsg *EQ &ERR_22E3) + then(chgvar &returnCode &RC_22E3) if (&errorMsg *EQ &ERR_22E4) + then(chgvar &returnCode &RC_22E4) if (&errorMsg *EQ &ERR_22E5) + then(chgvar &returnCode &RC_22E5) if (&errorMsg *EQ &ERR_22E6) + then(chgvar &returnCode &RC_22E6) if (&errorMsg *EQ &ERR_22E9) + then(chgvar &returnCode &RC_22E9) if (&errorMsg *EQ &ERR_4AB8) + then(chgvar &returnCode &RC_4AB8) enddo /********************************************************************/ /* (K) */ /* Dump program - uncomment for testing/debugging */ /********************************************************************/ /* dmpclpgm */ endpgm