ローカル管理者を除くすべての内部 Confluence ユーザーを削除する方法

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Data Center - この記事は、Data Center プラットフォームのアトラシアン製品に適用されます。

このナレッジベース記事は製品の Data Center バージョン用に作成されています。Data Center 固有ではない機能の Data Center ナレッジベースは、製品のサーバー バージョンでも動作する可能性はありますが、テストは行われていません。サーバー*製品のサポートは 2024 年 2 月 15 日に終了しました。サーバー製品を利用している場合は、アトラシアンのサーバー製品のサポート終了のお知らせページにて移行オプションをご確認ください。

*Fisheye および Crucible は除く

目的

これは、Confluence バージョン 3.5.x 以降を実行している管理者に適用される、特殊なユースケースです。

Confluence was originally set up with local user management but then switched to an external user management system (JIRA, Crowd, or LDAP), keeping the exact same usernames. Normally, the external user directory would be set to the top position, thereby allowing the external users to  supersede  the internal users of the same usernames (the local users will be "shadowed").  However, the administrator would like to continue to use the internal directory to create users/groups local to Confluence.

The issue is that Confluence will not allow the creation of a local user unless the local user directory is at the top position. However, if the local directory is at the top position, then the external users will be "shadowed".  There is an improvement request to allow the administrator to add users to specific user directories. If this is implemented, then the external user directory can always remain at the top position, and users can be added to the local directory on command.  Please keep watch on the following ticket if you are interested in receiving updates on this feature:  CONFSERVER-22296 - Provide an option to select user directory on adding/deleting users

回避策

回避策は、ユーザー ディレクトリの順序を入れ替え、Confluence にローカル ユーザーを追加する必要があるときにローカル ディレクトリを上位に移動させることです。

  ソリューション

Another solution is to permanently keep the local directory at the top and remove all internal users (except a local administrator account in case of emergencies).

Confluence will not allow the removal of users if the username is associated with any content in the application (even if the same username exists in other directories). Therefore, the removal will have to be done via the database.

This operation is not supported and should be thoroughly tested in a test environment to avoid unexpected results. In other words, please proceed at your own risk. As usual, please ensure that you have ample database backups prior to running any SQL modifications.

This operation was tested in Confluence 8.5. This is not guaranteed to work in future versions as the product may change.

(warning) The below queries will delete ALL local users, except one local admin (determined by whatever <local_admin_username> is set to):

  • Postgres/MySQL

    CREATE TEMPORARY TABLE tmp_userids
    AS (SELECT u.id FROM cwd_user u
    JOIN cwd_directory d ON u.directory_id = d.id
    WHERE d.lower_directory_name = 'confluence internal directory' AND u.user_name <> '<local_admin_username>');

     (info) you can index the tmp_userids by running the following query after their creation:

    CREATE INDEX tmp_userids_index
    ON tmp_userids (id);
    DELETE FROM cwd_user_credential_record WHERE user_id IN (SELECT id FROM tmp_userids);
    DELETE FROM cwd_membership WHERE child_user_id IN (SELECT id FROM tmp_userids);
    DELETE FROM cwd_user_attribute WHERE user_id IN (SELECT id FROM tmp_userids);
    DELETE FROM cwd_user WHERE id IN (SELECT id FROM tmp_userids);
       (info) The cwd_membership table contains the details of the groups the user is part of, so before deleting the user we should delete the related record in table cwd_membership and cwd_user_attribute table. If we do not delete entries in this order, we might see this error similar to this: 
    Error : The DELETE statement conflicted with the REFERENCE constraint "fk_child_user". The conflict occurred in database "prd-osconfluence-sqldb", table "dbo.cwd_membership", column 'child_user_id'.
  • Microsoft SQL Server

    CREATE TABLE #tmp_userids(id numeric)
    INSERT INTO #tmp_userids (id) (SELECT u.id FROM cwd_user u
    JOIN cwd_directory d ON u.directory_id = d.id
    WHERE d.lower_directory_name = 'confluence internal directory' AND u.user_name != '<local_admin_username>');

    (info) you can index the tmp_userids by running the following query after their creation:

    CREATE INDEX tmp_userids_index
    ON tmp_userids (id);
      
    DELETE FROM cwd_user_credential_record WHERE user_id IN (SELECT id FROM #tmp_userids);
    DELETE FROM cwd_membership WHERE child_user_id IN (SELECT id FROM #tmp_userids);
    DELETE FROM cwd_user_attribute WHERE user_id IN (SELECT id FROM #tmp_userids);
    DELETE FROM cwd_user WHERE id IN (SELECT id FROM #tmp_userids);
最終更新日: 2025 年 1 月 24 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.