The Intrexx multi-tenancy facilitates weak data separation in large, adjoined company structures. If you have multiple tenants, the setup and usability (e.g. in intranets) is made easier in many ways. Multi-tenancy also provides valuable support for B2B and B2C. Because the data separation is weak, having isolated file storage locations and exporting portals with data are impossible.

Multi-tenancy in the Users module

The three objects

  • Country

  • Tenant

  • City

in the Users module. You can also create custom objects that can function as tenants.

Create tenant dependency

With the following, very simple structure we will show you how can link use objects to tenants. User A will be assigned to tenant "Organizational unit 1", User B to tenant "Organizational unit 2", and User C to both. Neither of the organizational units have anything particular about them but are simply created using the basic class "Organizational unit". As you can see, you do not have to use the tenant object to create a tenant.

In the first step, the user object, which should be assigned to a tenant, will be edited in the Schema Manager. In our example, User A, B and C are to be assigned to a tenant. These users are based on the User class. Once the class has been selected from the left-hand area of the Schema Manager, an attribute can be created for this purpose via the "Edit menu / New attribute". In our example, we will create the attribute "Organizational assignment". If multiple tenants are assigned to one object (1:n), the "Text" type should be selected for the data field so that a list of tenant memberships can be saved. If there is only a 1:1 relationship and a string field is also selected as a reference attribute, then a string data field can also be used.

So that this attribute can be used to save the tenant ID, the "Contains tenant ID" is activated. Click on "Edit reference" to open a dialog where the reference can be edited.

For our example, we select the class "Organizational unit", because "Organizational unit 1" and "Organizational unit 2" were created on this basis, as was described at the beginning. Any reference attribute can be defined here, meaning not just the LID or GUID, but also any other attribute that contains a unique identification value (e.g. organization abbreviation, cost center). The displayed attribute of the referenced class is also a free choice. In this case, we select the object name. So that User C can be assigned to both tenants, the "Support multiple values" option is selected here.

Close all dialogs with "OK". The tenant dependency has now been configured.

Tenant assignment

In the properties of a user, the tenant can now be assigned on the More attributes tab. To do this, highlight the attribute, which was created for the tenant dependency and click on "Edit value" in the "Value" column.

In our example User A will be assigned to "Organizational unit 1", User B to "Organizational unit 2", and User C to both.

Multi-tenancy in applications

Tenant control in data groups

A strict tenant control is achieved using the tenant filter in data groups. There, the relationship between the user's tenant membership and the data record can be established. There is an n:1 binding directly in the data group or an n:n binding via a child data group, which enables multiple tenant assignments per data record.

Tenant control in filters

There is a new operator available for tables, multiple selections and data pickers: "Is contained in tenants". If the UserID is compared, only the entries assigned to the corresponding tenant will be shown.

Tenant control in distribution lists

In the multiple selection element, you can activate the setting “Users and groups” to select any objects as a distribution list. A filter can be applied to the objects to only provide users or roles for selection that have been assigned to the tenant of the current user, for example.

Groovy API

The Groovy API enables you to

  • create objects for defining tenants and organizational structures

  • create groups, roles, distribution lists and their memberships in other objects

  • edit all objects

  • delete all objects

Here is a script example:

// Create "Organisation"

def strTitle = g_record["GUID"].value /* datafield Title <string> */
def strParentNode = g_record["GUID"].value /* datafield Tenant <string> */

def organization1 = g_om.createContainer ("ORGANIZATION", {
       container      = strParentNode
       NAME           = strTitle
       EXTERNALGUID   = "1235"
       PRIORITY       = 25
       DN             = "testDN"
       DISABLED       = false
       DESCRIPTION    = "Organization created by Groovy around ${new Date()}"
       INTERNALUSN    = 2
       STATE          = "BW"
       POBOX          = "UP"
       STREET         = "UP-Alley"
       CITY           = "Freiburg"
       POSTALCODE     = "79098"
       COUNTRY        = "Germany"

// Create "default roles"
def role1 = g_om.createSet ("ROLE", {
	container      = organization1
	NAME           = strTitle + ": Employee"
	DESCRIPTION    = "Role created by Groovy on ${new Date()}"
	memberOf       = ["Users"]

// Create "additional roles"
def role2 = g_om.createSet ("ROLE", {
	container      = organization1
	NAME           = strTitle + ": User"
	DESCRIPTION    = "Role created by Groovy on ${new Date()}"
	memberOf       = ["Users"]

// Delete roles
// Delete container (All included objects will also be deleted!)

To identify the tenant memberships of a logged-in user and the tenant objects selected for the session, the GroovyTenantHelper is available in the Groovy context. When defining a GroovyTenantHelper object, the current session is stated as a parameter. Furthermore, the GroovyTenantHelper can be used to modify the selection of the active tenants in the session. The variants entered as a character string list (||) enable you to directly edit distribution list and multiple selection information from long text fields.

// Import of class
import de.uplanet.lucy.server.usermanager.groovy.GroovyTenantHelper

// Definition of a new TenantHelper object
def thelper = new  GroovyTenantHelper(g_session)

thelper.getTenants():Set<String>thelper.getSelectedTenants():Set<String>thelper.getAllTenantValues():String seperated by ||
thelper.getSelectedTenantValues():String seperated by ||

// Define an active tenant

// Define multiple active tenants - the definition is made by a list of tenants

//Define multiple active tenants - the definition
// of tenants is made in the form of a list as a string seperated by || 

import de.uplanet.lucy.server.ServerFeature

// Determines the setting in the portal that determines the selection of the active 
// tenants limited to one tenant


Velocity API

The Velocity API enables you to

  • check the tenant membership (user object against tenant object)

  • determine the attributes of an object (tenant, organization, organizational unit, role, group)

## Check for tenant match (user - record)
#set($TenantMembersSelected = $Tenants.getAllTenantValues($Session))
#set($TenantMembersSqlList = $TenantMembersSelected.replace("||", "','") )

#set($stmtTable = $PreparedQuery.prepare($DbConnection, 
$stmtTable.setString(1, $TenantMembersSqlList)
#set($rsTable = $stmtTable.executeQuery())

#foreach($element in $rsTable)
	#set($Title = $element.getStringValue(1))
	$Title <br>#end

## Read object information (attributes)
#set($ObjectGuid = "8808E768D142663695576F533A27E5CAC2739552")
#set($stmtObject = $PreparedQuery.prepare($DbConnection, "SELECT STRIDENT FROM VDSTENANT WHERE STRGUID = ?"))
$stmtObject.setString(1, $ObjectGuid)
#set($ObjectIdent= $stmtObject.executeAndGetScalarStringValue(""))

The following methods are provided for tenants with the $Tenants object:

## List of all tenants of the current user

## List of all selected tenants of the current user/session

## Piped-List of all selected tenants of the current user
$Tenants.getSelectedTenantValues ($Session)

## Number of tenants of the current user

## All tenants of the current user as string list 
## (seperated by ||)

## Number of selected tenants

The following methods can be applied to the list of tenant objects (getTenants / getSelectedTenants):

## Display of the name of the first tenant
#set($TenantList = $Tenants.getTenants($Session))

## Check if first tenant is selected

## ID of the tenant

More information

Parameter dialog

Velocity Docs

Groovy Docs