13.2.9. Managing Users and Groups

Engineering Knowledge Manager

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

13.2.8. Transferring Files |  | 13.2.10. Miscellaneous Operations
Prev |  | Next

### 13.2.9. Managing Users and Groups

EKM controls access to the repository with user accounts. EKM controls access to objects in the repository by assigning permissions to users and groups for the objects. The library provides a way to create, manage, and delete EKM users and groups. The examples below show how to do this.

Java

      AdministrationManager mm = conn.getAdministrationManager();
      ModelObject user = mm.createUser(“jsmith”);
      ModelObject group = mm.createGroup(“engineers);
      List<String> users = new ArrayList<>();
      users.add(user.getName());
      mm.addUsersToGroup(users, group.getName());
      user = mm.findUser(user.getName());
      group = mm.findGroup(group.getName());
      if (!mm.belongsTo(user.getName(), group.getName()))
          System.err.println(">>>>> " + user.getName() + " not member of " + group.getName());
      else
          mm.removeUsersFromGroup(users, group.getName());

Python (Jython)

      mm = conn.getAdministrationManager()
      user = mm.createUser(“jsmith”)
      group = mm.createGroup(“engineers”)
      users = [user.getName()]
      mm.addUsersToGroup(users, group.getName())
      user = mm.findUser(“jsmith”)
      group = mm.findGroup(“engineers”)
      if not mm.belongsTo(user.getName(), group.getName()):
          print ">>>>> " + user.getName() + " not member of " + group.getName()
      else:
         mm.removeUsersFromGroup(users, group.getName())

Python (IronPython)

      mm = conn.getAdministrationManager()
      user = mm.CreateUser(“jsmith”)
      group = mm.CreateGroup(“engineers”)
      users = List[str]()
      users.Add(user.Name)
      mm.AddUsersToGroup(users, group.Name)
      user = mm.FindUser(user.Name)
      group = mm.FindGroup(group.Name)
      if not mm.BelongsTo(user.getName(), group.getName()):
          print ">>>>> " + user.Name + " not member of " + group.Name
      else:
          mm.RemoveUsersFromGroup(users, group.Name)

C#

      AdministrationManager mm = conn.GetAdministrationManager();
      ModelObject user = mm.CreateUser(“jsmith”);
      ModelObject group = mm.CreateGroup(“engineers”);
      List<string> users = new List<string>();
      users.Add(user.Name);
      mm.AddUsersToGroup(users, group.Name);
      user = mm.FindUser(user.Name);
      group = mm.FindGroup(group.Name);
      if (!mm.BelongsTo(user.getName(), group.getName()))
          Console.WriteLine(">>>> " + user.Name + " not member of " + group.Name);
      else
          mm.RemoveUsersFromGroup(users, group.Name);

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.