What is the principal ?

Estimated reading: 1 minute

The principal is your current user authenticate and authorize

//Once user is authenticated in runtime, you can access current principal using runtime.Principal.
var currentPrincipal = runtime.Principal;

//list of roles granted to the user for current application
var grantedRoles = currentPrincipal.Roles;

//list of permissions granted to the user for current application
var permissions = currentPrincipal.GetAllCurrentPermissions();

//list of selectable contextual groups
var contextualGroups = currentPrincipal.ContextualGroups;

//list of groups which are directly assigned to users
var grantedGroups = currentPrincipal.GrantedGroups

//list of groups which are directly assigned and also their descendant groups
var allgroups = currentPrincipal.Groups

//gets a list of profile values for current principal
var profileValues = currentPrincipal.ProfileValues 

//change profile values for principal
//where attributeId is propertyId of attribute
currentPrincipal.ProfileValues.SetValue(attributeId, 15);
currentPrincipal.ProfileValues.SetValue(attributeId, "HelloWorld");

//save/update profilevalues for current principal

Leave a Comment

Share this Doc