Example #1
0
        private void OnUserOverviewRequest(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus").Debug("User overview request from " + ServerUser.AccountName + ".");

            PacketGenericMessage msg = r as PacketGenericMessage;
            int pageNum  = msg.Parms.GetIntProperty(2).GetValueOrDefault(0);
            int pageSize = msg.Parms.GetIntProperty(3).GetValueOrDefault(50);

            if (!ServerUser.Profile.IsUserInRole("ActiveCustomerService"))
            {
                Log1.Logger("Server.Commands").Warn("[" + ServerUser.AccountName + "] has insufficient permissions to request user info.");
                r.ReplyPacket = CreateStandardReply(r, ReplyType.Failure, "Insufficient permissions. Only Administrators can request Zeus users.");
                return;
            }

            WispUsersInfo users = new WispUsersInfo();

            users.AllowRemoteConnections = ZeusServer.AllowRemote;

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.Parms.SetProperty(1, MyServer.ServerUserID);
            r.ReplyPacket.Parms.SetProperty(2, users);
            users.TotalUserCount = -1;

            if (MyServer.RequireAuthentication)
            {
                int totalUsers = 0;
                Membership.GetAllUsers(0, 1, out totalUsers);
                users.TotalUserCount = totalUsers;
                users.UserDataStore  = "Database";
            }
        }
Example #2
0
        private void GetAllDBUsers(WispUsersInfo users, int page, int numPerPage)
        {
            SqlMembershipProvider prov = Membership.Provider as SqlMembershipProvider;

            users.UserDataStore = "Database";
            int totalRecords = 0;
            MembershipUserCollection allUsers = null;

            if (numPerPage == -1 && page == -1)
            {
                allUsers             = Membership.GetAllUsers();
                users.TotalUserCount = allUsers.Count;
            }
            else
            {
                allUsers             = Membership.GetAllUsers(page, numPerPage, out totalRecords);
                users.TotalUserCount = totalRecords;
            }

            foreach (MembershipUser u in allUsers)
            {
                //string[] roles = Roles.GetRolesForUser(u.UserName);
                users.Users.Add(new WispUsersInfo.User(u.UserName, new string[0], u.IsLockedOut, (Guid)u.ProviderUserKey, u.Email, u.LastLoginDate));
            }
        }
Example #3
0
        private void OnUserSearch(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus").Debug("User search request from " + ServerUser.AccountName + ".");

            PacketGenericMessage msg = r as PacketGenericMessage;

            string name     = msg.Parms.GetStringProperty(2).Trim();
            string email    = msg.Parms.GetStringProperty(3).Trim();
            Guid   guid     = msg.Parms.GetGuidProperty(4);
            int    page     = msg.Parms.GetIntProperty(5).GetValueOrDefault(0);
            int    pageSize = msg.Parms.GetIntProperty(6).GetValueOrDefault(0);
            string ip       = msg.Parms.GetStringProperty(7).Trim();

            WispUsersInfo users = new WispUsersInfo();

            users.AllowRemoteConnections = ZeusServer.AllowRemote;

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.Parms.SetProperty(1, MyServer.ServerUserID);
            r.ReplyPacket.Parms.SetProperty(2, users);
            r.ReplyPacket.Parms.SetProperty(3, name);
            r.ReplyPacket.Parms.SetProperty(4, email);
            r.ReplyPacket.Parms.SetProperty(5, guid);
            r.ReplyPacket.Parms.SetProperty(6, page);
            r.ReplyPacket.Parms.SetProperty(7, pageSize);
            r.ReplyPacket.Parms.SetProperty(8, ip);
            users.TotalUserCount = -1;
            if (MyServer.RequireAuthentication)
            {
                r.ReplyPacket.Parms.SetProperty(2, SearchDBUsers(name, email, guid, ip, page, pageSize));
            }
        }
Example #4
0
        private WispUsersInfo SearchDBUsers(string name, string email, Guid id, string ip, int page, int numPerPage)
        {
            int total = 0;

            WispUsersInfo wu   = new WispUsersInfo();
            WispUsersInfo rslt = new WispUsersInfo();

            try
            {
                MembershipUserCollection users = null;
                if (name.Length > 0)
                {
                    if (!name.EndsWith("%"))
                    {
                        name += "%";
                    }
                    if (!name.StartsWith("%"))
                    {
                        name = "%" + name;
                    }
                    users = Membership.FindUsersByName(name);
                    foreach (MembershipUser u in users)
                    {
                        string[] roles = new string[0];// Roles.GetRolesForUser(u.UserName);
                        wu.Users.Add(new WispUsersInfo.User(u.UserName, roles, u.IsLockedOut, (Guid)u.ProviderUserKey, u.Email, u.LastLoginDate.ToUniversalTime()));
                    }
                }

                if (email.Length > 0)
                {
                    if (!email.EndsWith("%"))
                    {
                        email += "%";
                    }
                    if (!email.StartsWith("%"))
                    {
                        email = "%" + email;
                    }
                    users = Membership.FindUsersByEmail(email);
                    foreach (MembershipUser u in users)
                    {
                        string[] roles = new string[0];// Roles.GetRolesForUser(u.UserName);
                        wu.Users.Add(new WispUsersInfo.User(u.UserName, roles, u.IsLockedOut, (Guid)u.ProviderUserKey, u.Email, u.LastLoginDate));
                    }
                }

                if (id != Guid.Empty)
                {
                    MembershipUser usr = Membership.GetUser(id, false);
                    if (usr != null)
                    {
                        string[] roles = new string[0];// Roles.GetRolesForUser(u.UserName);
                        wu.Users.Add(new WispUsersInfo.User(usr.UserName, roles, usr.IsLockedOut, (Guid)usr.ProviderUserKey, usr.Email, usr.LastLoginDate));
                    }
                }

                if (ip.Length > 0)
                {
                    if (!ip.EndsWith("%"))
                    {
                        ip += "%";
                    }
                    if (!ip.StartsWith("%"))
                    {
                        ip = "%" + ip;
                    }

                    List <WispUsersInfo.User> ipusers = new List <WispUsersInfo.User>();
                    DB.Instance.User_SearchByIP(ip, ipusers);
                    wu.Users.AddRange(ipusers);
                }

                rslt.TotalUserCount = wu.Users.Count;

                // Partition
                IEnumerable <IEnumerable <WispUsersInfo.User> > usrs = wu.Users.Partition(numPerPage);

                // Move to selected page
                IEnumerator <IEnumerable <WispUsersInfo.User> > enu = usrs.GetEnumerator();
                int cur = 0;
                while (enu.MoveNext())
                {
                    if (cur == page)
                    {
                        foreach (WispUsersInfo.User ai in enu.Current)
                        {
                            rslt.Users.Add(ai);
                        }
                    }

                    cur++;
                }
            }
            catch { }


            return(rslt);
        }
        private WispUsersInfo SearchDBUsers(string name, string email, Guid id, string ip, int page, int numPerPage)
        {
            int total = 0;

            WispUsersInfo wu = new WispUsersInfo();
            WispUsersInfo rslt = new WispUsersInfo();
            try
            {
                MembershipUserCollection users = null;
                if (name.Length > 0)
                {
                    if (!name.EndsWith("%"))
                    {
                        name += "%";
                    }
                    if (!name.StartsWith("%"))
                    {
                        name = "%" + name;
                    }
                    users = Membership.FindUsersByName(name);
                    foreach (MembershipUser u in users)
                    {
                        string[] roles = new string[0];// Roles.GetRolesForUser(u.UserName);
                        wu.Users.Add(new WispUsersInfo.User(u.UserName, roles, u.IsLockedOut, (Guid)u.ProviderUserKey, u.Email, u.LastLoginDate.ToUniversalTime()));
                    }
                }

                if (email.Length > 0)
                {
                    if (!email.EndsWith("%"))
                    {
                        email += "%";
                    }
                    if (!email.StartsWith("%"))
                    {
                        email = "%" + email;
                    }
                    users = Membership.FindUsersByEmail(email);
                    foreach (MembershipUser u in users)
                    {
                        string[] roles = new string[0];// Roles.GetRolesForUser(u.UserName);
                        wu.Users.Add(new WispUsersInfo.User(u.UserName, roles, u.IsLockedOut, (Guid)u.ProviderUserKey, u.Email, u.LastLoginDate));
                    }
                }

                if (id != Guid.Empty)
                {
                    MembershipUser usr = Membership.GetUser(id, false);
                    if (usr != null)
                    {
                        string[] roles = new string[0];// Roles.GetRolesForUser(u.UserName);
                        wu.Users.Add(new WispUsersInfo.User(usr.UserName, roles, usr.IsLockedOut, (Guid)usr.ProviderUserKey, usr.Email, usr.LastLoginDate));
                    }
                }

                if (ip.Length > 0)
                {
                    if (!ip.EndsWith("%"))
                    {
                        ip += "%";
                    }
                    if (!ip.StartsWith("%"))
                    {
                        ip = "%" + ip;
                    }

                    List<WispUsersInfo.User> ipusers = new List<WispUsersInfo.User>();
                    DB.Instance.User_SearchByIP(ip, ipusers);
                    wu.Users.AddRange(ipusers);
                }

                rslt.TotalUserCount = wu.Users.Count;

                // Partition
                IEnumerable<IEnumerable<WispUsersInfo.User>> usrs = wu.Users.Partition(numPerPage);

                // Move to selected page
                IEnumerator<IEnumerable<WispUsersInfo.User>> enu = usrs.GetEnumerator();
                int cur = 0;
                while (enu.MoveNext())
                {
                    if (cur == page)
                    {
                        foreach (WispUsersInfo.User ai in enu.Current)
                        {
                            rslt.Users.Add(ai);
                        }
                    }

                    cur++;
                }
            }
            catch { }

            return rslt;
        }
        private void OnUserSearch(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus").Debug("User search request from " + ServerUser.AccountName + ".");

            PacketGenericMessage msg = r as PacketGenericMessage;

            string name = msg.Parms.GetStringProperty(2).Trim();
            string email = msg.Parms.GetStringProperty(3).Trim();
            Guid guid = msg.Parms.GetGuidProperty(4);
            int page = msg.Parms.GetIntProperty(5).GetValueOrDefault(0);
            int pageSize = msg.Parms.GetIntProperty(6).GetValueOrDefault(0);
            string ip = msg.Parms.GetStringProperty(7).Trim();

            WispUsersInfo users = new WispUsersInfo();
            users.AllowRemoteConnections = ZeusServer.AllowRemote;

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.Parms.SetProperty(1, MyServer.ServerUserID);
            r.ReplyPacket.Parms.SetProperty(2, users);
            r.ReplyPacket.Parms.SetProperty(3, name);
            r.ReplyPacket.Parms.SetProperty(4, email);
            r.ReplyPacket.Parms.SetProperty(5, guid);
            r.ReplyPacket.Parms.SetProperty(6, page);
            r.ReplyPacket.Parms.SetProperty(7, pageSize);
            r.ReplyPacket.Parms.SetProperty(8, ip);
            users.TotalUserCount = -1;
            if (MyServer.RequireAuthentication)
            {
                r.ReplyPacket.Parms.SetProperty(2, SearchDBUsers(name, email, guid, ip, page, pageSize));
            }
        }
        private void OnUserOverviewRequest(INetworkConnection con, Packet r)
        {
            Log1.Logger("Zeus").Debug("User overview request from " + ServerUser.AccountName + ".");

            PacketGenericMessage msg = r as PacketGenericMessage;
            int pageNum = msg.Parms.GetIntProperty(2).GetValueOrDefault(0);
            int pageSize = msg.Parms.GetIntProperty(3).GetValueOrDefault(50);

            if (!ServerUser.Profile.IsUserInRole("ActiveCustomerService"))
            {
                Log1.Logger("Server.Commands").Warn("[" + ServerUser.AccountName + "] has insufficient permissions to request user info.");
                r.ReplyPacket = CreateStandardReply(r, ReplyType.Failure, "Insufficient permissions. Only Administrators can request Zeus users.");
                return;
            }

            WispUsersInfo users = new WispUsersInfo();
            users.AllowRemoteConnections = ZeusServer.AllowRemote;

            r.ReplyPacket = CreateStandardReply(r, ReplyType.OK, "");
            r.ReplyPacket.Parms.SetProperty(1, MyServer.ServerUserID);
            r.ReplyPacket.Parms.SetProperty(2, users);
            users.TotalUserCount = -1;

            if (MyServer.RequireAuthentication)
            {
                int totalUsers = 0;
                Membership.GetAllUsers(0, 1, out totalUsers);
                users.TotalUserCount = totalUsers;
                users.UserDataStore = "Database";
            }
        }
        private void GetAllDBUsers(WispUsersInfo users, int page, int numPerPage)
        {
            SqlMembershipProvider prov = Membership.Provider as SqlMembershipProvider;

            users.UserDataStore = "Database";
            int totalRecords = 0;
            MembershipUserCollection allUsers = null;
            if (numPerPage == -1 && page == -1)
            {
                allUsers = Membership.GetAllUsers();
                users.TotalUserCount = allUsers.Count;
            }
            else
            {
                allUsers = Membership.GetAllUsers(page, numPerPage, out totalRecords);
                users.TotalUserCount = totalRecords;
            }

            foreach (MembershipUser u in allUsers)
            {
                //string[] roles = Roles.GetRolesForUser(u.UserName);
                users.Users.Add(new WispUsersInfo.User(u.UserName, new string[0], u.IsLockedOut, (Guid)u.ProviderUserKey, u.Email, u.LastLoginDate));
            }
        }