Add

Create a new z/OS userid.

UserAdmin.add()

def add(self, userid: str, traits: dict = {}) -> Union[dict, bytes]:

📄 Description

 

Only a subset of available Segments and Traits are considered Stable. See Segments and Traits for more details.

 

  • pyRACF encodes the data it passes to RACF in Code Page IBM-1047.
  • If you are entering a password or phrase with special or national characters, users logging on from terminals using differnt or international codepages may experience errors.
  • Please consult a list of invariant characters to use for such passwords or phrases if this applies to you.

 

Create a new z/OS userid.

📥 Parameters

  • userid
    The z/OS userid being created.

  • traits
    A dictionary of traits/attributes that should be given to the user on creation. See Traits to see what all of the valid User Traits are.

📤 Returns

  • Union[dict, bytes]
    Returns a Security Result dictionary or Security Request XML bytes if the UserAdmin.generate_requests_only class attribute is set to True.

❌ Raises

  • SecurityRequestError
    Raises SecurityRequestError when the SAF Return Code of a Security Result is equal to 4.
  • DownstreamFatalError
    Raises DownstreamFatalError when the SAF Return Code of a Security Result is greater than 4.
  • AddOperationError
    Raises AddOperationError when the z/OS userid cannot be added because it already exists.
  • SegmentTraitError
    Raises SegmentTraitError when the dictionary of traits/attributes provided contains one or more unknown traits.

💻 Example

The following example creates a new user with a userid of squidwrd and serveral traits/attributes as defined in the traits dictionary.

Python Script
from pyracf import UserAdmin
user_admin = UserAdmin()

traits = {
    "base:name": "Squidward",
    "base:password": "K29521IO",
    "base:owner": "leonard",
    "base:special": False,
    "base:operations": True,
    "omvs:uid": 2424,
    "omvs:home_directory": "/u/squidwrd",
    "omvs:default_shell": "/bin/sh",
}

user_admin.add("squidwrd", traits=traits)
Security Result Dictionary as JSON
{
  "securityResult": {
    "user": {
      "name": "SQUIDWRD",
      "operation": "set",
      "requestId": "UserRequest",
      "commands": [
        {
          "safReturnCode": 0,
          "returnCode": 0,
          "reasonCode": 0,
          "image": "ADDUSER SQUIDWRD ",
          "messages": [
            "ICH01024I User SQUIDWRD is defined as PROTECTED."
          ]
        },
        {
          "safReturnCode": 0,
          "returnCode": 0,
          "reasonCode": 0,
          "image": "ALTUSER SQUIDWRD  PASSWORD    (********) OWNER       (leonard) NOSPECIAL      OPERATIONS   OMVS     (HOME        ('/u/squidwrd') PROGRAM     ('/bin/sh'))"
        }
      ]
    },
    "returnCode": 0,
    "reasonCode": 0,
    "runningUserid": "testuser"
  }
}