addGroupToUser()

The method adds a user to a group.

Synopsis

public bool addGroupToUser(shared_ptr<UserManagementGroup> group, shared_ptr<UserManagementUser> user);

Parameter Description
group The user group to which the WinCC OA user is added to.
user The user who is added to the group and who becomes a member of the group.

Return Value

The method returns TRUE if a group could be added.

Errors

Errors are shown in the log viewer.

EXAMPLE

#uses "classes/userManagement/UserManagement"
main(mapping event)
{
  shared_ptr<UserManagement> userMgm = UserManagement::getInstance();
  shared_ptr<UserManagementGroup> group;
  shared_ptr<UserManagementUser> usr;
  group = userMgm.getGroupByName("WinCCOAManager");
  usr = userMgm.getUserByName("JohnDoe");
  bool GroupUser = userMgm.addGroupToUser(group, usr);
  /*Adds John Doe to the group WinCCOAManager */
  DebugN("Added the user JohnDoe to the group WinCCOAManager", GroupUser);
  DebugN(userMgm.saveChanges());
  dyn_anytype GroupInfo = userMgm.getGroupsByUser(usr);
  for (int i =1; i<=dynlen(GroupInfo); i++)
  DebugN("Groups of the user JohnDoe:", GroupInfo[i].getName());
}

Assignment

User administration

See also

addGroup()