Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

List all users without group assignment

Artur Siwakowski March 10, 2015

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
Answer accepted
Stephen Deutsch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 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.

0 votes
Artur Siwakowski March 11, 2015

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

0 votes
Artur Siwakowski March 11, 2015

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 11, 2015

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

Artur Siwakowski March 11, 2015

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

0 votes
Artur Siwakowski March 10, 2015

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

0 votes
Alex Yasurek
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 10, 2015

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.

 

 

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events