在Bitbucket中查找非活动用户列表?

时间:2017-12-05 07:31:29

标签: bitbucket bitbucket-server

如何找到从未登录过Bitbucket帐户的用户列表?有任何查询或宏,还是我必须手动完成?

3 个答案:

答案 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服务器(和数据中心):

  • 在用户列表中(管理> 用户下)显示最后通过身份验证
  • 提供REST API以查询任何给定用户的上次认证日期

答案 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);