Class UserPlugin
Default implementation of User Name Plugins. Overrides must be declared with UserPluginAttribute and a priority greater than 0.
Implements
Namespace: SuperOffice.CRM.Administration
Assembly: SoDataBase.dll
Syntax
[UserPlugin("DefaultUserPlugin", 1073741823)]
public class UserPlugin : Object, IUserPlugin, IPlugin
Constructors
UserPlugin()
Default implementation of User Name Plugins. Overrides must be declared with UserPluginAttribute and a priority greater than 0.
Declaration
public UserPlugin()
Methods
ExtractEmail(Person, CheckIfAssociateNameIsLegal)
Extract e-mail from a person. If no valid e-mail is found, we try to fake something.
Declaration
protected virtual string ExtractEmail(Person person, CheckIfAssociateNameIsLegal validator)
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. |
Returns
Type | Description |
---|---|
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.
GetDefaultAssociateName(UserType, Person, CheckIfAssociateNameIsLegal)
Get default user name for a user.
Declaration
public virtual string GetDefaultAssociateName(UserType type, Person person, 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. |
CheckIfAssociateNameIsLegal | validator | Validator to help check if the a user name is valid. |
Returns
Type | Description |
---|---|
String | Default user name validated with the provided CheckIfAssociateNameIsLegal delegate. |
GetDefaultAssociateUserName(UserType, Person, CheckIfAssociateNameIsLegal)
Default implementation of User Name Plugins. Overrides must be declared with UserPluginAttribute and a priority greater than 0.
Declaration
public virtual string GetDefaultAssociateUserName(UserType type, Person person, CheckIfAssociateNameIsLegal validator)
Parameters
Type | Name | Description |
---|---|---|
UserType | type | |
Person | person | |
CheckIfAssociateNameIsLegal | validator |
Returns
Type | Description |
---|---|
String |
GetDefaultExternalUserName(Person, CheckIfAssociateNameIsLegal)
Get user name for an external user based on ExtractEmail(Person, CheckIfAssociateNameIsLegal)
Declaration
protected virtual string GetDefaultExternalUserName(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 external user based on ExtractEmail(Person, CheckIfAssociateNameIsLegal). |
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 |
---|---|
Int32 | 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 |
---|---|
Int32 | 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 |
---|---|
Int32[] | 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.
GetValidAssociateName(UserType, Person, String, CheckIfAssociateNameIsLegal)
Default implementation of User Name Plugins. Overrides must be declared with UserPluginAttribute and a priority greater than 0.
Declaration
public virtual string GetValidAssociateName(UserType type, Person person, string userName, CheckIfAssociateNameIsLegal validator)
Parameters
Type | Name | Description |
---|---|---|
UserType | type | |
Person | person | |
String | userName | |
CheckIfAssociateNameIsLegal | validator |
Returns
Type | Description |
---|---|
String |
GetValidAssociateUserName(UserType, Person, String, CheckIfAssociateNameIsLegal)
Default implementation of User Name Plugins. Overrides must be declared with UserPluginAttribute and a priority greater than 0.
Declaration
public virtual string GetValidAssociateUserName(UserType type, Person person, string associateUserName, CheckIfAssociateNameIsLegal validator)
Parameters
Type | Name | Description |
---|---|---|
UserType | type | |
Person | person | |
String | associateUserName | |
CheckIfAssociateNameIsLegal | validator |
Returns
Type | Description |
---|---|
String |
ProcessProvidedAssociateName(String, Int32, 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 |
Int32 | 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, Int32, UserType, Person, CheckIfAssociateNameIsLegal)
Default implementation of User Name Plugins. Overrides must be declared with UserPluginAttribute and a priority greater than 0.
Declaration
public virtual string ProcessProvidedAssociateUserName(string providedAssociateUserName, int associateId, UserType type, Person person, CheckIfAssociateNameIsLegal validator)
Parameters
Type | Name | Description |
---|---|---|
String | providedAssociateUserName | |
Int32 | associateId | |
UserType | type | |
Person | person | |
CheckIfAssociateNameIsLegal | validator |
Returns
Type | Description |
---|---|
String |