How to get space permissions of all spaces for specific user groups
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
The steps outlined on this article are provided AS-IS. This means we've had reports of them working for some customers — under certain circumstances — yet are not officially supported, nor can we guarantee they'll work for your specific scenario.
You may follow through and validate them on your own non-prod environments prior to production or fall back to supported alternatives if they don't work out.
We also invite you to reach out to our Community for matters that fall beyond Atlassian's scope of support!
Database query to get details about space permissions of all the spaces in Confluence for a specific set of user groups.
Solution
Always back up your data before making any database modifications. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.
Note
These database queries are tested on PostgreSQL Database
Below are all possible space permissions which can be given for space, to a user/users or to a group/groups
The types of space permissions for spaces
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
permtype
---------------------
SETSPACEPERMISSIONS
EXPORTSPACE
VIEWSPACE
SETPAGEPERMISSIONS
REMOVEBLOG
REMOVEPAGE
EDITSPACE
CREATEATTACHMENT
REMOVEOWNCONTENT
COMMENT
REMOVECOMMENT
EDITBLOG
REMOVEMAIL
REMOVEATTACHMENT
When you have to check space permissions of all the spaces in confluence for a specific set of user groups
You need to replace '<group1>', '<group2>' with the groups from your environment, in the below query:
Database query to check permissions for both groups for all spaces
PostgreSQL
1 2 3 4 5
SELECT distinct sp.permtype FROM SPACEPERMISSIONS sp JOIN SPACES s ON sp.spaceid = s.spaceid LEFT JOIN user_mapping um ON sp.permusername = um.user_key WHERE sp.permgroupname IN ('<group1>', '<group2>');
When you have to check space permissions of one space for two groups
You need to replace '<group1>', '<group2>' with the groups from your environment and the '<spacename>' as per your requirement, in the below query:
Database query to check space permissions of one space for two groups
PostgreSQL
1 2 3 4 5 6
SELECT sp.permid, sp.permtype, s.spacekey, s.spacename, sp.permgroupname FROM SPACEPERMISSIONS sp JOIN SPACES s ON sp.spaceid = s.spaceid LEFT JOIN user_mapping um ON sp.permusername = um.user_key WHERE s.spacename = '<spacename>' and sp.permgroupname IN ('<group1>', '<group2>');
When you have to check the space permissions of all the personal spaces for groups , this query will check permissions for personal spaces only.
You need to replace '<group1>', '<group2>' with the groups from your environment, in the below query:
Database query to check the permissions for ALL of the personal space for groups - "'<group1>', '<group2>'"
PostgreSQL
1 2 3
SELECT * FROM SPACEPERMISSIONS AS SP ,SPACES AS S WHERE SP.SPACEID=S.SPACEID AND S.SPACETYPE='personal' AND SP.PERMGROUPNAME IS NOT NULL AND SP.PERMGROUPNAME IN ('<group1>', '<group2>');
Was this helpful?