Base solution for your next web application
Open Closed

Using Organization ID and Tenant ID - User Linking Issue #1409


User avatar
0
maharatha created

Hi Hilkan -

I am now using Organization ID to group the Tenants so that these Tenants can be grouped and I can later on use to share data between them. I moved my database connection to Organization where they can input connection string to a Organization and the tenant using this organization will use the connection string.

Now I am trying to create user from one tenant into all the grouped tenant under the organization , ie. let's say I have 3 tenants in one organization and i create an user in one tenant then i am creating 2 users of the same credentials in the other two tenants.

This works fine, but I am unable to link these users programatically. I am trying to create user and link them in a single unit of work.

I am unable to figure out when you are inserting records to the UserAccounts table.

Please help


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

    Hi,

    This class fills the UserAccount table: <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero/blob/dev/src/Abp.Zero/Authorization/Users/UserAccountSynchronizer.cs">https://github.com/aspnetboilerplate/mo ... ronizer.cs</a>

    Unfortunately, it's not possible to do it in a single transaction. Currently you can do that:

    1. Add [UnitOfWork(IsDisabled=true)] to disable UOW for your application service.
    2. Manually begin transaction (using UnitOfWorkManager) and complete in the service.
    3. After uow completed and disposed (by using statement), start a new UOW and now you can get UserAccount entities.

    We know that this is not very safe, but it's the only option since UserAccount table is filled after uow complete. If you don't like this solution, please create an issue to module zero repository: <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero/issues/new">https://github.com/aspnetboilerplate/mo ... issues/new</a> So, we can consider to make this better for next releases.