Obtaining current logged in user with a script

You can obtain the currently logged in user in the following way.

Script with PublicAPI

Documentation on PublicAPI is available here
The script below is relevant for ELMA up to 3.12.1 inclusive.

Context variable:

Context.CurUser - User type variable
using EleWise.ELMA.API;

Script text:

context.CurUser = PublicAPI.Portal.Security.User.GetCurrentUser();
Starting from ELMA 3.8 there is a service for obtaining the current user
var curUser = PublicAPI.Services.Authentication.GetCurrentUser();

Script without PublicAPI

For correct functioning of the script you need the following namespaces:

using EleWise.ELMA.Security.Models;
using EleWise.ELMA.Security.Services;

Script text:

context.CurUser = (User)AuthenticationService.GetCurrentUser<EleWise.ELMA.Security.Models.IUser>();
where context.CurUser is the context variable of the User type that will store the value.