Skip to main content
Version: 8.1

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

TypeParameterDescription
StringusernameThe username to try and switch to.
StringpasswordThe password to authenticate with.
EventObjecteventIf 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]
BooleanhideErrorIf 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

Code Snippet
# 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()

Keywords

system security switchUser, security.switchUser