public override bool IsInRole(string role)
{
if (role == null || m_roles == null)
return false;
for (int i = 0; i < m_roles.Length; ++i)
{
if (m_roles[i] != null && String.Compare(m_roles[i], role, StringComparison.OrdinalIgnoreCase) == 0)
return true;
}
// it may be the case a ClaimsIdentity was passed in as the IIdentity which may have contained claims, they need to be checked.
return base.IsInRole(role);
}
}
public void IsInRole_CaseInsensitive () { GenericIdentity gi = new GenericIdentity ("user"); GenericPrincipal gp = new GenericPrincipal (gi, new string[2] { "mono", "hackers" }); Assert.IsTrue (gp.IsInRole ("MoNo"), "MoNo"); Assert.IsTrue (gp.IsInRole ("hAcKeRs"), "hAcKeRs"); }