如何於 RPG 中檢核使用者密碼?
檢核使用者密碼的程序 VRYUSRPWD
File : QRPGLESRC
Member : VRYUSRPWD
Type : RPGLE
* ===================================================================
* = Service Program... VRYUSRPWD =
* = Description....... Verify User Password =
* = =
* = Compile........... CrtRPGMod Module(YourLib/VRYUSRPWD) =
* = SrcFile(YourLib/YourSrcFile) =
* ===================================================================
H NoMain
* ===================================================================
* = Prototypes =
* ===================================================================
* -------------------------------------------------------------------
* - VfyUsrPwd - Veryify user password -
* -------------------------------------------------------------------
D VfyUsrPwd PR 1N
D 10 Value
D 10 Value
D 272 Options( *NoPass )
* -------------------------------------------------------------------
* - GetProfileHdl - Get profile handle API -
* -------------------------------------------------------------------
D GetProfileHdl PR ExtPgm( 'QSYGETPH' )
D 10
D 10
D 12
D 272
* -------------------------------------------------------------------
* - RlsProfileHdl - Release profile handle API -
* -------------------------------------------------------------------
D RlsProfileHdl PR ExtPgm( 'QSYRLSPH' )
D 12
D 272
* ===================================================================
* = Procedure..... VfyUsrPwd =
* = Description... Verify user password =
* ===================================================================
P VfyUsrPwd B Export
D PI 1N
D UsrPrf 10 Value
D Password 10 Value
D APIError 272 Options( *NoPass )
* -------------------------------------------------------------------
* - Data definitions -
* -------------------------------------------------------------------
D Hdl S 12
D NoAPIError C Const( *Zero )
D APIErrorPassed S 1N
D APIErrorDS DS
D BytesProvided 10I 0 Inz( %Size( APIErrorDS ) )
D BytesAvail 10I 0 Inz( *Zero )
D MsgID 7 Inz( *Blanks )
D Reserved 1 Inz( X'00' )
D MsgDta 256 Inz( *Blanks )
* -------------------------------------------------------------------
* - Determine whether API error parameter was passed -
* -------------------------------------------------------------------
C If %Parms > 2
C Eval APIErrorPassed = *On
C EndIf
* -------------------------------------------------------------------
* - Retrieve profile handle -
* -------------------------------------------------------------------
C Reset APIErrorDS
C CallP GetProfileHdl(
C UsrPrf :
C Password :
C Hdl :
C APIErrorDS
C )
C If BytesAvail <> NoAPIError
C ExSr ReturnError
C EndIf
* -------------------------------------------------------------------
* - Release profile handle -
* -------------------------------------------------------------------
C Reset APIErrorDS
C CallP RLSProfileHdl(
C Hdl :
C APIErrorDS
C )
C If BytesAvail <> NoAPIError
C ExSr ReturnError
C EndIf
C Return *Off
* -------------------------------------------------------------------
* - Subroutine.... ReturnError -
* - Description... Return error condition to caller -
* -------------------------------------------------------------------
C ReturnError BegSr
C If APIErrorPassed
C Eval APIError = APIErrorDS
C EndIf
C Return *On
C EndSr
P VfyUsrPwd E
檢核使用者密碼程序的使用範例
File : QRPGLESRC
Member : VRYUSRPWDT
Type : RPGLE
Usage : 此範例程式包含三種呼叫方式,可擇一使用,
但最好使用有包含錯誤訊息的呼叫方式(方式二及方式三)。
可在應用程式某些中有需要再次確認密碼時,要求使用者再次輸入密碼,並呼叫
確認密碼程序 VRYUSRPWD 以檢核使用者密碼輸入正確與否。
* ===================================================================
* = Program....... VRYUSRPWDT =
* = Description... Sample demonstrating use of procedure =
* = VRYUSRPWD in applications =
* = =
* = Compile....... CrtRPGMod Module(YourLib/VRYUSRPWDT) =
* = SrcFile(YourLib/YourSrcFile) =
* = CrtPgm Pgm(YourLib/VRYUSRPWDT) =
* = Module(YourLib/VRYUSRPWDT VRYUSRPWD) =
* = ActGrp(*New) =
* ===================================================================
D VfyUsrPwd PR 1N
D 10 Value
D 10 Value
D 272 Options( *NoPass )
D UsrPrf S 8
D Password S 10
D RtnCode S 1N
D PSDS SDS
D User 254 263
D APIErrorDS DS
D BytesProvided 10I 0 Inz( %Size( APIErrorDS ) )
D BytesAvail 10I 0 Inz( *Zero )
D MsgID 7 Inz( *Blanks )
D Reserved 1 Inz( X'00' )
D MsgDta 256 Inz( *Blanks )
C Eval UsrPrf = User
* call method 1 without API Error Structure
C Eval RtnCode = VfyUsrPwd(
C UsrPrf :
C Password
C )
* call method 2 with API Error Structure
C Eval RtnCode = VfyUsrPwd(
C UsrPrf :
C Password :
C APIErrorDS
C )
* call method 3 use procedure
C If VfyUsrPwd(
C UsrPrf :
C Password :
C APIErrorDS
C )
* Insert error handling code for failed verification
C EndIf
C Eval *InLr = *On
參考資料
檢核使用者密碼程序所使用的 API
1. Get Profile Handle (QSYGETPH)
This API obtains a profile handle.
You can find documentation for API QSYGETPH at
http://publib.boulder.ibm.com/pubs/html/as400/v5r1/ic2924/index.htm?info/apis/QSYGETPH.htm
2. Release Profile Handle (QSYRLSPH)
This API releases a profile handle.
You can find documentation for API QSYRLSPH at
http://publib.boulder.ibm.com/pubs/html/as400/v5r1/ic2924/index.htm?info/apis/QSYRLSPH.htm
A blog about IBM i (AS/400), MQ and other things developers or Admins need to know.
星期二, 10月 31, 2023
2001-09-14 如何於 RPG 中檢核使用者密碼?
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言