Show / Hide Table of Contents

Class SoContext

Class holding context information about the currently logged on user.

Inheritance
object
SoContext
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
Namespace: SuperOffice
Assembly: SoCore.dll
Syntax
public sealed class SoContext
Examples

Log in and get the users home country:

SoSession session = SoSession.Authenticate("user", "password");
int countryId = SoContext.CurrentPrincipal.GetHomeCountryId();
session.Close();

Constructors

SoContext()

Class holding context information about the currently logged on user.

Declaration
public SoContext()
Examples

Log in and get the users home country:

SoSession session = SoSession.Authenticate("user", "password");
int countryId = SoContext.CurrentPrincipal.GetHomeCountryId();
session.Close();

Properties

CurrentIdentity

Obtain the current identity

Declaration
[Obsolete("Get ClaimsIdentity through SuperOffice.SoContext.CurrentPrincipal.GetClaimsIdentity() instead.")]
public static ClaimsIdentity CurrentIdentity { get; }
Property Value
Type Description
ClaimsIdentity

CurrentPrincipal

Obtain the current principal

Declaration
public static ClaimsPrincipal CurrentPrincipal { get; }
Property Value
Type Description
ClaimsPrincipal

IsAuthenticated

True if authenticated

Declaration
public static bool IsAuthenticated { get; }
Property Value
Type Description
bool

Methods

CloseCurrentSession()

Close any open session. Does nothing if the current session is already closed.

Declaration
public static void CloseCurrentSession()
Remarks

Will no longer throw an exception if called twice.

ToString()

If there is a valid principal, return his ToString() - generally for debug purposes. An empty string is returned if there is no valid principal (_currentPrincipal returned null).

Declaration
public override string ToString()
Returns
Type Description
string

Current principal's ToString, or string.Empty if the current SoPrincipal is null

Overrides
object.ToString()

Extension Methods

EnumUtil.MapEnums<From, To>(From)
Converters.MapEnums<From, To>(From)
ObjectExtensions.AssignByReflection<T>(T, T)
ObjectExtensions.GraphCopy<T>(T)
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top