Set default role for new user upon registration in genexus - genexus

How can we set a default role for new user upon registration in genexus?
I have a registration page wherein a new user can create their account on their own. I want to set their default role on that registration process.

in the repository configuration you have this option:
It is the role that will be used by default for all users.
Another option is to subscribe to the new user event
and configure a procedure that adds the roles you need and eventually any other action you need at that time
This is a bit more advanced, you will find more details here
GAM Events subscription

Related

Outsystems:Is it possible to have same user in different tenants in a Multi-tenant application

I created a multi-tenant application where each tenant have different set of users. I am trying to implement a functionality where same user might exist in different tenants. Does outsystems provide such functionality or I have to create my custom logic ?
Right now, I did create a user having same username in 2 different tenants and during login I am showing user to select tenants. But on changing tenants and logging to that tenant, the environment doesn't switch to that tenant that user has selected.
Below is the image of the logic of switching tenants and logging in the customer.
During debugging I saw that after executing TenantSwitch action it did change the Site.TenantID property but after User_Login action is reverted to the first tenant not the one user selected.
When you use User_Login(), the system will log you in the first Tenant it finds in the DB that has that username, thus ignoring your TenantSwitch().
So, if you want to login to a specific Tenant in your case, you need to be more explicit and instead use the Login() action - after the tenant switch.
For a thorough explanation of this, with example code, please check out the following deepdive Master Class on Multi-Tenancy starting around the 27:20 minute mark.
This isn't available out of the box as OutSystems assigns users (and all entities) to a specific tenant. Entities belonging to single tenanted modules are assigned to the default tenant.
OutSystems uses a hidden .Tenant_Id attribute on each entity to indicate which tenant that user belongs to. You can unhide this attribute for the users entity by selecting it, clicking More... and then ticking the relevant box in the Advanced tab. You can then access the attribute directly, but be aware this will hinder OutSystems' ability to do some of the stuff it does automatically to ensure that you access tenant specific data.
When you use the User_Login action OutSystems will deduce which tenant to use from the User.Tenant_Id attribute regardless of which tenant you've switched it to previously. The user would need an account for each tenant they need to use, but there's no reason this couldn't be done behind the scenes with OS fetching the correct username before logging in. You'd need to ensure they all stay in sync though, especially the passwords ofc.

Check user roles from Application Service

i'm implementing Application Service that sends statistical data to home page (dashboard application page).
Based on User's Role (the service needs authentication) i would extract/aggregate data from database using WhereIf() based on is role
In particular if user is administrator, I will not apply a data extraction filter using WhereIf()
To do that i've injected IAbpSession inside service constructor to be able to give userid, but how can i ckeck if user is an administrator?
You can check if current user is an administrator by checking the associated roles of that user. You must inject the UserManager which has several methods for role checking. One of them is IsInRole(userId, roleName).

Play authenticate create roles and signup page for different roles

Please am using Play authenticate play framework and am trying to create many roles and how to create different signup and login form for each role i created.
You don't have to create different signup for every role. Role is assign to user after the user get created. Assigning of role should be handle by admin and super user. So I would suggest you initially don't assign any role or give the lowest priority role. And then make the user ask the admin for a particular role.
But if you really want to assign user a role during sign up you can add a dropdown field in your form which contains the values of all the roles and assign the role while creating the user.
I hope this answer your question.

How to mark api-created Okta users as being provided by Active Directory

We’re currently running the Okta Active Directory agent in order to import our users into Okta.
I'd like to replace this with a custom built process that imports users into a new internal database, for other user-management-related activities, whilst also adding those users to Okta.
Creating the user in Okta is easy, but I also need to get the user's "provider" set to ACTIVE_DIRECTORY, so that Okta delegates authentication to Active Directory.
The documentation (http://developer.okta.com/docs/api/resources/users.html#provider-object) says that the User's Provider field is read-only.
How can I set it?
While you cannot directly manipulate the credential object you can leverage other features available to achieve the desired result.
Create a group in Okta and configure it as a directory provisioning group. From the designated group select 'Manage Directories' add the desired Directory and follow the wizard to completion.
Add the created users to the group (using the API)
You unfortunately cannot set this property as we do not allow the creation of Active Directory users through the public API at this point.
If the purpose of the new process is simply to enrich the user's profile, can't you not achieve this by letting the AD agent sync the users and enrich the profile directly through the API?

How do I create a user in AD and Okta?

How do I automatically create a user in Active Directory, at the same time as creating the user in Okta. Is there an API/SDK to do this ?
You can use the Create User call to create a User in Okta. Additionally, you can add this user to a group.
Upon membership in this specific group which should be configured with AD as the provisioning target, the group members are provisioned in AD (or any other application as per configuration).

Resources