internal GroupMembershipItem(Guid groupUId, SecurityPrincipalBase member) { GroupUId = groupUId; Member = member; MemberUId = member.UId; IsMemberUser = member is User; Validate(); }
public GroupMembershipItem(Group group, SecurityPrincipalBase member) { Group = group; GroupUId = group.UId; Member = member; MemberUId = member.UId; IsMemberUser = member is User; Validate(); }
public static MembershipList <Group> GetMemberOf(this IEnumerable <GroupMembershipItem> groupMembershipItems, SecurityPrincipalBase member, bool?includeDisabledMembership, IList <Group> groups, IList <User> users = null) { if (!includeDisabledMembership.HasValue) { includeDisabledMembership = false; } MembershipList <Group> membership = new MembershipList <Group>(); foreach (GroupMembershipItem gmi in groupMembershipItems) { if (gmi.MemberUId == member.UId) { gmi.Resolve(groups, null); if (gmi.Group.IsEnabled || includeDisabledMembership.Value) { membership.MemberList.Add(gmi.Group); } } } if (groups != null) { membership.NonMemberList = new List <Group>(); IEnumerator <Group> nonMembers = groups.Except(membership.MemberList).GetEnumerator(); while (nonMembers.MoveNext()) { if (nonMembers.Current.IsLocal && nonMembers.Current.UId != member.UId && (nonMembers.Current.IsEnabled || includeDisabledMembership.Value)) { membership.NonMemberList.Add(nonMembers.Current); } } if (member is Group group) { //Group thisGroup = membership.NonMemberList.FirstOrDefault( group => group.UId == member.UId ); //membership.NonMemberList.Remove( thisGroup ); IEnumerable <GroupMembershipItem> members = groupMembershipItems.GetByGroup(group, includeDisabledMembers: includeDisabledMembership.Value, groups: null, users: null); foreach (GroupMembershipItem gmi in members) { if (!gmi.IsMemberUser) { gmi.Resolve(groups, null); membership.NonMemberList.Remove((Group)gmi.Member); } } List <Group> nonMembs = membership.NonMemberList; List <Group> nestedMembs = membership.NestedMemberList; RecurseIneligibleNonMembers(groupMembershipItems, group, ref nonMembs, ref nestedMembs, groups, users); } } return(membership); }
public static IEnumerable <GroupMembershipItem> GetByMember(this IEnumerable <GroupMembershipItem> groupMembershipItems, SecurityPrincipalBase member, bool includeDisabledMembers, IList <Group> groups, IList <User> users, bool forceResolution = false) { return(groupMembershipItems.GetByMember(member.UId, includeDisabledMembers, groups, users, forceResolution)); }
public static IEnumerable <GroupMembershipItem> GetByGroupOrMember(this IEnumerable <GroupMembershipItem> groupMembershipItems, SecurityPrincipalBase member) { return(groupMembershipItems.Where(item => item.GroupUId == member.UId || item.MemberUId == member.UId)); }