13.2.5. Checking Permissions

Engineering Knowledge Manager

Administration Guide | Chapter 13: EKM Client API | 13.2. Using the Library in Client Applications |

13.2.4. C.R.U.D. |  | 13.2.6. Locking and Unlocking Objects
Prev |  | Next

### 13.2.5. Checking Permissions

EKM uses permissions to authorize actions on objects. If the application attempts to perform an action on an object for which the user has insufficient permissions, an exception is thrown and the action fails. Actions include access, create, delete, modify, download, full control, and checkout. When checking permissions, the application creates a collection of actions that it wants to check. If any single permission is denied, the check will return false. The following example checks to see if the user has permission to delete an object:

Java

      ModelObject folder = dm.findByPath("/Data/My Data/My Projects");
      Set<PermissionAction> actions = new HashSet<>();
      actions.add(PermissionAction.DELETE);
      if (dm.hasPermission(folder, actions))
          dm.DeleteModelObject(folder.getPath());

Python (Jython)

      folder = dm.findByPath("/Data/My Data/My Projects")
      actions = [PermissionAction.DELETE]
      if dm.hasPermission(folder, actions):
          dm.deleteModelObject("/Data/My Data/My Projects")

Python (IronPython)

      folder = dm.FindByPath("/Data/My Data/My Projects")
      actions = List[PermissionAction]()
      actions.Add(PermissionAction.DELETE)
      if dm.HasPermission(folder, actions):
          dm.DeleteModelObject(folder.Path)

C#

      ModelObject folder = dm.FindByPath("/Data/My Data/My Projects");
      HashSet<PermissionAction> actions = new HashSet<PermissionAction>();
      actions.Add(PermissionAction.DELETE);
      if (dm.HasPermission(folder, actions))
          dm.DeleteModelObject(folder.Path);

Contains proprietary and confidential information of ANSYS, Inc. and its subsidiaries and affiliates.

Prev | Up / Contents | Next

Release 18.2 - © ANSYS, Inc. All rights reserved.