Get a List of All Users in a Group

How can I do the following in an app:

  • A user is in a given group
  • Find all users of the same group

In addition:

  • Find all users of a certain group
  • Find all groups on the server


A user should select a member from the same work group to assign a job. So I’ll use the functions to setup a combo box in a template:

<select name="user">
  <option value="username1">User1</option>
  <option value="username2">User2</option>
  <option value="username3">User3</option>


I’d ask on the issue tracker. There is a search function but 0 documentation

If you can do it within normal business hours, you can try via IRC channel and try to reach the developers directly:

Hi, I’ve been searching how to do the same thing as mrv in 2017 , but it turns out that there is almost no documentation and when I found one it doesn’t help me at all . I want to use groups to limit the access of some content of my app to people that are in some groups and hide it from the others. But all I’ve tried doesn’t work because I don’t really know how to use correctly IGroupManager, all the functions in this lib would be very useful to me if I could be able to use them.

Have you tried Group folders?

Hi henry , yes, I already tried to use the code from group folder to understand how they use IGroupManager but this app is really complex for me and i don’t understand the way they use the functions. i can’t use group folder because it is made to limit access to some folder to certain groups on the file explorer and I would like to limit the access of content to some groups only on the app I’m creating .


Add the IGroupManager namespace to your controller class (use OCP\IGroupManager;).
Create a additional groupManager property in your controller class and add a IGroupManager constructor parameter.
Assign the constructor parameter to your new groupManager property.
Now you have access to all methods provided by IGroupManager (e.g.: $this->groupManager->search('')).
Write a new controller class method which determines and returns the desired group data and use the result data in your template.

You can see this procedure in almost all App Controller or/and Service classes.

1 Like