Show / Hide Table of Contents

Class SoImpersonationContext

Utility class assisting with impersonation. Impersonation is only permitted if a system user is logged in using CRM5 username and password and the user that is impersonated is an employee or external person.

Inheritance
Object
SoImpersonationContext
Implements
IDisposable
Namespace: SuperOffice.Security
Assembly: SoCore.dll
Syntax
public sealed class SoImpersonationContext : Object, IDisposable

Properties

ImpersonatedPrincipal

Principal of the impersonated user.

Declaration
public SoPrincipal ImpersonatedPrincipal { get; }
Property Value
Type Description
SoPrincipal

RealPrincipal

Principle of the impersonating user.

Declaration
public SoPrincipal RealPrincipal { get; }
Property Value
Type Description
SoPrincipal

Methods

CanImpersonate()

Check if the currently logged in user is permitted to impersonate.

Declaration
public static bool CanImpersonate()
Returns
Type Description
Boolean

True if the currently logged in user is permitted to impersonate.

CanImpersonate(SoPrincipal)

Check if the user represented by the provided principle is permitted to impersonate.

Declaration
public static bool CanImpersonate(SoPrincipal impersonator)
Parameters
Type Name Description
SoPrincipal impersonator

The user to check if it has the permission to impersonate

Returns
Type Description
Boolean

True if the user represented by the provided principle is permitted to impersonate.

Dispose()

Dispose of the SoImpersonationContext and implcitly call Revert().

Declaration
public void Dispose()

Impersonate(String)

Impersonate as the user with the provided user name. Only users of type System logged in with username and passwords are permitted to impersonate. Call Dispose() or Revert(). Impersonation is not supported with remote mode.

Declaration
public static SoImpersonationContext Impersonate(string user)
Parameters
Type Name Description
String user

Name of the user to impersonate as.

Returns
Type Description
SoImpersonationContext

Disposable context for the impersonation.

Remarks

Impersonation lives in the thread scope. Threads executed with the SpawnThread<TArgument>(AsyncOperation<TArgument>, TArgument, String) or SpawnThread<TArgument>(AsyncOperation<TArgument>, TArgument, String, Boolean, Boolean, Boolean) will also be executed inside the scope of the impersonated user. It is not permitted to log out using Close() or in any other way end the current session like calling Suspend() while in a impersonated state.

Revert()

Revert impersonation.

Declaration
public void Revert()

Implements

System.IDisposable

Extension Methods

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