Skip to main content
Version: 7.9

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.
BooleanhideErrorIf true (1), no error will be shown if the switch user function fails. (default: 0)

Returns

boolean - false(0) if the switch user operation failed, true (1) otherwise.

Scope

Client

Code Examples

Example #1
# 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()