/// <summary>Gets unix groups and netgroups for the user.</summary>
        /// <remarks>
        /// Gets unix groups and netgroups for the user.
        /// It gets all unix groups as returned by id -Gn but it
        /// only returns netgroups that are used in ACLs (there is
        /// no way to get all netgroups for a given user, see
        /// documentation for getent netgroup)
        /// </remarks>
        /// <exception cref="System.IO.IOException"/>
        public override IList <string> GetGroups(string user)
        {
            // parent gets unix groups
            IList <string> groups = new List <string>(base.GetGroups(user));

            NetgroupCache.GetNetgroups(user, groups);
            return(groups);
        }
Ejemplo n.º 2
0
        private void VerifyGroupMembership(string user, int size, string group)
        {
            IList <string> groups = new AList <string>();

            NetgroupCache.GetNetgroups(user, groups);
            Assert.Equal(size, groups.Count);
            if (size > 0)
            {
                bool present = false;
                foreach (string groupEntry in groups)
                {
                    if (groupEntry.Equals(group))
                    {
                        present = true;
                        break;
                    }
                }
                Assert.True(present);
            }
        }