Show / Hide Table of Contents

Class UserPlugin

Default implementation of User Name Plugins. Overrides must be declared with UserPluginAttribute and a priority greater than 0.

Inheritance
object
UserPlugin
Implements
IUserPlugin
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: SuperOffice.CRM.Administration
Assembly: SoDataBase.dll
Syntax
[UserPlugin("DefaultUserPlugin", 1073741823)]
public class UserPlugin : IUserPlugin

Constructors

UserPlugin()

Default implementation of User Name Plugins. Overrides must be declared with UserPluginAttribute and a priority greater than 0.

Declaration
public UserPlugin()

Methods

ExtractEmailAsync(Person, CheckIfAssociateNameIsLegal, CancellationToken)

Extract e-mail from a person. If no valid e-mail is found, we try to fake something.

Declaration
protected virtual Task<string> ExtractEmailAsync(Person person, CheckIfAssociateNameIsLegal validator, CancellationToken cancellationToken = default)
Parameters
Type Name Description
Person person

Person to extract e-mail from.

CheckIfAssociateNameIsLegal validator

Validator to help check if the a user name is valid.

CancellationToken cancellationToken
Returns
Type Description
Task<string>

Extracted e-mail from a person. If no valid e-mail was found, we tried to fake something.

ExtractFirstName(string)

Use the ExtractNamePart(string) to process the first name.

Declaration
protected virtual string ExtractFirstName(string namePart)
Parameters
Type Name Description
string namePart

The name part to process.

Returns
Type Description
string

Processed name part.

ExtractLastName(string)

Use the ExtractNamePart(string) to process the last name.

Declaration
protected virtual string ExtractLastName(string namePart)
Parameters
Type Name Description
string namePart

The name part to process.

Returns
Type Description
string

Processed name part.

ExtractMiddleName(string)

Use the ExtractNamePart(string) to process the middl name.

Declaration
protected virtual string ExtractMiddleName(string namePart)
Parameters
Type Name Description
string namePart

The name part to process.

Returns
Type Description
string

Processed name part.

ExtractName(Person)

Extract a name from the person

Declaration
protected virtual string ExtractName(Person person)
Parameters
Type Name Description
Person person

Person to extract name from

Returns
Type Description
string

User name extracted from a person.

Remarks

Takes first, midle and last names and procces them induvidually and appending '.' between the name parts.

ExtractNamePart(string)

Replace invalid characters with empty strings.

Declaration
protected virtual string ExtractNamePart(string namePart)
Parameters
Type Name Description
string namePart

The name part to process.

Returns
Type Description
string

Processed name part.

FindFirstValidated(string, CheckIfAssociateNameIsLegal)

Find the first available user name by appending a number.

Declaration
protected virtual string FindFirstValidated(string baseUserName, CheckIfAssociateNameIsLegal validator)
Parameters
Type Name Description
string baseUserName

Base user name.

CheckIfAssociateNameIsLegal validator
Returns
Type Description
string

User name in the form of baseName+number where number > 0

Remarks

The validator will be provided with the base name pluss a number starting at 1. This number will be incremented untill a valid user name can be provided. Gives up when number 1000 is reached

GetDefaultAnonymousUserName(CheckIfAssociateNameIsLegal)

Get default name for anonymous users.

Declaration
protected virtual string GetDefaultAnonymousUserName(CheckIfAssociateNameIsLegal validator)
Parameters
Type Name Description
CheckIfAssociateNameIsLegal validator

Validator to help check if the a user name is valid.

Returns
Type Description
string

Default name for validated using the validator.

Remarks

The FindFirstValidated(string, CheckIfAssociateNameIsLegal) is used passing in Anonymous as base name.

GetDefaultAssociateNameAsync(UserType, Person, CheckIfAssociateNameIsLegal, CancellationToken)

Get default user name for a user.

Declaration
public virtual Task<string> GetDefaultAssociateNameAsync(UserType type, Person person, CheckIfAssociateNameIsLegal validator, CancellationToken cancellationToken = default)
Parameters
Type Name Description
UserType type

Type of user.

Person person

Person this is a user for. This value will be null (VB Noting) for System and Anonymous users.

CheckIfAssociateNameIsLegal validator

Validator to help check if the a user name is valid.

CancellationToken cancellationToken
Returns
Type Description
Task<string>

Default user name validated with the provided CheckIfAssociateNameIsLegal delegate.

GetDefaultAssociateUserNameAsync(UserType, Person, CheckIfAssociateNameIsLegal, CancellationToken)

Get default associate user name for a user.

Declaration
public virtual Task<string> GetDefaultAssociateUserNameAsync(UserType type, Person person, CheckIfAssociateNameIsLegal validator, CancellationToken cancellationToken = default)
Parameters
Type Name Description
UserType type

Type of user.

Person person

Person this is a user for. This value will be null (VB Noting) for System and Anonymous users.

CheckIfAssociateNameIsLegal validator

Validator to help check if the an associate user name is valid.

CancellationToken cancellationToken
Returns
Type Description
Task<string>

Default associate user name validated with the provided CheckIfAssociateNameIsLegal delegate.

GetDefaultExternalUserNameAsync(Person, CheckIfAssociateNameIsLegal, CancellationToken)

Get user name for an external user based on ExtractEmail

Declaration
protected virtual Task<string> GetDefaultExternalUserNameAsync(Person person, CheckIfAssociateNameIsLegal validator, CancellationToken cancellationToken = default)
Parameters
Type Name Description
Person person

Person to get user name for.

CheckIfAssociateNameIsLegal validator

Validator to help check if the a user name is valid.

CancellationToken cancellationToken
Returns
Type Description
Task<string>

User name for an external user based on ExtractEmail.

Remarks

FindFirstValidated(string, CheckIfAssociateNameIsLegal) ia used to validate the name.

GetDefaultInternalUserName(Person, CheckIfAssociateNameIsLegal)

Get user name for an internal user based on ExtractName(Person).

Declaration
protected virtual string GetDefaultInternalUserName(Person person, CheckIfAssociateNameIsLegal validator)
Parameters
Type Name Description
Person person

Person to get user name for.

CheckIfAssociateNameIsLegal validator

Validator to help check if the a user name is valid.

Returns
Type Description
string

User name for an internal user.

Remarks

FindFirstValidated(string, CheckIfAssociateNameIsLegal) ia used to validate the name.

GetDefaultPrimaryGroup(UserType, Person)

Get default primary group for the user.

Declaration
public int GetDefaultPrimaryGroup(UserType type, Person person)
Parameters
Type Name Description
UserType type

Type of user.

Person person

Person this is a user for. This value will be null (VB Noting) for System and Anonymous users.

Returns
Type Description
int

Default primary group id.

GetDefaultRole(UserType, Person)

Get default role id for the user

Declaration
public int GetDefaultRole(UserType type, Person person)
Parameters
Type Name Description
UserType type

Type of user.

Person person

Person this is a user for. This value will be null (VB Noting) for System and Anonymous users.

Returns
Type Description
int

Default role id for the user.

GetDefaultSecondaryGroups(UserType, Person)

Get default secondary groups for the user

Declaration
public int[] GetDefaultSecondaryGroups(UserType type, Person person)
Parameters
Type Name Description
UserType type

Type of user.

Person person

Person this is a user for. This value will be null (VB Noting) for System and Anonymous users.

Returns
Type Description
int[]

Default secoundary group ids

GetDefaultSystemUserName(CheckIfAssociateNameIsLegal)

Get default name for system users.

Declaration
protected virtual string GetDefaultSystemUserName(CheckIfAssociateNameIsLegal validator)
Parameters
Type Name Description
CheckIfAssociateNameIsLegal validator

Validator to help check if the a user name is valid.

Returns
Type Description
string

Default name for validated using the validator.

Remarks

The FindFirstValidated(string, CheckIfAssociateNameIsLegal) is used passing in System as base name.

GetValidAssociateNameAsync(UserType, Person, string, CheckIfAssociateNameIsLegal, CancellationToken)

Get valid associate name for a user.

Declaration
public virtual Task<string> GetValidAssociateNameAsync(UserType type, Person person, string userName, CheckIfAssociateNameIsLegal validator, CancellationToken cancellationToken = default)
Parameters
Type Name Description
UserType type

Type of user.

Person person

Person this is a user for. This value will be null (VB Noting) for System and Anonymous users.

string userName
CheckIfAssociateNameIsLegal validator

Validator to help check if the an associate name is valid.

CancellationToken cancellationToken
Returns
Type Description
Task<string>

Default associate name validated with the provided CheckIfAssociateNameIsLegal delegate.

GetValidAssociateUserName(UserType, Person, string, CheckIfAssociateNameIsLegal)

Get valid associate user name for a user.

Declaration
public virtual string GetValidAssociateUserName(UserType type, Person person, string associateUserName, CheckIfAssociateNameIsLegal validator)
Parameters
Type Name Description
UserType type

Type of user.

Person person

Person this is a user for. This value will be null (VB Noting) for System and Anonymous users.

string associateUserName

Candidate for user name.

CheckIfAssociateNameIsLegal validator

Validator to help check if the an associate name is valid.

Returns
Type Description
string

Default associate user name validated with the provided CheckIfAssociateNameIsLegal delegate.

ProcessProvidedAssociateName(string, int, UserType, Person, CheckIfAssociateNameIsLegal)

Default implementation returning the name provided.

Declaration
public virtual string ProcessProvidedAssociateName(string providedUserName, int associateId, UserType type, Person person, CheckIfAssociateNameIsLegal validator)
Parameters
Type Name Description
string providedUserName

Provided user name

int associateId

Associate id of the user. The value 0 will be provided for new users.

UserType type

Type of user

Person person

Person this is a user for. This value will be null (VB Noting) for System and Anonymous users.

CheckIfAssociateNameIsLegal validator

Validator to help check if the a user name is valid.

Returns
Type Description
string

User name validated with the provided CheckIfAssociateNameIsLegal delegate.

ProcessProvidedAssociateUserName(string, int, UserType, Person, CheckIfAssociateNameIsLegal)

Process a provided associate user name and allow modifications of an associate user name.

Declaration
public virtual string ProcessProvidedAssociateUserName(string providedAssociateUserName, int associateId, UserType type, Person person, CheckIfAssociateNameIsLegal validator)
Parameters
Type Name Description
string providedAssociateUserName

Provided associate user name

int associateId

Associate id of the user. The value 0 will be provided for new users.

UserType type

Type of user

Person person

Person this is a user for. This value will be null (VB Noting) for System and Anonymous users.

CheckIfAssociateNameIsLegal validator

Validator to help check if the an associate name is valid.

Returns
Type Description
string

Associate user name validated with the provided CheckIfAssociateNameIsLegal delegate.

Remarks

The user name provided is guaranteed to meet the requirements set forth by teh provided validator.

Implements

IUserPlugin

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