Class SecurityContext
Manages access to information about the current user and their permissions.
Inheritance
Inherited Members
Namespace: Mediachase.Commerce.Security
Assembly: Mediachase.Commerce.dll
Version: 10.8.0Syntax
public class SecurityContext
Constructors
SecurityContext(ISecurityCheck, IRoleManagement, SecurityRole)
Declaration
[Obsolete("Use SecurityContext.ctor(ISecurityProvider, IRoleManagement, IUserImpersonation). Will remain at least until October 2016.")]
public SecurityContext(ISecurityCheck securityCheck, IRoleManagement roleManager, SecurityRole everyoneRole)
Parameters
Type | Name | Description |
---|---|---|
ISecurityCheck | securityCheck | |
IRoleManagement | roleManager | |
SecurityRole | everyoneRole |
SecurityContext(ISecurityProvider, SecurityEntityProvider, PermissionService, SecurityRole)
Initializes a new instance of the SecurityContext class.
Declaration
[Obsolete("Use SecurityContext.ctor(ISecurityProvider, IRoleManagement, IUserImpersonation). Will remain at least until July 2018.")]
public SecurityContext(ISecurityProvider securityProvider, SecurityEntityProvider securityEntityProvider, PermissionService permissionService, SecurityRole everyoneRole)
Parameters
Type | Name | Description |
---|---|---|
ISecurityProvider | securityProvider | The security provider. |
EPiServer.Security.SecurityEntityProvider | securityEntityProvider | The security entity provider. |
EPiServer.Security.PermissionService | permissionService | The permission service. |
SecurityRole | everyoneRole | The role to return when getting user global roles when PermissionCheckEnable is false. |
SecurityContext(ISecurityProvider, CustomerContext)
Creates a new instance of SecurityContext.
Declaration
[Obsolete("Use SecurityContext.ctor(ISecurityProvider, IRoleManagement, IUserImpersonation). Will remain at least until October 2016.")]
public SecurityContext(ISecurityProvider securityProvider, CustomerContext customerContext)
Parameters
Type | Name | Description |
---|---|---|
ISecurityProvider | securityProvider | The ISecurityProvider instance to use. |
CustomerContext | customerContext | The CustomerContext instance to use. |
Remarks
Some implementations of security providers may implement both the ISecurityCheck and IRoleManagement, but not ISecurityProvider. The SecurityProviderUpgradeProxy class is provided to wrap a class implementing ISecurityCheck and IRoleManagement in a proxy implementing ISecurityProvider, so that that the service locator will know that the two interfaces are implemented by the same class (the configuration file format does not support specifying separate classes for ISecurityCheck and IRoleManagement).
SecurityContext(ISecurityProvider, CustomerContext, IUserImpersonation)
Creates a new instance of SecurityContext.
Declaration
public SecurityContext(ISecurityProvider securityProvider, CustomerContext customerContext, IUserImpersonation userImpersonation)
Parameters
Type | Name | Description |
---|---|---|
ISecurityProvider | securityProvider | The ISecurityProvider instance to use. |
CustomerContext | customerContext | The CustomerContext instance to use. |
EPiServer.Security.IUserImpersonation | userImpersonation | The user impersonation |
Remarks
Some implementations of security providers may implement both the ISecurityCheck and IRoleManagement, but not ISecurityProvider. The SecurityProviderUpgradeProxy class is provided to wrap a class implementing ISecurityCheck and IRoleManagement in a proxy implementing ISecurityProvider, so that that the service locator will know that the two interfaces are implemented by the same class (the configuration file format does not support specifying separate classes for ISecurityCheck and IRoleManagement).
SecurityContext(ISecurityProvider, CustomerContext, SecurityRole)
Creates a new instance of SecurityContext.
Declaration
[Obsolete("Use SecurityContext.ctor(ISecurityProvider, IRoleManagement, IUserImpersonation). Will remain at least until July 2018.")]
public SecurityContext(ISecurityProvider securityProvider, CustomerContext customerContext, SecurityRole everyoneRole)
Parameters
Type | Name | Description |
---|---|---|
ISecurityProvider | securityProvider | The ISecurityProvider instance to use. |
CustomerContext | customerContext | The CustomerContext instance to use. |
SecurityRole | everyoneRole | The role to return when getting user global roles when PermissionCheckEnable is false. |
Fields
Anonymous
Declaration
public static readonly string Anonymous
Field Value
Type | Description |
---|---|
System.String |
Properties
Current
Gets or sets the instance of SecurityContext associated with the current thread or http request.
Declaration
public static SecurityContext Current { get; set; }
Property Value
Type | Description |
---|---|
SecurityContext |
CurrentContactId
Gets the ID of the current user's contact instance.
Declaration
[Obsolete("Use EPiServer.Security.PrincipalInfo.CurrentPrincipal.GetContactId() instead. GetContactId is an extension method in Mediachase.Commerce.Security namespace. Will remain at least until October 2016.")]
public Guid CurrentContactId { get; }
Property Value
Type | Description |
---|---|
System.Guid |
Remarks
Redundant with CurrentUserId
CurrentUser
Gets the instance of System.Web.Security.MembershipUser for the current user.
Declaration
[Obsolete("The system does not consider this property. Instead it uses the property EPiServer.Security.PrincipalInfo.CurrentPrincipal. You can set the value to specific user name by using EPiServer.Security.PrincipalInfo.CurrentPrincipal = new System.Security.Principal.GenericPrincipal(new System.Security.Principal.GenericIdentity(username), null). Will remain at least until October 2016.")]
public virtual MembershipUser CurrentUser { get; set; }
Property Value
Type | Description |
---|---|
System.Web.Security.MembershipUser |
Remarks
If a non-null value is assigned to either CurrentUser or SpecifiedUser, then that value will be returned. If no assignment has been made to either property, or a null value is assigned to either, then the value of LoggedInUser will be returned.
CurrentUserId
Gets the ID of the current user's contact instance.
Declaration
[Obsolete("Use EPiServer.Security.PrincipalInfo.CurrentPrincipal.GetContactId() instead. GetContactId is an extension method in Mediachase.Commerce.Security namespace. Will remain at least until October 2016.")]
public Guid CurrentUserId { get; }
Property Value
Type | Description |
---|---|
System.Guid |
Remarks
Redundant with CurrentContactId.
CurrentUserName
Gets the name of the current user.
Declaration
[Obsolete("Use EPiServer.Security.PrincipalInfo.CurrentPrincipal.Identity.Name instead. Will remain at least until October 2016.")]
public string CurrentUserName { get; }
Property Value
Type | Description |
---|---|
System.String |
CurrentUserProfile
Gets a wrapper for the profile in System.Web.HttpContext.Current, or null if the profile in System.Web.HttpContext.Current is null.
Declaration
public ProfileBase CurrentUserProfile { get; }
Property Value
Type | Description |
---|---|
System.Web.Profile.ProfileBase |
Remarks
This property passes directly into the System.Web namespace. The information provided may be retrieved without use of SecurityContext.
IsPermissionCheckEnable
Gets the value of PermissionCheckEnable from the configured security provider.
Declaration
public bool IsPermissionCheckEnable { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsSecurityScopeEnable
Gets the value of the EnableSecurityScope configuration setting.
Declaration
public bool IsSecurityScopeEnable { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
LoggedInUser
Gets the System.Web.Security.MembershipUser instance for the currently logged in user, or null if the current user is anonymous or unset.
Declaration
[Obsolete("Use Membership.GetUser(EPiServer.Security.PrincipalInfo.CurrentPrincipal.Identity.Name) instead. Will remain at least until October 2016.")]
public MembershipUser LoggedInUser { get; }
Property Value
Type | Description |
---|---|
System.Web.Security.MembershipUser |
Remarks
Setting the value of CurrentUser or SpecifiedUser will not affect the value of this property.
SecurityCheckInstance
Gets the underlying ISecurityCheck provider instance.
Declaration
public ISecurityCheck SecurityCheckInstance { get; }
Property Value
Type | Description |
---|---|
ISecurityCheck |
SecurityManagerInstance
Gets the underlying IRoleManagement provider instance.
Declaration
public IRoleManagement SecurityManagerInstance { get; }
Property Value
Type | Description |
---|---|
IRoleManagement |
SpecifiedUser
Gets an instance of System.Web.Security.MembershipUser that has been explicitly assigned to this instance.
Declaration
[Obsolete("The system does not consider this property. Instead it uses the property EPiServer.Security.PrincipalInfo.CurrentPrincipal. You can set the value to specific user name by using EPiServer.Security.PrincipalInfo.CurrentPrincipal = new System.Security.Principal.GenericPrincipal(new System.Security.Principal.GenericIdentity(username), null). Will remain at least until October 2016.")]
public MembershipUser SpecifiedUser { get; set; }
Property Value
Type | Description |
---|---|
System.Web.Security.MembershipUser |
Remarks
Assigning a non-null value to SpecifiedUser will cause all members operating on the "current user" to operate on the assigned value. Assigning null to SpecifiedUser will revert the "current user" back to using LoggedInUser.
Assigning a value to CurrentUser has the same effects as assigning the same value to SpecifiedUser.
Methods
AssignUserToGlobalRole(MembershipUser, String)
Craetes a global role assignment.
Declaration
[Obsolete("If using Membership use Roles.AddUserToRole(user.UserName, globalRoleName) instead. Otherwise use configured security api. Will remain at least until October 2016.")]
public void AssignUserToGlobalRole(MembershipUser user, string globalRoleName)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Security.MembershipUser | user | The user. |
System.String | globalRoleName | Name of the global role. |
Remarks
The CustomerContact associated with the user must be saved before calling this method. Otherwise contact information might be lost.
CheckCurentUserHaveAllPermissions(IEnumerable<String>)
Declaration
[Obsolete("Use CheckCurrentUserHaveAllPermissions instead. Will remain at least until November 2016.")]
public bool CheckCurentUserHaveAllPermissions(IEnumerable<string> permissions)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | permissions |
Returns
Type | Description |
---|---|
System.Boolean |
CheckCurentUserHaveAllPermissions(IEnumerable<String>, Object)
Declaration
[Obsolete("Use CheckCurrentUserHaveAllPermissions instead. Will remain at least until November 2016.")]
public bool CheckCurentUserHaveAllPermissions(IEnumerable<string> permissions, object securityObj)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | permissions | |
System.Object | securityObj |
Returns
Type | Description |
---|---|
System.Boolean |
CheckCurentUserHaveAnyPermissions(IEnumerable<String>)
Declaration
[Obsolete("Use CheckCurrentUserHaveAnyPermissions instead. Will remain at least until November 2016.")]
public bool CheckCurentUserHaveAnyPermissions(IEnumerable<string> permissions)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | permissions |
Returns
Type | Description |
---|---|
System.Boolean |
CheckCurentUserHaveAnyPermissions(IEnumerable<String>, Object)
Declaration
[Obsolete("Use CheckCurrentUserHaveAnyPermissions instead. Will remain at least until November 2016.")]
public bool CheckCurentUserHaveAnyPermissions(IEnumerable<string> permissions, object securityObj)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | permissions | |
System.Object | securityObj |
Returns
Type | Description |
---|---|
System.Boolean |
CheckCurrentUserHaveAllPermissions(IEnumerable<String>)
Checks if CurrentUser has all of the specified permissions.
Declaration
[Obsolete("Use extension method PrincipalInfo.IsAllPermitted (located in EPiServer.Commerce.Security) instead. Will remain at least until October 2016.")]
public bool CheckCurrentUserHaveAllPermissions(IEnumerable<string> permissions)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | permissions | An enumeration of permissions to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if permission checks are disabled, CurrentUser has the admin role,
or CurrentUser has all of the permissions specified in
|
Remarks
The CustomerContact associated with the current user must be saved before calling this method. Otherwise contact information might be lost.
CheckCurrentUserHaveAllPermissions(IEnumerable<String>, Object)
Checks if CurrentUser has all of the specified permissions.
Declaration
[Obsolete("Use extension method PrincipalInfo.IsAllPermitted (located in EPiServer.Commerce.Security) instead. Will remain at least until October 2016.")]
public bool CheckCurrentUserHaveAllPermissions(IEnumerable<string> permissions, object securityObj)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | permissions | An enumeration of permissions to check. |
System.Object | securityObj | If IsSecurityScopeEnable is true, the value of
|
Returns
Type | Description |
---|---|
System.Boolean | True if permission checks are disabled, CurrentUser has the admin role,
or CurrentUser has all of the permissions specified in
|
Remarks
The CustomerContact associated with the current user must be saved before calling this method. Otherwise contact information might be lost.
CheckCurrentUserHaveAnyPermissions(IEnumerable<String>)
Checks if CurrentUser has any of the specified permissions.
Declaration
[Obsolete("Use extension method PrincipalInfo.IsAnyPermitted (located in EPiServer.Commerce.Security) instead. Will remain at least until October 2016.")]
public bool CheckCurrentUserHaveAnyPermissions(IEnumerable<string> permissions)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | permissions | An enumeration of permissions to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if permission checks are disabled, CurrentUser has the admin role,
or CurrentUser has at least one of the permissions specified in
|
Remarks
The CustomerContact associated with the current user must be saved before calling this method. Otherwise contact information might be lost.
CheckCurrentUserHaveAnyPermissions(IEnumerable<String>, Object)
Checks if CurrentUser has any of the specified permissions.
Declaration
[Obsolete("Use extension method PrincipalInfo.IsAnyPermitted (located in EPiServer.Commerce.Security) instead. Will remain at least until October 2016.")]
public bool CheckCurrentUserHaveAnyPermissions(IEnumerable<string> permissions, object securityObj)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | permissions | An enumeration of permissions to check. |
System.Object | securityObj | If IsSecurityScopeEnable is true, the value of
|
Returns
Type | Description |
---|---|
System.Boolean | True if permission checks are disabled, CurrentUser has the admin role,
or CurrentUser has at least one of the permissions specified in
|
Remarks
The CustomerContact associated with the current user must be saved before calling this method. Otherwise contact information might be lost.
CheckCurrentUserInAnyGlobalRoles(IEnumerable<SecurityRole>)
Checks if CurrentUser has any of the specified global roles.
Declaration
[Obsolete("Use roles.Any(x => PrincipalInfo.CurrentPrincipal.IsInRole(x.RoleName)) instead. Will remain at least until October 2016.")]
public bool CheckCurrentUserInAnyGlobalRoles(IEnumerable<SecurityRole> roles)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<SecurityRole> | roles | The roles to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if CurrentUser has the admin role or any of the specified global roles; otherwise, false. |
Remarks
The CustomerContact associated with the current user must be saved before calling this method. Otherwise contact information might be lost.
CheckCurrentUserInAnyGlobalRoles(IEnumerable<SecurityRole>, Boolean)
Checks if CurrentUser has any of the specified global roles.
Declaration
[Obsolete("Use roles.Any(x => PrincipalInfo.CurrentPrincipal.IsInRole(x.RoleName)) instead. Will remain at least until October 2016.")]
public bool CheckCurrentUserInAnyGlobalRoles(IEnumerable<SecurityRole> roles, bool throwException)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<SecurityRole> | roles | The roles to check. |
System.Boolean | throwException | If true, then the method will throw an exception instead of returning false. |
Returns
Type | Description |
---|---|
System.Boolean | True if CurrentUser has the admin role or any of the specified global roles; otherwise, false. |
Remarks
The CustomerContact associated with the current user must be saved before calling this method. Otherwise contact information might be lost.
CheckCurrentUserInAnyGlobalRoles(IEnumerable<String>)
Checks if CurrentUser has any of the specified global roles.
Declaration
[Obsolete("Use roles.Any(x => PrincipalInfo.CurrentPrincipal.IsInRole(x)) instead. Will remain at least until October 2016.")]
public bool CheckCurrentUserInAnyGlobalRoles(IEnumerable<string> roles)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | roles | The roles to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if CurrentUser has the admin role or any of the specified global roles; otherwise, false. |
Remarks
The CustomerContact associated with the current user must be saved before calling this method. Otherwise contact information might be lost.
CheckCurrentUserInAnyGlobalRoles(IEnumerable<String>, Boolean)
Checks if CurrentUser has any of the specified global roles.
Declaration
[Obsolete("Use roles.Any(x => PrincipalInfo.CurrentPrincipal.IsInRole(x)) instead. Will remain at least until October 2016.")]
public bool CheckCurrentUserInAnyGlobalRoles(IEnumerable<string> roles, bool throwException)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | roles | The roles to check. |
System.Boolean | throwException | If true, then the method will throw an exception instead of returning false. |
Returns
Type | Description |
---|---|
System.Boolean | True if CurrentUser has the admin role or any of the specified global roles; otherwise, false. |
Remarks
The CustomerContact associated with the current user must be saved before calling this method. Otherwise contact information might be lost.
CheckPermissionForCurentUser(String)
Declaration
[Obsolete("Use CheckPermissionForCurrentUser instead. Will remain at least until November 2016.")]
public bool CheckPermissionForCurentUser(string permission)
Parameters
Type | Name | Description |
---|---|---|
System.String | permission |
Returns
Type | Description |
---|---|
System.Boolean |
CheckPermissionForCurentUser(String, Boolean)
Declaration
[Obsolete("Use CheckPermissionForCurrentUser instead. Will remain at least until November 2016.")]
public bool CheckPermissionForCurentUser(string permission, bool throwException)
Parameters
Type | Name | Description |
---|---|---|
System.String | permission | |
System.Boolean | throwException |
Returns
Type | Description |
---|---|
System.Boolean |
CheckPermissionForCurentUser(String, Object)
Declaration
[Obsolete("Use CheckPermissionForCurrentUser instead. Will remain at least until November 2016.")]
public bool CheckPermissionForCurentUser(string permission, object securityObj)
Parameters
Type | Name | Description |
---|---|---|
System.String | permission | |
System.Object | securityObj |
Returns
Type | Description |
---|---|
System.Boolean |
CheckPermissionForCurentUser(String, Object, Boolean)
Declaration
[Obsolete("Use CheckPermissionForCurrentUser instead. Will remain at least until November 2016.")]
public bool CheckPermissionForCurentUser(string permission, object securityObj, bool throwException)
Parameters
Type | Name | Description |
---|---|---|
System.String | permission | |
System.Object | securityObj | |
System.Boolean | throwException |
Returns
Type | Description |
---|---|
System.Boolean |
CheckPermissionForCurrentUser(String)
Checks if CurrentUser has the specified permission.
Declaration
[Obsolete("Use extension method PrincipalInfo.IsPermitted instead. Will remain at least until October 2016.")]
public bool CheckPermissionForCurrentUser(string permission)
Parameters
Type | Name | Description |
---|---|---|
System.String | permission | The permission to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if permission checks are disabled, CurrentUser has the admin role,
or CurrentUser has the permission specified by
|
Remarks
The CustomerContact associated with the current user must be saved before calling this method. Otherwise contact information might be lost.
CheckPermissionForCurrentUser(String, Boolean)
Checks if CurrentUser has the specified permission.
Declaration
[Obsolete("Use extension method PrincipalInfo.ValidatePermission (located in EPiServer.Commerce.Security) instead. Will remain at least until October 2016.")]
public bool CheckPermissionForCurrentUser(string permission, bool throwException)
Parameters
Type | Name | Description |
---|---|---|
System.String | permission | The permission to check. |
System.Boolean | throwException | If true, the method will throw an exception instead of returning false. |
Returns
Type | Description |
---|---|
System.Boolean | True if permission checks are disabled, CurrentUser has the admin role,
or CurrentUser has the permission specified by
|
Remarks
The CustomerContact associated with the current user must be saved before calling this method. Otherwise contact information might be lost.
CheckPermissionForCurrentUser(String, Object)
Checks if CurrentUser has the specified permission.
Declaration
[Obsolete("Use extension method PrincipalInfo.IsPermitted instead. Will remain at least until October 2016.")]
public bool CheckPermissionForCurrentUser(string permission, object securityObj)
Parameters
Type | Name | Description |
---|---|---|
System.String | permission | The permission to check. |
System.Object | securityObj | If IsSecurityScopeEnable is true, the value of
|
Returns
Type | Description |
---|---|
System.Boolean | True if permission checks are disabled, CurrentUser has the admin role,
or CurrentUser has the permission specified by
|
Remarks
The CustomerContact associated with the current user must be saved before calling this method. Otherwise contact information might be lost.
CheckPermissionForCurrentUser(String, Object, Boolean)
Checks if CurrentUser has the specified permission.
Declaration
[Obsolete("Use extension method PrincipalInfo.ValidatePermission (located in EPiServer.Commerce.Security) instead. Will remain at least until October 2016.")]
public bool CheckPermissionForCurrentUser(string permission, object securityObj, bool throwException)
Parameters
Type | Name | Description |
---|---|---|
System.String | permission | The permission to check. |
System.Object | securityObj | If IsSecurityScopeEnable is true, the value of
|
System.Boolean | throwException | If true, the method will throw an exception instead of returning false. |
Returns
Type | Description |
---|---|
System.Boolean | True if permission checks are disabled, CurrentUser has the admin role,
or CurrentUser has the permission specified by
|
Remarks
The CustomerContact associated with the current user must be saved before calling this method. Otherwise contact information might be lost.
CheckPermissionForUser(MembershipUser, String, Object)
Checks if a user has the specified permission.
Declaration
[Obsolete("Use extension method PrincipalInfo.ValidatePermission (located in EPiServer.Commerce.Security) instead. Will remain at least until October 2016.")]
public bool CheckPermissionForUser(MembershipUser user, string permission, object securityObj)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Security.MembershipUser | user | The user the check the permission for. |
System.String | permission | The permission to check. |
System.Object | securityObj | If IsSecurityScopeEnable is true, the value of
|
Returns
Type | Description |
---|---|
System.Boolean | True if permission checks are disabled, |
Remarks
The CustomerContact associated with the user must be saved before calling this method. Otherwise contact information might be lost.
CheckUserInAnyGlobalRoles(MembershipUser, IEnumerable<SecurityRole>)
Checks if user
has any of the specified global roles.
Declaration
[Obsolete("Use roles.Any(x => PrincipalInfo.CreatePrincipal(user.UserName).IsInRole(x.RoleName)) instead. Will remain at least until October 2016.")]
public bool CheckUserInAnyGlobalRoles(MembershipUser user, IEnumerable<SecurityRole> roles)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Security.MembershipUser | user | The user to check roles for. |
System.Collections.Generic.IEnumerable<SecurityRole> | roles | The roles to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if |
Remarks
The CustomerContact associated with the user must be saved before calling this method. Otherwise contact information might be lost.
CheckUserInAnyGlobalRoles(MembershipUser, IEnumerable<SecurityRole>, Boolean)
Checks if user
has any of the specified global roles.
Declaration
[Obsolete("Use roles.Any(x => PrincipalInfo.CreatePrincipal(user.UserName).IsInRole(x.RoleName)) instead. Will remain at least until October 2016.")]
public bool CheckUserInAnyGlobalRoles(MembershipUser user, IEnumerable<SecurityRole> roles, bool throwException)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Security.MembershipUser | user | The user to check roles for. |
System.Collections.Generic.IEnumerable<SecurityRole> | roles | The roles to check. |
System.Boolean | throwException | If true, the method will throw an exception instead of returning false. |
Returns
Type | Description |
---|---|
System.Boolean | True if |
Remarks
The CustomerContact associated with the user must be saved before calling this method. Otherwise contact information might be lost.
CheckUserInAnyGlobalRoles(MembershipUser, IEnumerable<String>)
Checks if user
has any of the specified global roles.
Declaration
[Obsolete("Use roles.Any(x => PrincipalInfo.CreatePrincipal(user.UserName).IsInRole(x)) instead. Will remain at least until October 2016.")]
public bool CheckUserInAnyGlobalRoles(MembershipUser user, IEnumerable<string> roles)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Security.MembershipUser | user | The user to check roles for. |
System.Collections.Generic.IEnumerable<System.String> | roles | The roles to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if |
Remarks
The CustomerContact associated with the user must be saved before calling this method. Otherwise contact information might be lost.
CheckUserInAnyGlobalRoles(MembershipUser, IEnumerable<String>, Boolean)
Checks if user
has any of the specified global roles.
Declaration
[Obsolete("Use roles.Any(x => PrincipalInfo.CreatePrincipal(user.UserName).IsInRole(x)) instead. Will remain at least until October 2016.")]
public bool CheckUserInAnyGlobalRoles(MembershipUser user, IEnumerable<string> roles, bool throwException)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Security.MembershipUser | user | The user to check roles for. |
System.Collections.Generic.IEnumerable<System.String> | roles | The roles to check. |
System.Boolean | throwException | If true, the method will throw an exception instead of returning false. |
Returns
Type | Description |
---|---|
System.Boolean | True if |
Remarks
The CustomerContact associated with the user must be saved before calling this method. Otherwise contact information might be lost.
CheckUserInGlobalRole(MembershipUser, String)
Checks if user
has the specified global role.
Declaration
[Obsolete("Use PrincipalInfo.CreatePrincipal(user.UserName).IsInRole(roleName)) instead. Will remain at least until October 2016.")]
public bool CheckUserInGlobalRole(MembershipUser user, string roleName)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Security.MembershipUser | user | The user to check roles for. |
System.String | roleName | The role name to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if |
Remarks
The CustomerContact associated with the user must be saved before calling this method. Otherwise contact information might be lost.
CreateInstance()
Declaration
[Obsolete("Configure and instantiate instance of SecurityContext with the service locator. Will remain at least until November 2016.")]
public static SecurityContext CreateInstance()
Returns
Type | Description |
---|---|
SecurityContext |
CreateInstance(ISecurityCheck, IRoleManagement)
Declaration
[Obsolete("Configure and instantiate instance of SecurityContext with the service locator. Will remain at least until November 2016.")]
public static SecurityContext CreateInstance(ISecurityCheck securityCheck, IRoleManagement roleManager)
Parameters
Type | Name | Description |
---|---|---|
ISecurityCheck | securityCheck | |
IRoleManagement | roleManager |
Returns
Type | Description |
---|---|
SecurityContext |
CreateInstance(ISecurityCheck, IRoleManagement, SecurityRole)
Declaration
[Obsolete("Configure and instantiate instance of SecurityContext with the service locator. Will remain at least until November 2016.")]
public static SecurityContext CreateInstance(ISecurityCheck securityCheck, IRoleManagement roleManager, SecurityRole everyoneRole)
Parameters
Type | Name | Description |
---|---|---|
ISecurityCheck | securityCheck | |
IRoleManagement | roleManager | |
SecurityRole | everyoneRole |
Returns
Type | Description |
---|---|
SecurityContext |
CreateInstance(String)
Declaration
[Obsolete("Configure and instantiate instance of SecurityContext with the service locator. Will remain at least until November 2016.")]
public static SecurityContext CreateInstance(string providerName)
Parameters
Type | Name | Description |
---|---|---|
System.String | providerName |
Returns
Type | Description |
---|---|
SecurityContext |
CreateUserRoleAssignments(SecurityRoleAssignment)
Creates the user role assignments.
Declaration
[Obsolete("If using Membership use Roles.CreateRole(roleAssignment.RoleName); instead. Otherwise use configured security api. Will remain at least until October 2016.")]
public void CreateUserRoleAssignments(SecurityRoleAssignment roleAssignment)
Parameters
Type | Name | Description |
---|---|---|
SecurityRoleAssignment | roleAssignment | The role assignment. |
Remarks
This method is a direct pass-through to CreateUserRoleAssignments(SecurityRoleAssignment).
DeleteUserAndAllRelatedData(MembershipUser)
Deletes the user and all related data.
Declaration
public void DeleteUserAndAllRelatedData(MembershipUser user)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Security.MembershipUser | user | The user to delete. |
DeployPrincipalByUser(MembershipUser)
Deploys the principal by user.
Declaration
public IEnumerable<Principal> DeployPrincipalByUser(MembershipUser user)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Security.MembershipUser | user | The user. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Principal> |
Remarks
This method is a direct pass through to DeployPrincipalByUser(MembershipUser). The CustomerContact associated with the user must be saved before calling this method. Otherwise contact information might be lost.
GetAllCurrentUserGlobalRoles()
Enumerates all global roles for CurrentUser.
Declaration
[Obsolete("Use PrincipalInfo.Current.RoleList instead. Will remain at least until October 2016.")]
public IEnumerable<SecurityRole> GetAllCurrentUserGlobalRoles()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<SecurityRole> | An System.Collections.Generic.IEnumerable<T> enumerating the roles assigned to CurrentUser. |
Remarks
The CustomerContact associated with the current user must be saved before calling this method. Otherwise contact information might be lost.
GetAllRegisteredRoles()
Enumerates all registered roles in system.
Declaration
[Obsolete("Use ServiceLocator.Current.GetInstance<SecurityEntityProvider>().SearchRoles(null) instead. Will remain at least until October 2016.")]
public IEnumerable<SecurityRole> GetAllRegisteredRoles()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<SecurityRole> | An System.Collections.Generic.IEnumerable<T> enumerating all registered roles in the system. |
GetAllUserGlobalRoles(MembershipUser)
Enumerates all global roles for the specified user.
Declaration
[Obsolete("Use ServiceLocator.Current.GetInstance<SecurityEntityProvider>().GetRolesForUser(user.UserName) instead. Will remain at least until October 2016.")]
public IEnumerable<SecurityRole> GetAllUserGlobalRoles(MembershipUser user)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Security.MembershipUser | user | The user to get roles for. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<SecurityRole> | An System.Collections.Generic.IEnumerable<T> enumerating the roles assigned to
|
Remarks
The CustomerContact associated with the user must be saved before calling this method. Otherwise contact information might be lost.
GetCurrentUserComplexKey(String)
Declaration
[Obsolete("This method is unused and will be removed in a future version. Will remain at least until November 2016.")]
public string GetCurrentUserComplexKey(string prefix)
Parameters
Type | Name | Description |
---|---|---|
System.String | prefix |
Returns
Type | Description |
---|---|
System.String |
GetPrincipalByUser(MembershipUser)
Gets the principal by user.
Declaration
public Principal GetPrincipalByUser(MembershipUser user)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Security.MembershipUser | user | The user. |
Returns
Type | Description |
---|---|
Principal |
Remarks
This method is a direct pass-through to CreateUserRoleAssignments(SecurityRoleAssignment). The CustomerContact associated with the user must be saved before calling this method. Otherwise contact information might be lost.
GetProfileByUserProviderKey(Guid)
Gets the System.Web.Profile.ProfileBase for the user specified by userProviderKey
.
Declaration
public ProfileBase GetProfileByUserProviderKey(Guid userProviderKey)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | userProviderKey | The ID of the desired user. |
Returns
Type | Description |
---|---|
System.Web.Profile.ProfileBase | A System.Web.Profile.ProfileBase for the user specified by
|
GetSecuritySystemVersion(out Int32, out Int32, out Int32, out DateTime)
Declaration
[Obsolete("Security Schema Version is no longer used. Will remain at least until October 2016.")]
public static int GetSecuritySystemVersion(out int major, out int minor, out int patch, out DateTime installDate)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | major | |
System.Int32 | minor | |
System.Int32 | patch | |
System.DateTime | installDate |
Returns
Type | Description |
---|---|
System.Int32 |
ListAllUserRoleAssignments(MembershipUser)
Lists all user role assignments.
Declaration
[Obsolete("Use ServiceLocator.Current.GetInstance<SecurityEntityProvider>().GetRolesForUser(user.UserName) instead. Will remain at least until October 2016.")]
public IEnumerable<SecurityRoleAssignment> ListAllUserRoleAssignments(MembershipUser user)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Security.MembershipUser | user | The user to get role assignments for. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<SecurityRoleAssignment> | An System.Collections.Generic.IEnumerable<T> enumerating the role assignments
for |
Remarks
The CustomerContact associated with the user must be saved before calling this method. Otherwise contact information might be lost.
RemoveUserRoleAssignments(SecurityRoleAssignment)
Removes the user role assignments.
Declaration
[Obsolete("If using Membership use Roles.DeleteRole(roleAssignment.RoleName); instead. Otherwise use configured security api. Will remain at least until October 2016.")]
public void RemoveUserRoleAssignments(SecurityRoleAssignment roleAssignment)
Parameters
Type | Name | Description |
---|---|---|
SecurityRoleAssignment | roleAssignment | The role assignment. |
Remarks
This method is a direct pass-through to RemoveUserRoleAssignments(SecurityRoleAssignment).
ValidateMembershipUserPassword(String)
Validates the membership user password against the strong password requirements.
Declaration
public static UserPasswordValidationResult ValidateMembershipUserPassword(string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | password | The password to validate. |
Returns
Type | Description |
---|---|
UserPasswordValidationResult | A UserPasswordValidationResult value indicating the results of the validation. |