code: def AddGroupMemberships(self):
      
      self.groups = {g.name: self._Members(g) for g in itervalues(self.groups)}
      # Map the groups a user is a member of, irrespective of primary/extra gid.
      for g in itervalues(self.groups):
        for user in g.members:
          membership = self.memberships.setdefault(user, set())
          membership.add(g.gid)
      # Now add the completed membership to the user account.
      for user in itervalues(self.entry):
        user.gids = self.memberships.get(user.username)
docs: Adds aggregate group membership from group, gshadow and passwd.