Open Closed

Tenant Impersonation and tenant switching are generating 400 and 403 response codes respectively #9438


User avatar
0
AnneCMukul created

Hi,

I am unable to log into the tenant even by impersonation or by switching to the tenant in the login page, getting that the tenant user could not be found in case of impersonation login or getting the tenant cannot be found in case of trying to switch to the tenant in login page, attached a loom video and some screenshots regarding the issue here so you can understand the problem, please let us know if you find anything.

Thank you

https://www.loom.com/share/4f4e1e9f59ad449f90187d1f63b993d5


13 Answer(s)
  • User Avatar
    0
    AI-Bot created
    Support Team ABP Agent

    To resolve the issues with tenant impersonation and tenant switching (400/403 errors, "tenant does not exist", "no user with username: admin"), please check the following:

    1. Tenant Existence and Name

      • Ensure the tenant name ("alpha" in your screenshots) is correct and exists in the database.
      • Tenant names are case-sensitive and must match exactly.
    2. Tenant Admin User

      • Each tenant must have an admin user. By default, the username is "admin" unless changed during tenant creation.
      • If you get "There is no user with username: admin!", verify that the "admin" user exists under the "alpha" tenant. You can check this in the SaaS > Tenants > Users section.
    3. Cache Consistency

      • In tiered/separated deployments, cache key mismatches can cause tenant/user not found errors.
      • Ensure all your services (AuthServer, HttpApi.Host, etc.) use the same cache configuration and prefix. If you recently upgraded or changed configuration, clear all distributed caches (e.g., Redis).
    4. Database Consistency

      • Confirm that the tenant and its admin user exist in the correct tables (SaasTenants, AbpTenants, AbpUsers) and are not soft-deleted.
    5. Migration Issues

      • If you recently upgraded ABP or migrated from community to commercial, follow the official migration guide and ensure all migrations are applied:
        • https://docs.abp.io/en/abp/latest/Migration-Guides/Abp-8_1
    6. Impersonation Permissions

      • Make sure the host user has the required permissions for tenant/user impersonation:
        • https://abp.io/docs/latest/modules/account/impersonation
    7. Restart and Clear Cookies

      • After making changes, restart all services and clear browser cookies to avoid stale session/cookie issues.

    If you follow these steps and the issue persists, double-check the logs for cache or database inconsistencies, and ensure the tenant and user data are present and correct.

    Sources:

    • https://abp.io/docs/latest/modules/account/impersonation
    • https://abp.io/support/questions/7020

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

  • User Avatar
    0
    AnneCMukul created

    [AI-Bot] said: To resolve the issues with tenant impersonation and tenant switching (400/403 errors, "tenant does not exist", "no user with username: admin"), please check the following:

    1. Tenant Existence and Name

      • Ensure the tenant name ("alpha" in your screenshots) is correct and exists in the database.
      • Tenant names are case-sensitive and must match exactly.
    2. Tenant Admin User

      • Each tenant must have an admin user. By default, the username is "admin" unless changed during tenant creation.
      • If you get "There is no user with username: admin!", verify that the "admin" user exists under the "alpha" tenant. You can check this in the SaaS > Tenants > Users section.
    3. Cache Consistency

      • In tiered/separated deployments, cache key mismatches can cause tenant/user not found errors.
      • Ensure all your services (AuthServer, HttpApi.Host, etc.) use the same cache configuration and prefix. If you recently upgraded or changed configuration, clear all distributed caches (e.g., Redis).
    4. Database Consistency

      • Confirm that the tenant and its admin user exist in the correct tables (SaasTenants, AbpTenants, AbpUsers) and are not soft-deleted.
    5. Migration Issues

      • If you recently upgraded ABP or migrated from community to commercial, follow the official migration guide and ensure all migrations are applied:
        • https://docs.abp.io/en/abp/latest/Migration-Guides/Abp-8_1
    6. Impersonation Permissions

      • Make sure the host user has the required permissions for tenant/user impersonation:
        • https://abp.io/docs/latest/modules/account/impersonation
    7. Restart and Clear Cookies

      • After making changes, restart all services and clear browser cookies to avoid stale session/cookie issues.

    If you follow these steps and the issue persists, double-check the logs for cache or database inconsistencies, and ensure the tenant and user data are present and correct.

    Sources:

    • https://abp.io/docs/latest/modules/account/impersonation
    • https://abp.io/support/questions/7020

    This response was generated by AI. If it didn’t solve your problem, feel free to post a new answer — our support team will jump in to help you soon.

    Tried everything but could not solve the issue.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Please try to inject ITenantStore and ITenantRepository and call GetListAsync method to see tenants in your Index page..

    Also enable the debug log of EF Core to see the sql querys.

    https://abp.io/support/questions/8622/How-to-enable-Debug-logs-for-troubleshoot-problems

  • User Avatar
    0
    AnneCMukul created

    [maliming] said: hi

    Please try to inject ITenantStore and ITenantRepository and call GetListAsync method to see tenants in your Index page..

    Also enable the debug log of EF Core to see the sql querys.

    https://abp.io/support/questions/8622/How-to-enable-Debug-logs-for-troubleshoot-problems

    This is the log I am getting while switching to the tenant and trying login into the tenant in the login page (enabled debug logs of EF Core)

    the log says that the given tenant does not exist, but it is available in SaaSTenants table

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Please try to inject ITenantStore and ITenantRepository and call GetListAsync method to see tenants in your Index page..

    Can you try that?

    Thanks.

  • User Avatar
    0
    AnneCMukul created

    [maliming] said: hi

    Please try to inject ITenantStore and ITenantRepository and call GetListAsync method to see tenants in your Index page..

    Can you try that?

    Thanks.

    I have used ITenantStore and ITenantRepository and called GetListAsync method to see tenants in BookAppService where we are calling GetListAsync from the host level, below attached are screenshot of the implementation

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share a project to reproduce this problem?

    liming.ma@volosoft.com

    I will download and debug it.

    Thanks.

  • User Avatar
    0
    AnneCMukul created

    [maliming] said: hi

    Can you share a project to reproduce this problem?

    liming.ma@volosoft.com

    I will download and debug it.

    Thanks.

    But I think you will be able to login into the tenant, I have this same project in two other systems and I can login into the tenant with no problems, this issue only arises in my computer which shares the same codebase and database as the other computers, what might be the problem here which I'm unable to point out.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you try to clear your local Redis?

    Your issue is related to your local environment, not the code.

  • User Avatar
    0
    AnneCMukul created

    [maliming] said: hi

    Can you try to clear your local Redis?

    Your issue is related to your local environment, not the code.

    Hey maliming

    I have tried clearing Redis cache multiple times using redis-cli flushall and flushdb, didn't work unfortunately :-(

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can override the MultiTenantConnectionStringResolver to see if the connection string is correct.

    https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/MultiTenantConnectionStringResolver.cs#L27-L81

  • User Avatar
    0
    AnneCMukul created

    [maliming] said: hi

    You can override the MultiTenantConnectionStringResolver to see if the connection string is correct.

    https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/MultiTenantConnectionStringResolver.cs#L27-L81

    Hey

    I found the issue, the connection string for the AuthServer was wrong and I just needed to change it to the correct one. The issue got solved.

    Thank you ;-)

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Great

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.0.0-preview. Updated on June 20, 2025, 11:20