system.security.switchUser
This function is used in Python Scripting.
Description​
Attempts to switch the current user on the fly. If the given username and password fail, this function will return false. If it succeeds, then all currently opened windows are closed, the user is switched, and windows are then re-opened in the states that they were in.
If an event object is passed to this function, the parent window of the event object will not be re-opened after a successful user switch. This is to support the common case of having a switch-user screen that you want to disappear after the switch takes place.
Client Permission Restrictions​
This scripting function has no Client Permission restrictions.
Syntax​
system.security.switchUser(username, password, [event], [hideError])
Parameters​
Type | Parameter | Description |
---|---|---|
String | username | The username to try and switch to. |
String | password | The password to authenticate with. |
EventObject | event | If specified, the enclosing window for this event's component will be closed in the switch user process. Refer to the list of Event objects. [optional] |
Boolean | hideError | If true (1), no error will be shown if the switch user function fails. Default is False. [optional] |
Returns​
Boolean - False if the switch user operation failed, True otherwise.
Scope​
Vision Client
Code Example​
# This script would go on a button in a popup window used to switch users without logging out of the client.
# Pull the username and password from the input components
uname = event.source.parent.getComponent("Username").text
pwd = event.source.parent.getComponent("Password").text
# Call switchUser. The event object is passed to this
# function so that if the username and password work,
# this window will be closed before the switch occurs.
success= system.security.switchUser(uname,pwd,event)
# If the login didn't work, give input focus back to the
# username component, so that the user can try again
if not success:
event.source.parent.getComponent("Username").requestFocusInWindow()