Esempio n. 1
0
        public void internal_Is_Admin_Admin()
        {
            var u = users.GetUser(ROLE_ADMIN);

            Assert.True(roles.IsInRole(new Identity(u), ROLE_ADMIN));
            u = users.GetUser(ROLE_SECURITY_ADMIN);
            Assert.True(roles.IsInRole(new Identity(u), ROLE_SECURITY_ADMIN));
        }
        public static bool IsInRole(this IRoleResolverService service, string login, string role,
                                    bool exact = false)
        {
            var srv = service as RoleResolverService;
            var us  = srv.Users.GetUser(login);

            if (null == us)
            {
                return(false);
            }
            var id = new Identity {
                Name            = us.Name,
                IsAuthenticated = true,
                IsAdmin         = us.IsAdmin,
                User            = us
            };

            return(service.IsInRole(id, role, exact));
        }
 public static bool IsInRole(this IRoleResolverService service, IPrincipal principal, string role,
                             bool exact = false)
 {
     return(service.IsInRole(principal.Identity, role, exact));
 }
Esempio n. 4
0
 /// <summary>
 /// Оболочка проверки роли текущего пользователя
 /// </summary>
 /// <param name="resolver"></param>
 /// <param name="role"></param>
 /// <param name="adminanyrole"></param>
 /// <returns></returns>
 public static bool IsInRole(this IRoleResolverService resolver, string role, bool adminanyrole = true)
 {
     return(resolver.IsInRole(getCurrent().Identity, role, adminanyrole));
 }
Esempio n. 5
0
 /// <summary>
 /// Признак административной учетной записи
 /// </summary>
 /// <param name="resolver"></param>
 /// <param name="user"> </param>
 /// <returns></returns>
 public static bool IsAdmin(this IRoleResolverService resolver, IPrincipal user)
 {
     return(resolver.IsInRole(user.Identity, SecurityConst.ROLE_ADMIN));
 }