Switching user to another User source

is there a way to use the system.security.switchUser function to switch to a user in another user source.

i am currently using the default user source with a generic user to auto-login to the application, but there is some occasions that the user needs to login as them self to make a change to some parameters. i see that the validateUser function allows for you to check against another user source, is there a way to login against another user source?

I don’t see a way to accomplish a switch-user to a different user source, but you could use validateUser or getUserRoles to set some temporary property or open a window that permits the parameter editing you need.

I made a popup similar to the standard switch-user popup, but with the following code on the ‘OK’ button event:

roles = system.security.getUserRoles(username, password)
requiredRoles = event.source.parent.rolesToAccept.split(', ')

# If the login didn't work, give input focus back to the
# username component, so that the user can try again
if roles == None:
	system.gui.warningBox('Bad Login.', 'Authentication Error') 
	if len(set(roles).intersection(requiredRoles)) != 0:	# Allow
			window = system.gui.getWindow(event.source.parent.parentWindow)
		except ValueError:
			system.gui.warningBox("Original window was closed!", "Authentication Error")
		system.gui.warningBox("Account does not have the required roles!", "Authentication Error")

In the above example, rolesToAccept is a string popup parameter containing the roles to accept, separated by a comma (like: “Administrator, Manager, Supervisor”). If the user successfully logs in with an account with one of the required roles, then the openSesame() method of the parent window (which opened the popup) is called. In that method I open the ‘protected’ window.

In your situation, you’d just need any successful login with system.security.validateUser(username, password, authProfile=“YourOtherUserSource”) to call your ‘openSesame’ method.