A while ago I wanted to programmatically create a user and assign him a role. I did not managed to find any post indicating how to do it, so here it goes.
I created an example eSpace, in which there is an 'Employee_List' screen. This screen can only be seen by users with a "myDirectoryUser" role.

So, instead of loggin-in, a user will be asked to sign-up, a password will be randomly generated, and the user will be created and assigned the role.

Keep in mind that since the password was generated automatically, once this user logs-out he will not be able to loggin again.
You can change the password for this users in <your machine>/Users, or you could let the user specify his own password.
Hi joão,

How is it going ?

I just have a few questions ..
I didn't test the behaviour, but when you use it, does it logs you in with the new user automaticly ?
Another thing is, I don't have the encript password action, where do I can find it ?

Congratz, it's a nice post!
Yes, it will login automatically. The User_Login action will do that.

The User_Login will receive a username and a password. If the user and password match, the flow will go on. If the user does not match the password (or the user does not exist), an exception will be thrown with "invalid login".

Please excuse me if I was not clear enough.
Both the User_Login and EncryptPassword belong to the Users eSpace.
By default applications already reference the Users eSpace, but you will have to add a reference to these two actions.

A nice feature would be to automatically send an e-mail to the user, which gave him a link to a screen that allows to change his password. I did not implement this in the demo .oml to keep things simple.

Glad to help :)
Hello Joao, i created a solution with the referenced users espace. When i opened it on another server, it came up with a popup to update my references. It shows the refresh-icons at system, ridgewidget and users. Logically, ik click on each refresh-icon. After i have done that, the reference to the users espace is gone thus creating a number of errors on the missing login-actions from that users espace. 
Why does this happen? I have the users-espace by default, why does it have to be refreshed again and why does it disappear after the refresh?