How to get a list of licensed users with "created" and "last authenticated" data with Bitbucket Server and Data Center
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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
The content on this page relates to platforms which are not supported. Consequently, Atlassian Support cannot guarantee providing any support for it. Please be aware that this material is provided for your information only and using it is done so at your own risk.
Summary
The article explains how to get a list of licensed users with information about when they last logged in ("last authenticated" data) and when the accounts were created.
Environment
Bitbucket 8.9.4, but also applicable to other versions.
Solution
The following database query provides a list of licensed users with information about when they last logged in ("last authenticated" data) and when the accounts were created.
-- list of licensed users with created and last authenticated dates
select
snu.name as username,
cu.created_date,
date(to_timestamp(cua.attribute_value::decimal/1000)) as last_authenticated
from sta_normal_user snu
join cwd_user cu on cu.lower_user_name = snu."name"
left join cwd_user_attribute cua on cua.user_id = cu.id and cua.attribute_name = 'lastAuthenticationTimestamp'
where exists (
select * from sta_global_permission where user_id = snu.user_id
)
or exists (
select * from cwd_membership where lower_parent_name in (
select group_name from sta_global_permission
)
and child_name = snu.name
)
order by last_authenticated;