Exemple #1
0
 public bool HasLocalRoleAtOrganizationGeography (Organization organization, Geography geography, Authorization.Flag flags)
 {
     return HasLocalRoleAtOrganizationGeography(organization, geography, RoleTypes.AllLocalRoleTypes, flags);
 }
Exemple #2
0
 public bool HasLocalRoleAtOrganizationGeography (Organization organization, Geography geography,
                                                  RoleType roleType, Authorization.Flag flags)
 {
     return HasLocalRoleAtOrganizationGeography(organization, geography,
                                                  new RoleType[] { roleType }, flags);
 }
Exemple #3
0
 public bool HasPermission (PermissionSet perm, Authorization.Flag flags)
 {
     return Authorization.CheckAuthorization(perm, -1, -1, this, flags);
 }
Exemple #4
0
 public bool HasPermission (PermissionSet perm, int organizationId, int geographyId, Authorization.Flag flags)
 {
     return Authorization.CheckAuthorization(perm, organizationId, geographyId, this, flags);
 }
Exemple #5
0
 private bool HasPermission (Permission perm, int organizationId, Authorization.Flag flags)
 {
     return Authorization.CheckAuthorization(new PermissionSet(perm), organizationId, Organization.RootIdentity, this, flags);
 }
Exemple #6
0
        public bool HasRoleAtOrganization (Organization organization, RoleType[] roleTypes, Authorization.Flag flags)
        {
            if (organization == null)
            {
                if ((flags & Authorization.Flag.AnyOrganization) != 0)
                    return true;
                else
                    return false;
            }

            if (organization != null && organization.Identity == Organization.SandboxIdentity)
            {
                return true; // UGLY UGLY HACK
            }

            foreach (BasicPersonRole role in OrganizationPersonRoles)
            {
                foreach (RoleType type in roleTypes)
                {
                    if (type == role.Type)
                    {
                        if ((flags & Authorization.Flag.AnyOrganization) != 0)
                            return true;

                        if (organization.Identity == role.OrganizationId)
                        {
                            return true;
                        }

                        if ((flags & Authorization.Flag.ExactOrganization) == 0)
                        {
                            if (organization.Inherits(role.OrganizationId))
                            {
                                return true;
                            }
                        }
                    }
                }
            }

            return false;
        }
Exemple #7
0
 public bool HasRoleAtOrganization (Organization organization, RoleType roleType, Authorization.Flag flags)
 {
     return HasRoleAtOrganization(organization, new RoleType[] { roleType }, flags);
 }
Exemple #8
0
 public bool HasRoleAtOrganization (Organization organization, Authorization.Flag flags)
 {
     return HasRoleAtOrganization(organization, RoleTypes.AllOrganizationalRoleTypes, flags);
 }
Exemple #9
0
        public bool HasLocalRoleAtOrganizationGeography (Organization organization, Geography geography,
                                                         RoleType[] roleTypes, Authorization.Flag flags)
        {

            if (organization != null && organization.Identity == Organization.SandboxIdentity)
            {
                return true; // UGLY UGLY HACK
            }

            if (organization == null && (flags & Authorization.Flag.AnyOrganization) == 0)
                return false;

            if (geography == null && (flags & Authorization.Flag.AnyGeography) == 0)
                return false;


            foreach (BasicPersonRole role in LocalPersonRoles)
            {
                foreach (RoleType type in roleTypes)
                {
                    if (type == role.Type)
                    {
                        // Expensive op. The org/geo lookups need a cache at the logic layer.

                        bool organizationClear = false;
                        bool geographyClear = false;

                        // First, check if the organization and geography match identically.

                        if ((flags & Authorization.Flag.AnyOrganization) != 0)
                        {
                            // then it is used to check if they have a local role for any org
                            organizationClear = true;
                        }
                        else if (organization != null && organization.Identity == role.OrganizationId)
                        {
                            organizationClear = true;
                        }

                        if ((flags & Authorization.Flag.AnyGeography) != 0)
                        {
                            // then it is used to check if they have a local role anywhere
                            geographyClear = true;
                        }
                        else if (geography != null && geography.Identity == role.GeographyId)
                        {
                            geographyClear = true;
                        }


                        // If not clear, then check if there is inherited authority.

                        if (!organizationClear
                            && (flags & Authorization.Flag.ExactOrganization) == 0)
                        {
                            if (organization != null && organization.Inherits(role.OrganizationId))
                            {
                                organizationClear = true;
                            }
                        }

                        if (!geographyClear && (flags & Authorization.Flag.ExactGeography) == 0)
                        {
                            if (geography != null && geography.Inherits(role.GeographyId))
                            {
                                geographyClear = true;
                            }
                        }

                        // If both are ok, return that there is authority at this org & geo.

                        if (organizationClear && geographyClear)
                        {
                            return true;
                        }
                    }
                }
            }

            return false;
        }