使用脚本 API 管理设备用户权限

使用在线服务时所用的脚本

EcoStruxure Machine Expert 让您能够通过脚本 API 访问其多项在线服务。为了建立连接或稍后使用在线服务,系统中必须存储有效的凭据。

为在线服务提供特定凭据

对于多控制器项目,您可以通过在线设备或在线应用程序存储凭据。如果为连接提供了特定凭据,则系统将使用这些信息。

示例:

# create an "online device" to use online services
root_device = projects.primary.find("LMC_PacDrive", False)[0]
online_device = online.create_online_device(root_device)

# store credentials specific to this "online device"
online.set_specific_credentials(online_device, "my_user", "my_password")

# use of any online service
online_device.connect()

为在线服务提供缺省凭据

如果没有为连接提供特定凭据,系统会使用缺省凭据。

示例:

# create an "online device" to use online services 
root_device = projects.primary.find("LMC_PacDrive", False)[0] 
online_device = online.create_online_device(root_device)

# store default credentials
online.set_default_credentials("my_user", "my_password")

# use of any online service
online_device.connect()

用于强制密码更新的脚本

在以下情形下,在验证身份后,用户需要更改密码:

  • 首次登录到新控制器。

  • 将用户权限管理复位到缺省设置后首次连接。

  • 设备管理员针对特定用户强制执行了密码更新。

  • 根据控制器配置的过期超时,密码已过期。

EcoStruxure Machine Expert 不支持使用脚本 API 来更新密码。请使用服务工具 Controller Assistant 来执行此操作。

您可以通过以下示例所示的命令行来调用 Controller Assistant 的最新版本:

"c:\Program Files (x86)\Schneider Electric\EcoStruxureMachine Expert\Tools\ControllerAssistant\ControllerAssistant.exe" -username Administrator -password Administrator -renewalpassword MyNewPassword -getcontrollerinfo etcp4://192.168.3.50

有关更多信息,请参阅 EcoStruxure Machine Expert Controller Assistant 用户指南