It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get confluence licensed users count from database

I am new to confluence. I just would like know how to get confluence licensed users count. Currently, our organisation has limit of 10000  users. And in this 4935 signed up users. I mean 4935 used. But when trying get count for licensed users from data base using following query I got only 2932. I am not understanding why both displaying different. Please let me whether I am using correct query or not getting licensed users count for confluence.

 

SELECT count(
(users.lower_user_name))
FROM
cwd_user users
JOIN
cwd_directory userdir
ON
users.directory_id=userdir.id
WHERE
users.lower_user_name IN
(
SELECT DISTINCT
lower(permusername)
FROM
SPACEPERMISSIONS
WHERE
permtype='USECONFLUENCE')
OR users.lower_user_name IN
(
SELECT
u.lower_user_name
FROM
cwd_user u
JOIN
cwd_directory d
ON
u.directory_id = d.id
JOIN
cwd_membership m
ON
u.id = m.child_user_id
JOIN
cwd_group g
ON
g.id = parent_id
JOIN
SPACEPERMISSIONS sp
ON
g.lower_group_name =lower(sp.permgroupname)
WHERE
permtype='USECONFLUENCE' )
AND users.active='T'
AND userdir.active='T'
ORDER BY
1;

1 answer

1 vote

Don't bother with the database, it's complex and you're looking at the wrong thing anyway.

Go to Admin -> Global permissions and get the list of groups that have "can use" in there.  The members of those groups are the ones that give you  the 4953 (note, that deduplicates users - if you're in three of the groups for example, you only count once to the 4953)

Thank you for response. But, I have different situation like I need to read the list of licensed users from data base.  So, I google it and tried with multiple queries but mostly the results are getting below 3000. But, when I verify the count in Confluence Admin page it has 4900+ used licenses.

 

May be you are right, one user can have multiple licenses. because of that count is varying. But, I need total licenses used count using script. I don't have knowledge how to get that.

"I need to read from the database" does not explain what you are trying to do.  It is almost certainly the wrong way to do it.

Instead of running off down the path of a probably complex and inaccurate solution, could you explain what you are trying to achieve instead?

Your original question was "I want to get the number of licenced users" and you then said you had 4935.  Assuming that is from the Confluence system information, licence or user list pages, then it is already the answer.  Why are you trying to replicate it using another method?

I am trying to create a console job to get the count of licensed users and need to notify the admins if count crossed certain limit. For that, I am trying to fetch the signed up users count and verifying count is crossed or not in console. But, my problem is I am unable fetch actual count  that displayed in the admin page. Please let me know if you have other ways to read the count if it is not possible from database.

I am still not understanding why reading from database is not right way.

The database is not right because you are asking it the wrong question.  Because it's messy and can't tell you the right answer unless you completely understand it.

Best way to do this would be to note what group(s) let you into Confluence (they rarely change once set up) and then get the list of users in those groups over the REST API 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

What project did you transition or start on Confluence with the shift to remote work?

It’s been great to hear from fellow users over the last few weeks about the best tips and fun moments you’ve had working on Confluence since the transition to working remote. I’d love to keep the c...

203 views 3 8
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you