Saturday, October 4, 2014

How to impose custom password validation rules

If you want to create advanced password validation logic, Sage X3 has an entry point dedicated to this. To show how it works, we will create a rule that will reject a password not containing at least one digit.

The entry point we are going to use is called CTLPASSE and is located in the PASSE process. So first you need to go to your Entry points function (GESAPE) and declare the PASSE process like this:


ZCTLPASS is the name of the file that will contain the entry point code. Of course, you can give it another name. Here is the code for this file:

$ACTION
Case ACTION
    When "CTLPASSE" : Gosub CTLPASSE
Endcase
Return

$CTLPASSE
If !pat(PASSE, "*#*")
    Infbox("Error: The password must contain at least one digit.")
    GPE=1
Endif
Return

In the entry point, we are passed the new password in the PASSE variable. To reject the new password, we must set GPE to 1. In the above example, we do this when the password does not contain at least one digit. We check for this condition by pattern matching using the pat instruction. This is just a simple check, but the checks can be as elaborated as you want, so you can create any number of advanced password validation rules.

You might need to logout of X3 and login again before the entry point becomes active.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.