system.user.addUser
This function is used in Python Scripting.
Description​
Adds a new user to a user source. Used in combination with getNewUser to create new user.
Client Permission Restrictions​
Permission Type: User Management
Client access to this scripting function is blocked to users that do not meet the role/zone requirements for the above permission type. This function is unaffected when run in the Gateway scope.
Syntax​
system.user.addUser(userSource, user)
Parameters​
Type | Parameter | Description |
---|---|---|
String | userSource | The user source to add a user to. If set to an empty string, the function will attempt to use the project's default user source (if called from a project). |
User | user | The user to add, as a User object. Refer also to the PyUser class. |
Returns​
UIResponse - A UIResponse object which contains lists of the errors, warnings, and information returned after the add attempt. The contents of the lists are accessible from the getter methods.
getWarns()
- Returns a list of warning messages that were encountered during the add.getErrors()
- Returns a list of error messages that were encountered during the add.getInfos()
- Returns a list of "info" messages that were encountered during the add.
These messages represent normal logging events that occurred during the add, and can be useful when trying to visualize the events that lead up to a failure.
Scope​
Gateway, Vision Client, Perspective Session
Code Examples​
# Get new user.
userToGet = system.user.getNewUser("AcmeWest", "mTrejo")
# Add some contact info.
contactInfo = {"email":"mTrejo@acmewest.com","sms": "5551234"}
userToGet.addContactInfo(contactInfo)
userToGet.set("password", "thisIsMyPassword")
# Adds a user to the the AcmeWest usersource.
system.user.addUser("AcmeWest", userToGet)