Base solution for your next web application
Open Closed

Hangfire process records via impersonate user #4854


User avatar
0
[email protected] created

Hi there

I have records inserting to the database via a background hang fire process

question I have is, how can I ensure the record is insert as a Tennant user i.e FullAuditedEntity, IMustHaveTenant

I will be processing different records on behave of different users in different tenants

thanks


1 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    hi,

    if you want to impersonate user, it's easy

    using (_session.Use(42, null))
            {
                var tenantId = _session.TenantId; //42
                var userId = _session.UserId; //null
            }
    

    <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Abp-Session?searchKey=impersonate#overriding-current-session-values">https://aspnetboilerplate.com/Pages/Doc ... ion-values</a>