Example #1
0
 public static void Link(Organization from, Organization to, OrgLinkType linkType)
 {
     OrganizationLink link = new OrganizationLink { FromOrganization = from, ToOrganization = to, LinkType = linkType };
     from.LinksToOrgs.Add(link);
     to.LinksFromOrgs.Add(link);
 }
Example #2
0
        public static void InitializeOrganizationSecurity(this IDataStoreService ctx, Organization org, User admin)
        {
            org.AdminAccount = (admin == null) ? "setup" : admin.Username;

            var usersRole = new Role { Name = "Members", OrganizationId = org.Id, SystemRole = true };
            var adminRole = new Role { Name = "Administrators", OrganizationId = org.Id, SystemRole = true };
            adminRole.MemberOfRoles.Add(new RoleRoleMembership { Parent = usersRole, Child = adminRole, IsSystem = true });

            var siteAdmin = ctx.Roles.Single(f => f.Name == AuthIdentityService.ADMIN_ROLE && f.OrganizationId == null);
            siteAdmin.MemberOfRoles.Add(new RoleRoleMembership { Parent = adminRole, Child = siteAdmin, IsSystem = true });

            if (admin != null)
            {
                adminRole.Users.Add(new RoleUserMembership { Role = adminRole, User = admin });
            }

            ctx.Roles.Add(adminRole);
            ctx.Roles.Add(usersRole);

            ctx.Authorization.Add(new Authorization { Role = adminRole, Scope = org.Id, Permission = PermissionType.AdminOrganization, IsSystem = true });
            ctx.Authorization.Add(new Authorization { Role = adminRole, Scope = org.Id, Permission = PermissionType.AddOrganizationMembers, IsSystem = true });
            ctx.Authorization.Add(new Authorization { Role = adminRole, Scope = org.Id, Permission = PermissionType.EditMember, IsSystem = true });
            ctx.Authorization.Add(new Authorization { Role = adminRole, Scope = org.Id, Permission = PermissionType.EditMemberContacts, IsSystem = true });
            ctx.Authorization.Add(new Authorization { Role = adminRole, Scope = org.Id, Permission = PermissionType.ViewMemberDetail, IsSystem = true });
            ctx.Authorization.Add(new Authorization { Role = adminRole, Scope = org.Id, Permission = PermissionType.ViewMemberStandard, IsSystem = true });

            ctx.Authorization.Add(new Authorization { Role = usersRole, Scope = org.Id, Permission = PermissionType.ViewOrganizationBasic, IsSystem = true });
            ctx.Authorization.Add(new Authorization { Role = usersRole, Scope = org.Id, Permission = PermissionType.ViewOrganizationDetail, IsSystem = true });
            ctx.Authorization.Add(new Authorization { Role = usersRole, Scope = org.Id, Permission = PermissionType.ListOrganization, IsSystem = true });
            ctx.Authorization.Add(new Authorization { Role = usersRole, Scope = org.Id, Permission = PermissionType.ViewMemberStandard, IsSystem = false });
            ctx.Authorization.Add(new Authorization { Role = usersRole, Scope = org.Id, Permission = PermissionType.ViewMemberBasic, IsSystem = false });
        }