Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,455,739
Community Members
 
Community Events
175
Community Groups

Database query - PostgreSQL

Hi,

I am trying to fetch the list of users who don't have space admin permissions to their related spaces but have permissions to delete the page, attachment or blog post.

I am using this query:

SELECT s.spacekey, s.spacename, cu.user_name, cu.first_name || ' ' || cu.last_name AS username, sp.permtype
FROM SPACEPERMISSIONS sp
JOIN SPACES s ON s.SPACEID = sp.SPACEID
JOIN user_mapping u ON sp.permusername = u.user_key
JOIN cwd_user cu ON cu.user_name = u.username
WHERE sp.permtype = 'REMOVEPAGE' OR sp.permtype = 'REMOVEBLOG' OR sp.permtype = 'REMOVEATTACHMENT' OR sp.permtype = 'REMOVECOMMENT' OR sp.permtype = 'REMOVEMAIL' AND sp.permtype != 'SETSPACEPERMISSIONS'
GROUP BY s.spacekey, s.spacename, sp.permtype, cu.user_name, cu.first_name || ' ' || cu.last_name, sp.permtype
ORDER BY s.spacename, cu.user_name, sp.permtype

But, this is returning the list of users who have space admin permissions as well.  

Anything that I missed?

Thanks,
Vamsi

1 answer

1 accepted

0 votes
Answer accepted

SELECT s.spacekey, s.spacename, cu.user_name, cu.first_name || ' ' || cu.last_name AS username, sp.permtype, sp.permusername
FROM SPACEPERMISSIONS sp
JOIN SPACES s ON s.SPACEID = sp.SPACEID
JOIN user_mapping u ON sp.permusername = u.user_key
JOIN cwd_user cu ON cu.user_name = u.username
WHERE (sp.permtype = 'REMOVEPAGE' OR
sp.permtype = 'REMOVEBLOG' OR
sp.permtype = 'REMOVEATTACHMENT' OR
sp.permtype = 'REMOVECOMMENT' OR
sp.permtype = 'REMOVEMAIL') AND
sp.permusername NOT IN
(SELECT distinct permusername FROM spacepermissions WHERE permtype = 'SETSPACEPERMISSIONS' AND permusername = sp.permusername AND spaceid = sp.spaceid)
GROUP BY s.spacekey, s.spacename, sp.permtype, cu.user_name, cu.first_name || ' ' || cu.last_name, sp.permtype, sp.permusername
ORDER BY s.spacename, cu.user_name, sp.permtype

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS

Atlassian Community Events