public override MembershipUser GetUser(string username, bool userIsOnline)
        {
            if (!_users.ContainsKey(username))
            {
                throw new SecurityException("Invalid username");
            }

            XmlMembershipUser user = _users[username];

            return(user);
        }
        public override string GetPassword(string username, string answer)
        {
            if (!_users.ContainsKey(username))
            {
                throw new SecurityException("Invalid username");
            }

            XmlMembershipUser user = _users[username];

            return(user.Password);
        }
        public override void UpdateUser(MembershipUser user)
        {
            XmlMembershipUser theUser = user as XmlMembershipUser;
            XmlDocument       doc     = new XmlDocument();

            doc.Load(_path);
            XmlNode node = doc.SelectSingleNode(String.Format("//Users/User[@UserName='******']", theUser.UserName));

            if (node == null)
            {
                throw new SecurityException("No such user");
            }

            XmlNode parent = node.ParentNode;

            parent.RemoveChild(node);
            parent.AppendChild(doc.ImportNode(XmlUtils.Serialize(theUser), true));
            doc.Save(_path);
        }
        private void ReadData()
        {
            if (_users == null)
            {
                lock (_syncRoot)
                {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(_path);

                    _users = new Dictionary <string, XmlMembershipUser>();
                    foreach (XmlNode node in doc.SelectNodes("//Users/User"))
                    {
                        XmlMembershipUser user = XmlUtils.Deserialize <XmlMembershipUser>(node);
                        if (user.IsApproved)
                        {
                            _users.Add(user.UserName, user);
                        }
                    }
                }
            }
        }
        public override bool ValidateUser(string username, string password)
        {
            ReadData();

            if (!_users.ContainsKey(username))
            {
                return(false);
            }

            XmlMembershipUser user = _users[username];

            if (user.PasswordExpired)
            {
                throw new PasswordExpiredException();
            }

            if (!user.Password.Equals(password))
            {
                return(false);
            }

            return(true);
        }