ScriptDeviceUserManagement

class ScriptDeviceUserManagement.DeviceUserManagementFlags(value)

Bases: Enum

Flags for the entire _3S.CoDeSys.Core.Online.IDeviceUserList, the entire _3S.CoDeSys.Core.Online.IDeviceGroupList, a single _3S.CoDeSys.Core.Online.IDeviceUser, or a single _3S.CoDeSys.Core.Online.IDeviceGroup.

Edit = (1,)

If set, the particular _3S.CoDeSys.Core.Online.IDeviceUser or _3S.CoDeSys.Core.Online.IDeviceGroup can be edited.

AddMember = (2,)

If set, users or groups can be added to the particular _3S.CoDeSys.Core.Online.IDeviceGroup.

RemoveMember = (4,)

If set, users or groups can be removed from the particular _3S.CoDeSys.Core.Online.IDeviceGroup.

Create = (8,)

If set, new users can be created in the particular _3S.CoDeSys.Core.Online.IDeviceUserList, or new groups can be created in the particular _3S.CoDeSys.Core.Online.IDeviceGroupList.

Delete = (16,)

If set, existing users can be deleted from the particular _3S.CoDeSys.Core.Online.IDeviceUserList, or existing groups can be deleted from the particular _3S.CoDeSys.Core.Online.IDeviceGroupList

RemoveAllMembers = (32,)

If set, all existing users can be removed from the particular _3S.CoDeSys.Core.Online.IDeviceUserList. If not set, at least one user must be available in this group.

EditRights = (64,)

If set, permissions for the particular _3S.CoDeSys.Core.Online.IDeviceGroup can be changed

Owner = (128,)

If set, the particular _3S.CoDeSys.Core.Online.IDeviceGroup is the owner group

NameEditable = (256,)

If set, the name of the particular _3S.CoDeSys.Core.Online.IDeviceUser or _3S.CoDeSys.Core.Online.IDeviceGroup is editable.

PasswordUpToDate = (4096,)

If this flag is not set, a new password needs to be set by the user at the next login.

PasswordEditable = (8192,)

If this flag is set, the user can change his own password.

All = 4294967167

All flags together except flag Owner.

class ScriptDeviceUserManagement.ScriptDeviceUserManagement

Bases: object

This object represents the user management on a given device.

property online_device

Gets the online device this user management was created from.

Return type:

ScriptOnlineDevice

property users

Gets the users on the device.

Modifications of this list will take place offline and come into effect by downloading the user management to the device.

Return type:

ScriptDeviceUserList

property groups

Gets the groups on the device.

Modifications of this list will take place offline and come into effect by downloading the user management to the device.

Return type:

ScriptDeviceGroupList

reload_from_program()

Reloads the user management contents from the device object in the project.

store_to_project()

Writes the current contents of the user management back to the device object in the project.

You should always use this method to persist your changes into the project. If you don’t call this method, the project will contain an outdated state.

upload()

Uploads the user and group information from the device.

download()

Downloads the user and group information to the device.

load(element: XmlElement)

Loads the contents of the given XML element into this user management object.

Parameters:

element (XmlElement) – The element.

save(writer=None)

Saves the contents of this user management object as XML into an System.Xml.XmlWriter.

Parameters:

writer (XmlWriter) – The writer.

class ScriptDeviceUserManagement.ScriptDeviceUserList(iterable=(), /)

Bases: list

Represents a list of script device users.

property flags

Gets flags concerning the entire user list.

Return type:

DeviceUserManagementFlags

add(name)

Adds a new user with the specified name.

Parameters:

name (str) – The name of the new user.

Raises:
  • ArgumentException – A user with the specified name already exists.

  • NotSupportedException – Adding new users is not supported. Check flags for the DeviceUserManagementFlags.Create flag in advance.

Return type:

ScriptDeviceUser

Returns:

The newly created user.

remove(name)

Removes the user with the specified name.

Parameters:

name (str) – The name of the existing user.

Raises:

NotSupportedException

Return type:

bool

Returns:

True if the user existed and was removed, otherwise False

clear()

Removes all users.

Raises:

NotSupportedException – Deleting existing users is not supported. Check ScriptDeviceUser.flags for the DeviceUserManagementFlags.Delete flag in advance. –OR– Removing a member from a group in which the specified user is a member of is not supported. Check ScriptDeviceGroup.flags of all affected groups for the DeviceUserManagementFlags.RemoveMember flag in advance.

class ScriptDeviceUserManagement.ScriptDeviceGroupList(iterable=(), /)

Bases: list

A list of groups on the device.

property flags

Gets flags concerning the entire group list.

Return type:

DeviceUserManagementFlags

add(name)

Adds a new group with the specified name.

Parameters:

name (str) – The name of the group.

Return type:

ScriptDeviceGroup

Returns:

The newly created group, or None if a group with the specified name already exists.

remove(name)

Removes the group with the specified name.

Parameters:

name (str) – The name of the existing group.

Return type:

bool

Returns:

True if the group existed and was removed, otherwise False

clear()

Removes all groups.

class ScriptDeviceUserManagement.ScriptDeviceUser

Bases: object

An user on this device.

property flags

Gets flags concerning this particular user.

Return type:

DeviceUserManagementFlags

property name

Gets or sets the name of the user.

Raises:
  • NotSupportedException – Editing this user is not supported. Check flags for the DeviceUserManagementFlags.Edit flag in advance.

  • ArgumentException – A user with the specified name already exists.

Return type:

str

set_password(password)

Sets the password for this user.

Parameters:

password (str) – The password to set.

property password_hash

Gets or sets the encrypted password for this user.

Raises:

NotSupportedException – Editing this user is not supported. Check flags for the DeviceUserManagementFlags.Edit flag in advance.

Return type:

str

set_user_flags(flags)

Sets flags for the user.

Parameters:

flags (DeviceUserManagementFlags) – The flags to set.

class ScriptDeviceUserManagement.ScriptDeviceGroup

Bases: object

A group of users, which have common rights on the device.

property flags

Gets flags concerning this particular group.

Return type:

DeviceUserManagementFlags

property name

Gets or sets the name of the group.

Raises:
  • NotSupportedException – Editing this user is not supported. Check flags for the DeviceUserManagementFlags.Edit flag in advance.

  • ArgumentException – A group with the specified name already exists.

Return type:

str

property user_members

Gets the list of all user names which are members of this group.

This list can be modifed in-place to add or remove users from this group.

Return type:

list[string]

property group_members

Gets the list of all group names which are members of this group.

This list can be modifed in-place to add or remove groups from this group.

Return type:

list[str]

check_cyclic_membership(new_group_member)

Checks whether adding the specified group member would cause a cyclic membership dependency.

Parameters:

new_group_member (str) – The name of the new group membership to check.

Return type:

bool

Returns:

True if adding the specified group member would cause a cycle, otherwise False.