'Roles Criterion' does not implement inherited abstract member 'Criterion Base<Role Model>.IsMatch(IPrincipal, HttpContextBase)' Error

Vote:
 

'Roles Criterion' does not implement inherited abstract member 'Criterion Base.IsMatch(IPrincipal, HttpContextBase)' Error in creating custom Add ons, and 'RoleCriterion.IsMatch(IPrincipal, HttpContextBase)': no suitable method found to overrideRoleCriterion, any idea why these errors?

#148424
May 12, 2016 16:02
Vote:
 

Are you using owin? any addons?

Sounds like you have a custom visitor group for roles running in your solution? Probably this implementation. 

http://world.episerver.com/blogs/Magnus-Rahl/Dates/2011/1/More-custom-Visitor-Group-criteria-Role/

Might want to remove that one or bug fix it...

#148431
Edited, May 12, 2016 17:13
Vote:
 
<p>Yes, I am implementing custom visitor group criteria role for azure active directory. why this error, even though defination of method is exactly matching? or is there any add ons for azure active directory role?</p>
#148447
May 13, 2016 8:06
Vote:
 

Can you copy paste the relevant code for that class?

#148452
May 13, 2016 9:18
Vote:
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using EPiServer.Personalization.VisitorGroups;

namespace CriteriaPack.RoleCriterion
{
    /// <summary>
    /// Implementation of a EPiServer.Personalization.VisitorGroups.CriterionBase
    /// which checks if a user is in a named role.
    /// </summary>
    [VisitorGroupCriterion(
        Category = "Technical Criteria",
        DisplayName = "Role",
        Description = "Criterion that matches the user's roles",
        LanguagePath = "Install/lang/RoleCriterion")]
    public class RoleCriterion : CriterionBase<RoleModel>
    {
        public override bool IsMatch(System.Security.Principal.IPrincipal principal,
                                     HttpContextBase httpContext)
        {
            bool isInRole = principal.IsInRole(Model.RoleName);
            bool shouldBeInRole = Model.Condition == RoleCompareCondition.Equal;
            return isInRole == shouldBeInRole;
        }

    }
}

This is the code.

#148453
Edited, May 13, 2016 9:23
Vote:
 
<p>Do you get a compile time error or runtime?</p>
#148462
May 13, 2016 11:07
Vote:
 

compile time error..

#148464
May 13, 2016 11:20
Vote:
 
 [VisitorGroupCriterion(
        Category = "Technical Criteria",
        DisplayName = "Role",
        Description = "Criterion that matches the user's roles",
        LanguagePath = "Install/lang/RoleCriterion")]
    public class RoleCriterion : CriterionBase<RoleModel>
    {
        public override bool IsMatch(System.Security.Principal.IPrincipal principal,
                                     HttpContextBase httpContext)
        {
            bool isInRole = principal.IsInRole(Model.RoleName);
            bool shouldBeInRole = Model.Condition == RoleCompareCondition.Equal;
            return isInRole == shouldBeInRole;
        }

    }
    public class RoleModel : ICriterionModel
    {
        public EPiServer.Data.Identity Id { get; set; }
        public ICriterionModel Copy()
        {
            var model = (RoleModel)base.MemberwiseClone();
            model.Id = Identity.NewIdentity();
            return model;
        }
        
        [DojoWidget(
            SelectionFactoryType = typeof(EnumSelectionFactory),
            LabelTranslationKey = "/shell/cms/visitorgroups/criteria/role/comparecondition",
            AdditionalOptions = "{ selectOnClick: true }"),
            Required]
        public RoleCompareCondition Condition { get; set; }
        [DojoWidget(
            LabelTranslationKey = "/shell/cms/visitorgroups/criteria/role/rolename",
            AdditionalOptions = "{ selectOnClick: true }"),
            Required]
        public string RoleName { get; set; }
    }
    /// <summary>
    /// Enum representing compare conditions for booleans
    /// </summary>
    public enum RoleCompareCondition
    {
        Equal,
        NotEqual
    }

I tried the following code which compiles fine...also took a look at the Criteriapack which looks similar and compiles fine. Try the same on a fresh alloy site...? 

#148468
May 13, 2016 13:05
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.