System.Security.Principal.GenericPrincipal.IsInRole C# (CSharp) Метод

IsInRole() публичный Метод

public IsInRole ( string role ) : bool
role string
Результат bool
        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);
        }
    }

Usage Example

Пример #1
0
		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");
		}
All Usage Examples Of System.Security.Principal.GenericPrincipal::IsInRole