public bool IsInRole(string role)
        {
            List <string> roleList = role.Split(',').ToList();

            foreach (var item in roleList)
            {
                if (item == RoleID.ToString())
                {
                    return(true);
                }
            }
            return(false);
        }
Example #2
0
        public string GetProperty(string propertyName, string format, CultureInfo formatProvider, UserInfo accessingUser,
                                  Scope accessLevel, ref bool propertyNotFound)
        {
            string OutputFormat = string.Empty;

            if (format == string.Empty)
            {
                OutputFormat = "g";
            }
            else
            {
                OutputFormat = format;
            }
            string propName = propertyName.ToLowerInvariant();

            switch (propName)
            {
            case "roleid":
                return(PropertyAccess.FormatString(RoleID.ToString(), format));

            case "groupid":
                return(PropertyAccess.FormatString(RoleID.ToString(), format));

            case "status":
                return(PropertyAccess.FormatString(Status.ToString(), format));

            case "groupname":
                return(PropertyAccess.FormatString(RoleName, format));

            case "rolename":
                return(PropertyAccess.FormatString(RoleName, format));

            case "groupdescription":
                return(PropertyAccess.FormatString(Description, format));

            case "description":
                return(PropertyAccess.FormatString(Description, format));

            case "usercount":
                return(PropertyAccess.FormatString(UserCount.ToString(), format));

            case "street":
                return(PropertyAccess.FormatString(GetString("Street", string.Empty), format));

            case "city":
                return(PropertyAccess.FormatString(GetString("City", string.Empty), format));

            case "region":
                return(PropertyAccess.FormatString(GetString("Region", string.Empty), format));

            case "country":
                return(PropertyAccess.FormatString(GetString("Country", string.Empty), format));

            case "postalcode":
                return(PropertyAccess.FormatString(GetString("PostalCode", string.Empty), format));

            case "website":
                return(PropertyAccess.FormatString(GetString("Website", string.Empty), format));

            case "datecreated":
                return(PropertyAccess.FormatString(CreatedOnDate.ToString(), format));

            case "photourl":
                return(PropertyAccess.FormatString(FormatUrl(PhotoURL), format));

            case "stat_status":
                return(PropertyAccess.FormatString(GetString("stat_status", string.Empty), format));

            case "stat_photo":
                return(PropertyAccess.FormatString(GetString("stat_photo", string.Empty), format));

            case "stat_file":
                return(PropertyAccess.FormatString(GetString("stat_file", string.Empty), format));

            case "url":
                return(PropertyAccess.FormatString(FormatUrl(GetString("URL", string.Empty)), format));

            case "issystemrole":
                return(PropertyAccess.Boolean2LocalizedYesNo(IsSystemRole, formatProvider));

            case "grouptype":
                return(IsPublic ? "Public.Text" : "Private.Text");

            case "groupcreatorname":
                return(PropertyAccess.FormatString(GetString("GroupCreatorName", string.Empty), format));

            default:
                if (Settings.ContainsKey(propertyName))
                {
                    return(PropertyAccess.FormatString(GetString(propertyName, string.Empty), format));
                }

                propertyNotFound = true;
                return(string.Empty);
            }
        }
Example #3
0
 public override string ToString()
 {
     return(RoleID.ToString());
 }
Example #4
0
 public static RoleBase Create(RoleID roleID)
 {
     return(Create(roleID.ToString()));
 }
Example #5
0
        //当使用Authorize特性时,会调用该方法验证角色
        public bool IsInRole(string Roles)
        {
            var RolesArray = Roles.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            return(RolesArray.Contains(RoleID.ToString()));
        }
        public List <Claim> GetClaims(ClaimsPrincipal principal)
        {
            //getting the claims for the token created by the sts
            List <Claim> claims = new List <Claim>()
            {
                new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier", Email),
                new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", Email),
                new Claim("'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress", Email),
                new Claim(System.IdentityModel.Claims.ClaimTypes.Name, Email),
                //new Claim(System.IdentityModel.Claims.ClaimTypes.NameIdentifier, Email),
                new Claim(Const.CLAIM.CLAIM_NAMESPACE + "/" + "Email", Email),
                new Claim(Const.CLAIM.CLAIM_NAMESPACE + "/" + "PhoneNumber", PhoneNumber),
                new Claim(Const.CLAIM.CLAIM_NAMESPACE + "/" + Const.Fields.EMPLOYEE_ROLE_ID, ManagerID.ToString()),
                new Claim(Const.CLAIM.CLAIM_NAMESPACE + "/" + Const.Fields.EMPLOYEE_FIRST_NAME, FirstName),
                new Claim(Const.CLAIM.CLAIM_NAMESPACE + "/" + Const.Fields.EMPLOYEE_LAST_NAME, LastName),
                new Claim(Const.CLAIM.CLAIM_NAMESPACE + "/" + Const.Fields.EMPLOYEE_ACCESS, Administrator),
                new Claim(Const.CLAIM.CLAIM_NAMESPACE + "/" + Const.Fields.EMPLOYEE_FIRST_NAME, FirstName),
                new Claim(Const.CLAIM.CLAIM_NAMESPACE + "/" + Const.Fields.EMPLOYEE_LAST_NAME, LastName),
                new Claim(Const.CLAIM.CLAIM_NAMESPACE + "/" + Const.Fields.EMPLOYEE_ACCOUNT, Account),
                new Claim(Const.CLAIM.CLAIM_NAMESPACE + "/" + Const.Fields.EMPLOYEE_DEPARTMENT_ID, DepartmentID.ToString()),
                new Claim(Const.CLAIM.CLAIM_NAMESPACE + "/" + Const.Fields.EMPLOYEE_ROLE_ID, RoleID.ToString()),
                new Claim(Const.CLAIM.CLAIM_NAMESPACE + "/" + Const.Fields.EMPLOYEE_ID, EmployeeID.ToString()),
                new Claim(Const.CLAIM.CLAIM_NAMESPACE + "/" + Const.Fields.EMPLOYEE_HIRE_DATE, HireDate.ToString())
            };

            return(claims);
        }