Example #1
0
 public void AddChild(UserGroupInfo child)
 {
     lock (Children)
     {
         Children.Add(child);
     }
 }
Example #2
0
 public void RemoveChild(UserGroupInfo child)
 {
     lock (Children)
     {
         Children.Remove(child);
     }
 }
Example #3
0
 public void RemoveChild(UserGroupInfo child)
 {
     lock (Children)
     {
         Children.Remove(child);
     }
 }
Example #4
0
 public void AddChild(UserGroupInfo child)
 {
     lock (Children)
     {
         Children.Add(child);
     }
 }
Example #5
0
        /// <summary>
        /// Is the other group an ancestor of this one?
        /// </summary>
        public bool IsAncestor(UserGroupInfo other)
        {
            if ((Parent != null) &&
                 (Parent.Equals(other) || Parent.IsAncestor(other)))
                return true;

            return false;
        }
Example #6
0
        /// <summary>
        /// Is the other group an ancestor of this one?
        /// </summary>
        public bool IsAncestor(UserGroupInfo other)
        {
            if ((Parent != null) &&
                 (Parent.Equals(other) || Parent.IsAncestor(other)))
                return true;

            return false;

        }
Example #7
0
        /// <summary>
        /// Is the other group an ancestor of this one?
        /// </summary>
        public bool IsAncestor(UserGroupInfo other)
        {
            if ((Parent != null) &&
                (Parent.Equals(other) || Parent.IsAncestor(other)))
            {
                return(true);
            }

            return(false);
        }
Example #8
0
        /// <summary>
        /// Is the other group descendant of this one?
        /// </summary>
        public bool IsDescendant(UserGroupInfo other)
        {
            lock (Children)
            {
                foreach (UserGroupInfo child in Children)
                {
                    if (child.Equals(other) || child.IsDescendant(other))
                        return true;
                }
            }

            return false;
        }
Example #9
0
        /// <summary>
        /// Is the other group descendant of this one?
        /// </summary>
        public bool IsDescendant(UserGroupInfo other)
        {
            lock (Children)
            {
                foreach (UserGroupInfo child in Children)
                {
                    if (child.Equals(other) || child.IsDescendant(other))
                        return true;
                }
            }

            return false;
        }
Example #10
0
 public void SetParent(UserGroupInfo parent)
 {
     this.Parent = parent;
 }
Example #11
0
        private void ReadUserSubTree(XmlElement xmlParent, UserGroupInfo parent)
        {
            foreach (XmlElement xmlChild in xmlParent.ChildNodes)
            {

                UserGroupInfo child;

                //names are case insensitive
                string name = xmlChild.GetAttribute("Name").ToLower();

                if (allGroups.ContainsKey(name))
                    throw new Exception("duplicate usergroup name " + name);

                switch (xmlChild.Name)
                {
                    case "Group":
                        {
                            child = new UserGroupInfo(nextUserOrGroupId, name);
                        }
                        break;
                    case "User":
                        {
                            string password = xmlChild.GetAttribute("Password");
                            string liveId = xmlChild.GetAttribute("LiveId");
                            string LiveIdUniqueUserToken = xmlChild.GetAttribute("LiveIdUniqueUserToken");
                            DateTime activeFrom = DateTime.Parse(xmlChild.GetAttribute("ActiveFrom"));
                            DateTime activeUntil = DateTime.Parse(xmlChild.GetAttribute("ActiveUntil"));

                            child = new UserInfo(nextUserOrGroupId, name, password, activeFrom, activeUntil, liveId, LiveIdUniqueUserToken);

                            if (xmlChild.ChildNodes.Count != 0)
                                throw new Exception("User " + name + " has children");
                        }
                        break;
                    default:
                        throw new Exception("bad node name in users file " + xmlChild.Name);
                }

                AddUserGroup(child, parent, false);
                nextUserOrGroupId++;

                ReadUserSubTree(xmlChild, child);

            }
        }
Example #12
0
 public void SetParent(UserGroupInfo parent)
 {
     this.Parent = parent;
 }
Example #13
0
        private void WriteUserSubTree(XmlElement xmlParent, UserGroupInfo parent, XmlDocument xmlDoc)
        {
            foreach (UserGroupInfo userGroup in parent.Children)
            {
                XmlElement xmlChild;

                if (userGroup is UserInfo)
                {
                    xmlChild = xmlDoc.CreateElement("User");

                    UserInfo userInfo = (UserInfo)userGroup;
                    xmlChild.SetAttribute("Password", userInfo.Password);
                    xmlChild.SetAttribute("ActiveFrom", userInfo.ActiveFrom.ToString());
                    xmlChild.SetAttribute("ActiveUntil", userInfo.ActiveUntil.ToString());
                    xmlChild.SetAttribute("LiveId", userInfo.LiveId);
                    xmlChild.SetAttribute("LiveIdUniqueUserToken", userInfo.LiveIdUniqueUserToken);
                }
                else
                {
                    xmlChild = xmlDoc.CreateElement("Group");
                }

                xmlChild.SetAttribute("Name", userGroup.Name);

                xmlParent.AppendChild(xmlChild);

                WriteUserSubTree(xmlChild, userGroup, xmlDoc);
            }
        }
Example #14
0
        private void AddUserGroup(UserGroupInfo groupToAdd, UserGroupInfo parent, bool writeToDisk = true)
        {
            //we lock allGroups even when allUsers is being accessed
            lock (allGroups)
            {
                //add to all groups
                allGroups.Add(groupToAdd.Name, groupToAdd);

                //add to all users if this is a user
                if (groupToAdd is UserInfo)
                    allUsers.Add(groupToAdd.Name, (UserInfo)groupToAdd);

                //do the linking up and down
                groupToAdd.SetParent(parent);
                parent.AddChild(groupToAdd);

                if (writeToDisk)
                    WriteUserTree();
            }
        }
Example #15
0
 public bool Equals(UserGroupInfo other)
 {
     return this.Name.Equals(other.Name);
 }
Example #16
0
 public bool Equals(UserGroupInfo other)
 {
     return this.Name.Equals(other.Name);
 }
Example #17
0
        private void ReadUserTree()
        {
            XmlDocument xmlDoc = new XmlDocument();
            XmlReader xmlReader = XmlReader.Create(this.UsersFile, xmlReaderSettings);

            xmlDoc.Load(xmlReader);

            XmlElement rootXml = xmlDoc.FirstChild as XmlElement;

            //names are case insensitive
            string name = rootXml.GetAttribute("Name").ToLower();

            rootGroup = new UserGroupInfo(nextUserOrGroupId, name); 
            
            allGroups.Add(name, rootGroup);

            nextUserOrGroupId++;

            ReadUserSubTree(rootXml, rootGroup);

            xmlReader.Close();
        }