Just Code‎ > ‎

EPiServer Virtual role

posted Jan 18, 2010, 4:07 PM by Peter Henell
<virtualRoles replacePrincipal="true">
      <providers>
        <add name="Administrators"
             type="EPiServer.Security.WindowsAdministratorsRole, EPiServer"/>
        <add name="Everyone"
             type="EPiServer.Security.EveryoneRole, EPiServer"/>
        <add name="Authenticated"
             type="EPiServer.Security.AuthenticatedRole, EPiServer"/>
        <add name="Anonymous"
             type="EPiServer.Security.AnonymousRole, EPiServer"/>
        <add name="Creator"
             type="EPiServer.Security.CreatorRole, EPiServer"/>
        <add name="Tuesday" 
              type="EPiServer.Labs.Security.TuesdayVirtualRole, EPiServer.Templates.Public"/>
      </providers>
    </virtualRoles>


And then implement the class inherited from a nice baseclass

using System;
using EPiServer.Security;

namespace EPiServer.Labs.Security
{
    public class TuesdayVirtualRole : VirtualRoleProviderBase
    {

        public override bool IsInVirtualRole(System.Security.Principal.IPrincipal principal, object context)
        {
            if (DateTime.Now.DayOfWeek == DayOfWeek.Tuesday)
                return true;

            return false;
        }
    }
}
Comments