List all users without group assignment

Hello,

Is there a way to get a list of all users that are not assigned to any group? Maybe a user macro that can list all users without group?

Best Regards

Artur Siwakowski

6 answers

1 accepted

1 vote
Stephen Deutsch Community Champion Mar 11, 2015

Hi Artur,

Here is a quick way you can find the users without groups: Just paste this code into the javascript console of your browser when you are logged into your Confluence instance (usually brought up by pressing F12 and finding the console tab)

getGroups = function( userArray ) {
  if (userArray.length !== 0) {
    var currentUser = userArray.shift();
    jQuery.ajax({
      contentType: 'application/json',
      type: 'POST',
      url: contextPath + '/rpc/json-rpc/confluenceservice-v2/getUserGroups',
      data: '["' + currentUser + '"]',
      success: function( response ) {
         if (response.length === 0) {
           console.log(currentUser);
         }
         getGroups(userArray);
      }
    });
  } else {
    console.log("Done!");
  }
}

jQuery.ajax({
  contentType: 'application/json',
  type: 'POST',
  url: contextPath + '/rpc/json-rpc/confluenceservice-v2/getActiveUsers',
  data: '[false]',
  success: function( response ) {
    getGroups(response);
  }
});

It will make a list of all users who have no groups and will display the word "Done!" when it's done.  Note that this only finds the active users without groups.  If you also want to figure out the disabled users without groups, change the word 'false' above to 'true'.

EDIT: It appears the order of the functions makes a difference in the Firefox console. Also, you have to be logged in as an administrator (forgot to mention).

1 vote
Stephen Deutsch Community Champion Mar 11, 2015

Seems like it worked, there might not be any active users who don't have any groups.  You can use this slightly modified version to show a list of all users and the number of groups they have:

getGroups = function( userArray ) {
  if (userArray.length !== 0) {
    var currentUser = userArray.shift();
    jQuery.ajax({
      contentType: 'application/json',
      type: 'POST',
      url: contextPath + '/rpc/json-rpc/confluenceservice-v2/getUserGroups',
      data: '["' + currentUser + '"]',
      success: function( response ) {
         console.log(currentUser + ' - ' + response.length);
         getGroups(userArray);
      }
    });
  } else {
    console.log("Done!");
  }
}

jQuery.ajax({
  contentType: 'application/json',
  type: 'POST',
  url: contextPath + '/rpc/json-rpc/confluenceservice-v2/getActiveUsers',
  data: '[false]',
  success: function( response ) {
    getGroups(response);
  }
});

Like I said, if you want to also show for non-active users you have to change the false to true in the code above.

Hi,

The only way off the top of my head that I can think of is to use the API to retrieve all the users and then check to see if any don't belong a group.

https://developer.atlassian.com/confdev/confluence-rest-api/confluence-xml-rpc-and-soap-apis/remote-confluence-methods

First I would use getActiveUsers() to get all the users and then loop through them using getUserGroups() to see which come back with an empty set.

 

 

 

Hi Alex,

Thank you for the answer!

I don't know if I can handle the mentioned solution, because I'm not a developer. I guess I will have to look for other ways to achieve the goal.

Best Regards

Artur

Hi Stephen,

 

When I'm pasting this code into FF or IE10 console and press Enter, I get the code doubled without results.

Screenshot - 2015-03-11 , 16_25_29.png

Maybe I'm doing something wrong?

I've logged into the Production server and started IE10 (and FF), passed the code and click on Enter.

Best Regards

Artur

Stephen Deutsch Community Champion Mar 11, 2015

I changed the code above slightly, you could try again; I tested it and it worked with FF and IE now.

This time I got different error. Please see the second post below.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

2,481 views 25 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you