List all users without group assignment
Asked by Artur Siwakowski:

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


Answers:
author: Stephen Deutsch
body: 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).


author: Stephen Deutsch
body: 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.


author: Artur Siwakowski
body: Screenshot - 2015-03-11 , 16_58_32.png  
[](https://community.atlassian.com/t5/Confluence-questions/List-all-users-without-group-assignment/qaq-p/261327?attachment-id=3222){#link_1188c376504feb}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/44111/1/Screenshot%20-%202015-03-11%20,%2016_58_32.png){#display_1188c376504feb_0}


author: Artur Siwakowski
body: 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  
[](https://community.atlassian.com/t5/Confluence-questions/List-all-users-without-group-assignment/qaq-p/261327?attachment-id=1514){#link_1188c37a5ae6be}  
[](/tnckb94959/attachments/tnckb94959/confluence-questions/44108/1/Screenshot%20-%202015-03-11%20,%2016_25_29.png){#display_1188c37a5ae6be_0}

comments: author: Stephen Deutsch
body: I changed the code above slightly, you could try again; I tested it and it worked with FF and IE now.


author: Artur Siwakowski
body: This time I got different error. Please see the second post below.


author: Artur Siwakowski
body: 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


author: Alex Yasurek
body: 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.


Tags: confluence-administration