예제 #1
0
        public string[] GetMyRoles(string roleKey)
        {
            if (_roles[roleKey] != null)
            {
                return(_roles[roleKey].Split(';'));
            }

            _roles[roleKey] = string.Join(";", ResourceBase.GetUserRoles(User, roleKey));
            return(_roles[roleKey].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
        }
예제 #2
0
        public static bool IsUserInRole(string securityType, string roleKey, System.Web.HttpContextBase context)
        {
            // anonymous user
            if (context.User == null)
            {
                return(false);
            }

            switch (securityType)
            {
            case "role":
                return(ResourceBase.IsUserInRole(context.User, roleKey) || context.User.IsInRole(roleKey));

            case "group":
                RestNetUser rUser = (RestNetUser)context.User.Identity;
                return(rUser.isInRole(roleKey));

            case "none":
                return(true);

            default:
                throw ErrorHandler.HttpConfigurationError("The RestNetSecurityType setting in web.config contains an unknown value. Valid values are 'role', 'group', or 'none'");
            }
        }