如何找到从未登录过Bitbucket帐户的用户列表?有任何查询或宏,还是我必须手动完成?
答案 0 :(得分:1)
您可以使用SQL查询到数据库来执行此操作:
SELECT cu.lower_user_name
,cu.display_name
,cu.lower_display_name
,cu.lower_email_address
,cu.is_active
,dateadd(second,cast(cast(cua.attribute_value AS nvarchar(255)) AS bigint)/1000,'19700101 00:00:00:000') AS LAST_LOGIN
FROM [BitBucketDB].[dbo].[cwd_user] As cu
LEFT JOIN [BitBucketDB].[dbo].cwd_membership AS cm
ON cu.directory_id=cm.directory_id
AND cu.lower_user_name=cm.lower_child_name
AND cm.membership_type='GROUP_USER'
LEFT JOIN [BitBucketDB].[dbo].cwd_user_attribute As cua
ON cu.ID = cua.user_id and cua.attribute_name='lastAuthenticationTimestamp'
WHERE cm.lower_parent_name='stash-users'
答案 1 :(得分:0)
另请参阅有关主题的Atlassian KB: https://confluence.atlassian.com/bitbucketserverkb/query-for-inactive-or-idle-users-779171719.html 本质上,Bitbucket服务器(和数据中心):
答案 2 :(得分:0)
这是Postgresql的一种解决方案,请注意,您可能要考虑用户的创建日期,以排除昨天获得访问权限且尚未登录的用户。
一年未登录或从未登录,但已存在至少一年的用户:
select * from (SELECT distinct cu.lower_user_name
,to_timestamp(CAST(attribute_value AS BIGINT)/1000) AS last_login
,cu.created_date
FROM cwd_user As cu
LEFT JOIN cwd_membership AS cm
ON cu.directory_id=cm.directory_id
AND cu.lower_user_name=cm.lower_child_name
AND cm.membership_type='GROUP_USER'
LEFT JOIN cwd_user_attribute As cua
ON cu.ID = cua.user_id and
cua.attribute_name='lastAuthenticationTimestamp'
WHERE is_active = 'T'AND (cm.lower_parent_name='stash-users' OR
cm.lower_parent_name='bitbucket-users'
OR cm.lower_parent_name='stash' OR
cm.lower_parent_name='bitbucket') ) q1
where (last_login < current_date - (365) or last_login is null)
and created_date < current_date - (365);