Security Request Error
Understanding the SecurityRequestError
exception.
Any time the SAF Return Code is greater than
4
, aDownstreamFataError
will be raised.
A SAF Return Code of
4
from IRRSMO00 is indicative of a failure with one or more of the RACF operations performed by IRRSMO00, and pyRACF will always raise aSecurityRequestError
to bring attention to these failures.
When the SAF Return Code of a Security Result returned by IRRSMO00 is equal to 4
, a SecurityRequestError
will be raised to indicate that the request failed. A SecurityRequestError
can be handled as follows.
Python Script
from pyracf import UserAdmin
from pyracf import SecurityRequestError
user_admin = UserAdmin()
try:
user_admin.alter("squidwrd", traits={"base:password": "passwordtoolong"})
except SecurityRequestError as e:
return_code = e.result["securityResult"]["user"]["returnCode"]
reason_code = e.result["securityResult"]["user"]["reasonCode"]
messages = "\n".join(e.result["securityResult"]["user"]["commands"][0]["messages"])
print(f"Return Code: {return_code}")
print(f"Reason Code: {reason_code}")
print(f"Messages:\n\n{messages}")
Console Output
Return Code: 4
Reason Code: 0
Messages:
IKJ56717I INVALID PASSWORD
Security Result Dictionary as JSON
{
"securityResult": {
"user": {
"name": "SQUIDWRD",
"operation": "set",
"requestId": "UserRequest",
"info": [
"Definition exists. Add command skipped due to precheck option"
],
"commands": [
{
"safReturnCode": 8,
"returnCode": 16,
"reasonCode": 8,
"image": "ALTUSER SQUIDWRD PASSWORD (passwordtoolong)",
"messages": [
"IKJ56717I INVALID PASSWORD"
]
}
]
},
"returnCode": 4,
"reasonCode": 0,
"runningUserid": "testuser"
}
}