597
Views
7
Comments
how to add a user to a particular tenant?

Hello,

         This multitenancy feature is so confusing. I've created two tenants in service center of my app. I also created two users. How to assign a user to a particular tenant? Like if I log in with user1 creds tenant 1 data should be displayed and same should happen with user2. Also can anyone please explain me thefunctionality if tenant switch and how it works and also  the below statement.

  • User_Login: The User_Login action of the default Users application automatically binds an end-user to the correct tenant. If the login is successful, all queries are automatically filtered to only return data from the tenant;


Regards

Vaishnavi

Hi Vaishnavi,

I would like to suggest to go through these learning materials in order to understand the concept of multitenancy.

Also, there is a Multitenant Management application available in the Forge, which you can use as reference.

Hope this helps.

Regards,

Nordin

Nordin Ahdi wrote:

Hi Vaishnavi,

I would like to suggest to go through these learning materials in order to understand the concept of multitenancy.

Also, there is a Multitenant Management application available in the Forge, which you can use as reference.

Hope this helps.

Regards,

Nordin

 Hi Nordin,

                 I've already went through those links and also downloaded that component when I add a user for a tenant in Multitenant Management application it is not reflecting service center but it is getting updated in Users table. When I try to login with those creds it is giving an error. But I did not understand on how to assign a particular end-user to a specific tenant.


Regards,

Vaishnavi

 

Hi Vaishnavi,

I'm not sure I understand the exact issue you are facing.

If you want to create a specific user for a specific tenant, the Multitenant Management application enables you to do just that.

As you can see in the below example, I have just created the user 'SSadmin' for the Service Center tenant (which has TenantId = 1). Notice that the screens have a TenantId input parameter that allows data isolation for a specific tenant.

After that, I went and logged in Service Center with the 'SSadmin' user and the password I created using the Multitenant Management application.

When you look at the code of the Multitenant Management application, notice that the User entity and other related entities have their Tenant Identifier exposed. If you double-click the User entity and go to the Advanced tab, you notice the Show Tenant Identifier checkbox is checked. As a result, an extra column to the left named Tenant_Id was added to the User entity. As a result, the automatic data isolation for this entity is disabled and all the User data across all tenants can be viewed and managed within this application.

Notice that the first row contains the 'SSadmin' user we have created in the above example for the Service Center tenant (Tenant_Id = 1). 

You can do the same and manage all the users for other tenants that you have created with the use of this application.

Hope this makes it more clear.

Regards,

Nordin

Nordin Ahdi wrote:

Hi Vaishnavi,

I'm not sure I understand the exact issue you are facing.

If you want to create a specific user for a specific tenant, the Multitenant Management application enables you to do just that.

As you can see in the below example, I have just created the user 'SSadmin' for the Service Center tenant (which has TenantId = 1). Notice that the screens have a TenantId input parameter that allows data isolation for a specific tenant.

After that, I went and logged in Service Center with the 'SSadmin' user and the password I created using the Multitenant Management application.

When you look at the code of the Multitenant Management application, notice that the User entity and other related entities have their Tenant Identifier exposed. If you double-click the User entity and go to the Advanced tab, you notice the Show Tenant Identifier checkbox is checked. As a result, an extra column to the left named Tenant_Id was added to the User entity. As a result, the automatic data isolation for this entity is disabled and all the User data across all tenants can be viewed and managed within this application.

Notice that the first row contains the 'SSadmin' user we have created in the above example for the Service Center tenant (Tenant_Id = 1). 

You can do the same and manage all the users for other tenants that you have created with the use of this application.

Hope this makes it more clear.

Regards,

Nordin

 

 Hi Nordin,

                 Thankyou so much for this explanation and the efforts you've put in. Actually I created a tenant in the service center "tenant 2".

Then I opened multitenant management application, Under the tenants tab the tenant I created "tenant 2" was there.


Then I clicked on it and created a user by clicking on create user.

When I was trying to login with this user creds I'm getting "Invalid username or password" error. This is my major problem actually. It is showing in the Users table and yes I have checked the show tenant identifier checkbox.

Regards,

Vaishnavi

Hi Vaishnavi,

Do you mean you have created an extra tenant for the Users module via Service Center like in the below example?

If this is the case and you try to login with that user you have created for the new tenant, the User Provider for the module you try to login to has to be Users.

What I did is I have created a 'testuser' for the previously created 'TestTenant' inside the Multitenant Management application. 

Then I have started a debug session while login in with this 'testuser', to demonstrate the automatic binding of an end-user to the correct tenant and to come back to this statement on the Users_Login action you shared in your first post.

  • User_Login: The User_Login action of the default Users application automatically binds an end-user to the correct tenant. If the login is successful, all queries are automatically filtered to only return data from the tenant;

As you can see I have set a breakpoint before the User_Login action and at this point the TenantId = 20 which is the Identifier of the Users Tenant (which is the Default Tenant of the Users module as you can see in the Service Center snapshot).

I have set another breakpoint after the User_Login action and you can see that the Tenant has automatically switched to the newly created 'TestTenant' where the 'testuser' was created under.

As a result, I am logged in under the TestTenant.

Let me know if it helped.

Regards,

Nordin

Hi Nordin Ahdi,

As you said, Tenant has automatically switched in the previous login then what is the use of tenant switch action.  Can you explain brief.

Hi Yogesh,

Tenant switch action is useful when you want to create your custom user management or Front Office where you create tenant and add user in that tenant. Please refer 'Implementing the Front Office' in below section.

How to Build a Multi-tenant Application


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.