switchUser function troubles

Hi everyone!

I try add custom login screen using system.security.switchUser() function on login button, the following code bellow:

uname = event.source.parent.getComponent('Username').text
pwd = event.source.parent.getComponent('Password').text
success = system.security.switchUser(uname, pwd, event)

if success:
    system.util.invokeLater(switchWin, 500)
else:
    system.gui.massageBox('Access denied. Incoreect username or password', 'Auth')

during login next exception appears:
java.lang.IllegalArgumentException: Cannot create PySting with non-byte value
<…>

also I’m using ActiveDirectory user source

What was done to diagnose problem:

  1. audit journal - on login i have AuditStatus[0x00000000, Severity=Good, Subcore=NotSpecified], also i tried wrong creditals and there was on error code, so AD works well
  2. switch login screen to default vision login - success with the same creditals
  3. switch user source to internal and added user with same name and password in it - success
  4. validate user source on gateway: returned correct info

How can i fix that?
Thank you

Welcome to the forum. Tip: use the </> code formatting button to presever indent and to apply syntax highlighting for blocks of code.

If this is your actual script, there's a breaking typo (should be system.gui.messageBox), but that doesn't explain the actual error you're seeing.

The only thing that will help diagnose that error is the actual stacktrace that you elided when you pasted it here. Please post the full error message.

Ohh, excuse me that was a typo
full error message bellow:

java.lang.IllegalArgumentException: Cannot create PyString with non-byte value
	at org.python.core.PyString.<init>(PyString.java:57)
	at org.python.core.PyString.<init>(PyString.java:70)
	at org.python.core.PyString.<init>(PyString.java:74)
	at org.python.core.Py.newString(Py.java:647)
	at com.inductiveautomation.factorypmi.application.script.builtin.SecurityUtilities.rolesToTuple(SecurityUtilities.java:293)
	at com.inductiveautomation.factorypmi.application.script.builtin.SecurityUtilities.login(SecurityUtilities.java:81)
	at com.inductiveautomation.factorypmi.application.script.builtin.SecurityUtilities.switchUser(SecurityUtilities.java:102)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:188)
	at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:524)
	at org.python.core.PyObject.__call__(PyObject.java:497)
	at org.python.core.PyObject.__call__(PyObject.java:501)
	at org.python.pycode._pyx23.f$0(<event:actionPerformed>:32)
	at org.python.pycode._pyx23.call_function(<event:actionPerformed>)
	at org.python.core.PyTableCode.call(PyTableCode.java:171)
	at org.python.core.PyCode.call(PyCode.java:18)
	at org.python.core.Py.runCode(Py.java:1614)
	at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:782)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:206)
	at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:297)
	at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:57)
	at com.sun.proxy.$Proxy52.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
	at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.Component.processEvent(Unknown Source)
	at java.desktop/java.awt.Container.processEvent(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
	at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)

Ignition v(Dev Version)
Java: Azul Systems, Inc. 11.0.7

This is a bug that’s fixed in 8.1.2.

I can’t tell what version you’re using, but it looks like a (very old) nightly. You should update to the latest stable 8.1 release as soon as possible.