Open Closed

how to use ClaimsIdentity with current Tenant #6961


User avatar
0
ElifKaya created

Hi,

I need to use ClaimsPrincipal with current tenant. Actually, there is no problem without tenant. I also used _currentTenant.Change but, it throws Volo.Abp.Authorization.AbpAuthorizationException when I call to PhaseAppservice as below. I need to access to appService in IDistributedEventHandler also.

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, and please first use the search on the homepage. Provide us with the following info:

  • ABP Framework version: v7.3.1
  • UI Type: Angular / MVC
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes/
  • Exception message and full stack trace:
  • Steps to reproduce the issue:
Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    Can you share the full error logs?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    ElifKaya created

    Hi,

    Can you share the full error logs?

    Hi,

    Actually, current user has permission and it didn't throw exception from other appService with this tenant. It throwed exception when we use tenant just EventHandler.cs. So I think that we need to add tenant information in ClaimsPrincipal, is it possible or can you advice any other option? Thanks

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    You can try

    claimsIdentity.AddClaim(new Claim(AbpClaimTypes.TenantId, eventData.TenantId.ToString()))
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
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.8.0-preview. Updated on September 23, 2026, 09:57
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.