/// <summary>
        /// Checks the target group list to see if a group exists
        /// </summary>
        /// <param name="target">The target to check</param>
        /// <param name="groupName">The group name to check for</param>
        /// <returns>If the target has the group in its group list</returns>
        public static bool HasGroup(this IHasGroups target, string groupName)
        {
            if (target is null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            return(target.Groups.Any(g => string.Equals(groupName, g.ExternalId, StringComparison.InvariantCultureIgnoreCase)));
        }
        /// <summary>
        /// Checks the target group list to see if a group exists
        /// </summary>
        /// <param name="target">The target to check</param>
        /// <param name="thisGroup">The group to check for</param>
        /// <returns>If the target has the group in its group list</returns>
        public static bool HasGroup(this IHasGroups target, IGroup thisGroup)
        {
            if (thisGroup is null)
            {
                throw new ArgumentNullException(nameof(thisGroup));
            }

            return(target.HasGroup(thisGroup.ExternalId));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns a list of security groups including groups AND roles that an object belongs to
        /// </summary>
        /// <param name="target">The target to check</param>
        /// <returns>A list of Guids representing groups AND roles that an object belongs to</returns>
        private static IEnumerable <ISecurityGroup> GetGroups(IHasGroups target)
        {
            foreach (IGroup thisGroup in target.Groups)
            {
                yield return(thisGroup);

                foreach (ISecurityGroup r in GetRoles(thisGroup))
                {
                    yield return(r);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns a list of Guids representing groups AND roles that an object belongs to
        /// </summary>
        /// <param name="target">The target to check</param>
        /// <returns>A list of Guids representing groups AND roles that an object belongs to</returns>
        private static IEnumerable <Guid> GetGroupGuids(IHasGroups target)
        {
            foreach (IGroup thisGroup in target.Groups)
            {
                yield return(thisGroup.Guid);

                foreach (Guid g in GetRoleGuids(thisGroup))
                {
                    yield return(g);
                }
            }
        }
        private void RefreshGroups(IHasGroups target)
        {
            foreach (Group g in target.Groups.ToList())
            {
                if (this.GroupRepository.Find(g) is Group ng)
                {
                    (target.Groups as IList <Group>)?.Remove(g);

                    (target.Groups as IList <Group>)?.Add(ng);
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Returns a list of Guids representing ONLY the groups (not roles) that an object belongs to
        /// </summary>
        /// <param name="target">The target to check</param>
        /// <returns>A list of Guids representing ONLY the groups (not roles) that an object belongs to</returns>
        public static IEnumerable <Guid> SecurityGroups(this IHasGroups target)
        {
            if (target is null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            if (target is ISecurityGroup te)
            {
                yield return(te.Guid);
            }

            foreach (Guid g in GetGroupGuids(target))
            {
                yield return(g);
            }
        }