password protect a POU

fciac
2017-09-01
2017-09-01
  • fciac - 2017-09-01

    How can i password protect a POU?

     
  • mkeller - 2017-09-01

    Hi fciac.

    fciac hat geschrieben:
    How can i password protect a POU?

    Here some example code which is for a different use case but it should show how to use the Scripting API:

    proj = projects.primary
    found = proj.find("Device", "PLC Logic", "Application", "GVL")
    assert(found and len(found) == 1, "GVL not found")
    user_mgr = proj.user_management
    everyone = user_mgr.groups["Everyone"]
    myusers = user_mgr.groups["MyUsers"]
    user_mgr.login("Owner", "")
    perm = user_mgr.get_object_permission(found[0], ObjectPermissionKind.View)
    perm.set_permission_state(everyone, PermissionState.Granted)
    perm.set_permission_state(myusers, PermissionState.Granted)
    for perm_kind in (ObjectPermissionKind.Modify, ObjectPermissionKind.Remove, ObjectPermissionKind.AddRemoveChildren):
    Β  Β perm = user_mgr.get_object_permission(found[0], perm_kind)
    Β  Β perm.set_permission_state(everyone, PermissionState.Denied)
    Β  Β perm.set_permission_state(myusers, PermissionState.Denied)
    user_mgr.logout()
    

    BR
    Martin

     

Log in to post a comment.