示例#1
0
    // create datasource for user gridview
    private void BindUserAccounts()
    {
        int totalRecords;
        MembershipUserCollection allUsers = Membership.GetAllUsers(this.PageIndex, this.PageSize, out totalRecords);
        MembershipUserCollection filteredUsers = new MembershipUserCollection();

        bool isOnline = true;
        foreach (MembershipUser user in allUsers)
        {
            // if user is currently online, add to gridview list
            if (user.IsOnline == isOnline)
            {
                filteredUsers.Add(user);
            }
        }

        // Enable/disable the pager buttons based on which page we're on
        bool visitingFirstPage = (this.PageIndex == 0);
        lnkFirst.Enabled = !visitingFirstPage;
        lnkPrev.Enabled = !visitingFirstPage;

        int lastPageIndex = (totalRecords - 1) / this.PageSize;
        bool visitingLastPage = (this.PageIndex >= lastPageIndex);
        lnkNext.Enabled = !visitingLastPage;
        lnkLast.Enabled = !visitingLastPage;

        UsersGridView.DataSource = filteredUsers;
        UsersGridView.DataBind();
    }
示例#2
0
    public MembershipUserCollection GetMembers(int maximumRows, int startRowIndex)
    {
        int totalRecords = 0;

        MembershipUserCollection users = null;

        if (!string.IsNullOrEmpty(_rolenameToMatch))
        {
            users = new MembershipUserCollection();

            foreach (string usr in Roles.GetUsersInRole(_rolenameToMatch))
                users.Add(Membership.GetUser(usr));

            totalRecords = users.Count;
        }
        else if (!string.IsNullOrEmpty(_usernameToMatch))
            users = Membership.FindUsersByName(_usernameToMatch, maximumRows > 0 ? startRowIndex / maximumRows : 0, maximumRows > 0 ? maximumRows : int.MaxValue, out totalRecords);
        else if (!string.IsNullOrEmpty(_emailToMatch))
            users = Membership.FindUsersByEmail(_emailToMatch, maximumRows > 0 ? startRowIndex / maximumRows : 0, maximumRows > 0 ? maximumRows : int.MaxValue, out totalRecords);
        else
            users = Membership.GetAllUsers(maximumRows > 0 ? startRowIndex / maximumRows : 0, maximumRows, out totalRecords);

        HttpContext.Current.Items["MembershipUsers_TotalCount"] = totalRecords;

        return users;
    }
示例#3
0
    public static MembershipUserCollection FindUsersByRole(string[] roles)
    {
        MembershipUserCollection msc = new MembershipUserCollection();

        roles.Select(role => Roles.GetUsersInRole(role))
        .Aggregate((a, b) => a.Union(b).ToArray())
        .Distinct()
        .Select(user => Membership.GetUser(user))
        .ToList().ForEach(user => msc.Add(user));

        return msc;
    }
示例#4
0
    public DataSet CustomGetUsersOnline()
    {
        DataSet ds = new DataSet();
        DataTable dt = new DataTable();
        dt = ds.Tables.Add("Users");

        MembershipUserCollection muc = Membership.GetAllUsers();
        MembershipUserCollection OnlineUsers = new MembershipUserCollection();

        bool isOnline = true;

        dt.Columns.Add("UserName", Type.GetType("System.String"));
        dt.Columns.Add("Email", Type.GetType("System.String"));
        //dt.Columns.Add("PasswordQuestion", Type.GetType("System.String"));
        //dt.Columns.Add("Comment", Type.GetType("System.String"));
        //dt.Columns.Add("ProviderName", Type.GetType("System.String"));
        dt.Columns.Add("CreationDate", Type.GetType("System.DateTime"));
        dt.Columns.Add("LastLoginDate", Type.GetType("System.DateTime"));
        dt.Columns.Add("LastActivityDate", Type.GetType("System.DateTime"));
        //dt.Columns.Add("LastPasswordChangedDate", Type.GetType("System.DateTime"));
        //dt.Columns.Add("LastLockoutDate", Type.GetType("System.DateTime"));
        dt.Columns.Add("IsApproved", Type.GetType("System.Boolean"));
        dt.Columns.Add("IsLockedOut", Type.GetType("System.Boolean"));
        dt.Columns.Add("IsOnline", Type.GetType("System.Boolean"));

        foreach (MembershipUser mu in muc)
        {
            // if user is currently online, add to gridview list
            if (mu.IsOnline == isOnline)
            {
                OnlineUsers.Add(mu);

            DataRow dr;
            dr = dt.NewRow();
            dr["UserName"] = mu.UserName;
            dr["Email"] = mu.Email;
            dr["CreationDate"] = mu.CreationDate;
            dr["LastLoginDate"] = mu.LastLoginDate;
            dr["LastActivityDate"] = mu.LastActivityDate;
            dr["IsApproved"] = mu.IsApproved;
            dr["IsLockedOut"] = mu.IsLockedOut;
            dr["IsOnline"] = mu.IsOnline;
            // you can add the other columns that you want to include in your return value
            dt.Rows.Add(dr);

            }
        }
        return ds;
    }
示例#5
0
        public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            MembershipUserCollection results = new MembershipUserCollection();

            totalRecords = 0;
            DatabaseContext    db     = System.Web.Mvc.DependencyResolver.Current.GetService(typeof(DatabaseContext)) as DatabaseContext;
            StockwinnersMember member = db.StockwinnersMembers.FirstOrDefault(m => m.EmailAddress == emailToMatch);

            if (member != null)
            {
                results.Add(MembershipProvider.GetMembershipUser(member));
                totalRecords = 1;
            }

            return(results);
        }
示例#6
0
文件: UserManager.cs 项目: tjsas1/RHP
        /// <summary>
        /// Gets all the users in the database by the role name
        /// </summary>
        /// <param name="roleName">Role to filter the users from</param>
        /// <returns>All users with the roleName</returns>
        public MembershipUserCollection GetUsersListByRole(RHP.Common.Enums.UserRoles roleName)
        {
            MembershipUserCollection UserCollection = null;

            string[] userList;
            userList = Roles.GetUsersInRole(roleName.ToString());

            foreach (string userName in userList)
            {
                MembershipUser user;
                user = Membership.GetUser(userName);
                UserCollection.Add(user);
            }

            return(UserCollection);
        }
示例#7
0
 public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
 {
     using (var session = documentStore.OpenSession())
     {
         var results = from _user in session.Query <User>()
                       where _user.Username == usernameToMatch
                       select _user;
         totalRecords = results.Count();
         var users = new MembershipUserCollection();
         foreach (var user in results)
         {
             users.Add(new BirdBrainMembershipUser(user));
         }
         return(users);
     }
 }
示例#8
0
        public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize,
                                                                 out int totalRecords)
        {
            var membershipUsers = new MembershipUserCollection();

            var query = Query.And(Query.EQ("ApplicationName", ApplicationName), Query.Matches("Username", usernameToMatch));

            totalRecords = (int)mongoCollection.FindAs <BsonDocument>(query).Count();

            foreach (var bsonDocument in mongoCollection.FindAs <BsonDocument>(query).SetSkip(pageIndex * pageSize).SetLimit(pageSize))
            {
                membershipUsers.Add(ToMembershipUser(bsonDocument));
            }

            return(membershipUsers);
        }
示例#9
0
        public MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            if (pageSize <= 0)
            {
                throw new ArgumentException("Page size must be more than zero");
            }
            totalRecords = db.Users.Count();
            var users = db.Users.ToPagedList(pageIndex, pageSize);
            MembershipUserCollection collection = new MembershipUserCollection();

            foreach (var user in users)
            {
                collection.Add(user);
            }
            return(collection);
        }
示例#10
0
        public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            var oktaUsers = okta.users.GetList();
            var result    = new MembershipUserCollection();
            var records   = 0;

            foreach (var oktaUser in oktaUsers.Results)
            {
                var user = okta.GetOktaMembershipUser(oktaUser, false);
                records++;
                result.Add(user);
            }
            totalRecords = records;
            return(result);
            // return base.GetAllUsers(pageIndex, pageSize, out totalRecords);
        }
示例#11
0
        public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            MembershipUserCollection collection = new MembershipUserCollection();

            DataAccess.T_User user = DataAccess.UserCRUD.GetUserByEmail(emailToMatch);
            if (user == null)
            {
                totalRecords = 0;
            }
            else
            {
                collection.Add(new MembershipUser("Id", user.Login, user.Id, user.Email, "", "", true, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now));
                totalRecords = 1;
            }
            return(collection);
        }
示例#12
0
        public override MembershipUserCollection FindUsersByEmail(
            string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            var collection = new MembershipUserCollection();

            var users = this.userStorage.GetUsers(pageIndex, pageSize).Where(u => u.Email.Contains(emailToMatch));

            totalRecords = users.Count();

            foreach (var user in users)
            {
                collection.Add(this.GetMembershipUser(user));
            }

            return(collection);
        }
        public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            // Note: This implementation ignores pageIndex and pageSize,
            // and it doesn't sort the MembershipUser objects returned
            // Make sure the data source has been loaded
            ReadMembershipDataStore();
            var users = new MembershipUserCollection();

            foreach (var pair in _users)
            {
                users.Add(pair.Value);
            }

            totalRecords = users.Count;
            return(users);
        }
示例#14
0
        private void BindUserAccounts()
        {
            int totalRecords;
            MembershipUserCollection allUsers = Membership.GetAllUsers(this.PageIndex, this.PageSize, out totalRecords);

            if (UserRoles.SelectedIndex > 0)
            {
                allUsers = Membership.GetAllUsers();
            }

            MembershipUserCollection filteredUsers = new MembershipUserCollection();

            if (UserRoles.SelectedIndex > 0)
            {
                string[] usersInRole = Roles.GetUsersInRole(UserRoles.SelectedValue);
                foreach (MembershipUser user in allUsers)
                {
                    foreach (string userInRole in usersInRole)
                    {
                        if (userInRole == user.UserName && user.IsApproved)
                        {
                            filteredUsers.Add(user);

                            break;
                        }
                    }
                }
            }
            else
            {
                filteredUsers = allUsers;
            }

            bool visitingFirstPage = (this.PageIndex == 0);

            lnkFirst.Enabled = !visitingFirstPage;
            lnkPrev.Enabled  = !visitingFirstPage;

            int  lastPageIndex    = (totalRecords - 1) / this.PageSize;
            bool visitingLastPage = (this.PageIndex >= lastPageIndex);

            lnkNext.Enabled = !visitingLastPage;
            lnkLast.Enabled = !visitingLastPage;

            UsersGridView.DataSource = filteredUsers;
            UsersGridView.DataBind();
        }
示例#15
0
        public MembershipUserCollection GetAllUsers()
        {
            //IKernel kernel = new StandardKernel(new BindingModule());
            //IUserService userService = kernel.Get<IUserService>();

            IUserService userService = DependencyResolver.Current.GetService <IUserService>();

            MembershipUserCollection users = new MembershipUserCollection();

            foreach (User user in userService.GetAll())
            {
                users.Add(new MembershipUser("CommonMembershipProvider", user.Email, user.Id, user.Email, null,
                                             null, true, true, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue));
            }

            return(users);
        }
示例#16
0
        public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            List <UserInfo>          UserList = UserInfo.getAllUsers();
            MembershipUserCollection result   = new MembershipUserCollection();

            int startIndex = pageIndex * pageSize;

            totalRecords = 0;

            for (int i = 0; i < pageSize && pageIndex + i < UserList.Count; i++)
            {
                result.Add(getMembershipUser(UserList[startIndex + i]));
                totalRecords++;
            }

            return(result);
        }
示例#17
0
        /// <summary></summary>
        public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            MembershipUserCollection result = new MembershipUserCollection();

            IDictionary <string, IAccountInfo> users = MembershipStorage.Instance.Accounts;

            foreach (String username in users.Keys)
            {
                if (username.StartsWith(usernameToMatch))
                {
                    result.Add(this.GetUser(usernameToMatch, false));
                }
            }

            totalRecords = users.Count;
            return(result);
        }
示例#18
0
        public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            MembershipUserCollection AllUsers = new MembershipUserCollection();

            DataTable dtUsers = SecurityAdapters.MembershipAdapter.GetAllUsers();

            totalRecords = dtUsers.Rows.Count;

            if (totalRecords > 0)
            {
                for (int i = 0; i < dtUsers.Rows.Count; i++)
                {
                    AllUsers.Add(GetUserInfo(dtUsers.Rows[i]));
                }
            }
            return(AllUsers);
        }
示例#19
0
        public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            var membershipUsers = new MembershipUserCollection();

            var query = Query.EQ("ApplicationName", ApplicationName);

            totalRecords = (int)mongoCollection.FindAs <BsonDocument>(query).Count();

            var page = mongoCollection.FindAs <BsonDocument>(query).SetSkip(pageIndex * pageSize).SetLimit(pageSize);

            foreach (var bsonDocument in page)
            {
                membershipUsers.Add(ToMembershipUser(bsonDocument));
            }

            return(membershipUsers);
        }
示例#20
0
        public virtual MembershipUserCollection GetMembershipUsers(string providerName, int startIndex, int maxResults,
                                                                   out int totalRecords)
        {
            totalRecords = 0;
            CountFilter cf = new CountFilter(startIndex, maxResults);
            MembershipUserCollection muc = new MembershipUserCollection();

            foreach (User u in Children)
            {
                if (cf.Match(u))
                {
                    muc.Add(u.GetMembershipUser(providerName));
                }
                totalRecords++;
            }
            return(muc);
        }
示例#21
0
        public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            MembershipUserCollection UsersMatchingUsername = new MembershipUserCollection();

            DataTable dtUsers = SecurityAdapters.MembershipAdapter.GetUsersByUsername(usernameToMatch);

            totalRecords = dtUsers.Rows.Count;

            if (totalRecords > 0)
            {
                for (int i = 0; i < dtUsers.Rows.Count; i++)
                {
                    UsersMatchingUsername.Add(GetUserInfo(dtUsers.Rows[i]));
                }
            }
            return(UsersMatchingUsername);
        }
示例#22
0
        public MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            var response       = _securityService.GetAllUsers(new GetAllUsersRequest(Ticket, pageIndex, pageSize));
            var userCollection = new MembershipUserCollection();

            foreach (var user in response.GetAllUsersResult)
            {
                userCollection.Add(new MembershipUser(
                                       user.ProviderName, user.UserName, user.ProviderKey, user.Email, user.PassWordquestion,
                                       user.Comment, user.IsActive, user.IsLocketOut,
                                       user.CreationDate, user.LastLoginDate, user.LastActivityDate, user.LastPasswordChangedDate,
                                       user.LastLockedOutDate));
            }

            totalRecords = response.totalRecords;
            return(userCollection);
        }
        protected void BindUsersList()
        {
            MembershipUserCollection userList = Membership.GetAllUsers();

            var approvedUser = new MembershipUserCollection();

            foreach (MembershipUser user in userList)
            {
                if (user.IsApproved && !user.IsLockedOut)
                {
                    approvedUser.Add(user);
                }
            }

            dgPortalUsers.DataSource = approvedUser;
            dgPortalUsers.DataBind();
            listDV.Visible = true;
        }
示例#24
0
        public MembershipUserCollection FindUsers(string usernameToMatch, string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            var users = GetUsers()
                        .Where(x => string.IsNullOrEmpty(usernameToMatch) || Regex.IsMatch(x.Email, usernameToMatch, RegexOptions.IgnoreCase))
                        .Where(x => string.IsNullOrEmpty(emailToMatch) || Regex.IsMatch(x.Email, emailToMatch, RegexOptions.IgnoreCase))
                        .ToArray();

            totalRecords = users.Length;

            var membershipUsers = new MembershipUserCollection();

            users
            .Skip(pageIndex * pageSize)
            .Take(pageSize)
            .Each(x => membershipUsers.Add(Map(x)));

            return(membershipUsers);
        }
        public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            MembershipUserCollection membershipUsers = new MembershipUserCollection();
            int startIndex           = pageSize * pageIndex;
            IEnumerable <User> users = UsersCollection.FindByApplicationName(ApplicationName, startIndex, pageSize);

            totalRecords = users.Count();
            if (totalRecords == 0)
            {
                return(membershipUsers);
            }

            foreach (var user in users)
            {
                membershipUsers.Add(user);
            }
            return(membershipUsers);
        }
示例#26
0
 public MembershipUserCollection GetUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
 {
     using (var context = new Security())
     {
         totalRecords = context.Users.Count(f => f.Name.StartsWith(usernameToMatch));
         var selUsr = from usr in context.Users
                      where usr.Name.StartsWith(usernameToMatch)
                      select usr;
         var toRet = selUsr.OrderBy(o => o.Id).Skip(pageIndex).Take(pageSize);
         MembershipUserCollection coll = new MembershipUserCollection();
         foreach (var el in toRet)
         {
             MembershipUser usr = new MembershipUser("MyProvider", el.Name, el.Id, null, null, null, true, false, DateTime.MinValue, el.LastLogin.FromNullable(), DateTime.MinValue, DateTime.MinValue, DateTime.MinValue);
             coll.Add(usr);
         }
         return(coll);
     }
 }
        /// <summary>
        /// Gets a collection of membership users where the user name contains the specified user name to match.
        /// </summary>
        /// <returns>A <see cref="T:System.Web.Security.MembershipUserCollection"/> collection that contains a page of <paramref name="pageSize"/><see cref="T:System.Web.Security.MembershipUser"/> objects beginning at the page specified by <paramref name="pageIndex"/>.</returns>
        /// <param name="usernameToMatch">The user name to search for.</param>
        /// <param name="pageIndex">The index of the page of results to return. <paramref name="pageIndex"/> is zero-based.</param>
        /// <param name="pageSize">The size of the page of results to return.</param>
        /// <param name="totalRecords">The total number of matched users.</param>
        public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            if (this.initialized)
            {
                var result = new MembershipUserCollection();

                var crmUsers = this.userRepository.FindUsersByName(usernameToMatch, pageIndex, pageSize, out totalRecords);
                foreach (var crmUser in crmUsers)
                {
                    result.Add(new CRMMembershipUser(this.Name, crmUser));
                }

                return(result);
            }

            totalRecords = 0;
            return(new MembershipUserCollection());
        }
示例#28
0
        private void BindUserAccounts()
        {
            MembershipUserCollection allUsers      = Membership.GetAllUsers();
            MembershipUserCollection filteredUsers = new MembershipUserCollection();

            bool isOnline = true;

            foreach (MembershipUser user in allUsers)
            {
                if (user.IsOnline == isOnline)
                {
                    filteredUsers.Add(user);
                }
            }

            UsersGridView.DataSource = filteredUsers;
            UsersGridView.DataBind();
        }
示例#29
0
        private MembershipUserCollection FindUsersByEmailInternal(string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            totalRecords = 0;
            if (string.IsNullOrWhiteSpace(emailToMatch))
            {
                return(null);
            }

            var retval   = new MembershipUserCollection();
            var customer = repository.GetCustomerByEmail(emailToMatch, StormContext.CultureCode);

            if (customer != null)
            {
                retval.Add(GetUser(customer));
            }
            totalRecords = retval.Count;
            return(retval);
        }
        public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize,
                                                                  out int totalRecords)
        {
            var membershipUsers = new MembershipUserCollection();

            IMongoQuery query = Query.And(Query.EQ("ApplicationName", ApplicationName),
                                          Query.Matches("LoweredEmail", emailToMatch.ToLowerInvariant()));

            totalRecords = (int)mongoCollection.FindAs <BsonDocument>(query).Count();

            foreach (
                BsonDocument bsonDocument in
                mongoCollection.FindAs <BsonDocument>(query).SetSkip(pageIndex * pageSize).SetLimit(pageSize))
            {
                membershipUsers.Add(ToMembershipUser(bsonDocument));
            }

            return(membershipUsers);
        }
示例#31
0
        public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            var foo = _userDao.AllUsers();

            totalRecords = foo.Count;

            var result = new MembershipUserCollection();

            foo.ToList().ForEach(x =>
            {
                var user = GetUser(x.UserName, true);
                if (user != null)
                {
                    result.Add(user);
                }
            });

            return(result);
        }
        public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            IUserRepository          repo   = Repository.Instance.Registered(typeof(User)) as IUserRepository;
            MembershipUserCollection mUsers = new MembershipUserCollection();

            try
            {
                var users = repo.GetUsers(null, null, pageIndex, pageSize, out totalRecords);
                foreach (IUser user in users)
                {
                    mUsers.Add(new LightweightMembershipUser(user));
                }
                return(mUsers);
            }
            catch (Exception ex)
            {
                throw new ProviderException("Failed to find users", ex);
            }
        }
        private MembershipUserCollection FindUsers <TIndex>(Expression <Func <User, object> > fieldSelector, string searchTerms, int pageIndex, int pageSize, out int totalRecords)
            where TIndex : AbstractIndexCreationTask, new()
        {
            var membershipUsers = new MembershipUserCollection();

            using (var session = _documentStore.OpenSession())
            {
                var users = session.Query <User, TIndex>()
                            .Where(x => x.ApplicationName == ApplicationName)
                            .Search(fieldSelector, searchTerms, options: SearchOptions.And);
                totalRecords = users.Count();
                var pagedUsers = users.Skip(pageIndex * pageSize).Take(pageSize);
                foreach (var user in pagedUsers)
                {
                    membershipUsers.Add(UserToMembershipUser(user));
                }
            }
            return(membershipUsers);
        }
示例#34
0
        public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            List <Usuario>           usuarios = userRo.GetUsuarios();
            MembershipUserCollection users    = new MembershipUserCollection();

            foreach (var user in usuarios)
            {
                MembershipUser memUser = new MembershipUser("CustomMembershipProvider",
                                                            user.email, user.codigo, user.email,
                                                            string.Empty, string.Empty,
                                                            true, false, DateTime.MinValue,
                                                            DateTime.MinValue,
                                                            DateTime.MinValue,
                                                            DateTime.Now, DateTime.Now);
                users.Add(memUser);
            }
            totalRecords = users.Count;
            return(users);
        }
示例#35
0
    // create datasource for user gridview
    private void BindUserAccounts()
    {
        int totalRecords;
        MembershipUserCollection allUsers = Membership.GetAllUsers(this.PageIndex, this.PageSize, out totalRecords);
        MembershipUserCollection filteredUsers = new MembershipUserCollection();

        if (UserRoles.SelectedIndex > 0)
        {
            string[] usersInRole = Roles.GetUsersInRole(UserRoles.SelectedValue);
            foreach (MembershipUser user in allUsers)
            {
                foreach (string userInRole in usersInRole)
                {
                    if (userInRole == user.UserName)
                    {
                        filteredUsers.Add(user);

                        // Break out of the inner foreach loop to avoid unneeded checking.
                        break;
                    }
                }
            }
        }
        else
        {
            filteredUsers = allUsers;
        }

        // Enable/disable the pager buttons based on which page we're on
        bool visitingFirstPage = (this.PageIndex == 0);
        lnkFirst.Enabled = !visitingFirstPage;
        lnkPrev.Enabled = !visitingFirstPage;

        int lastPageIndex = (totalRecords - 1) / this.PageSize;
        bool visitingLastPage = (this.PageIndex >= lastPageIndex);
        lnkNext.Enabled = !visitingLastPage;
        lnkLast.Enabled = !visitingLastPage;

        UsersGridView.DataSource = filteredUsers;
        UsersGridView.DataBind();
    }
示例#36
0
    // create datasource for user gridview
    private void BindUserAccounts()
    {
        int totalRecords;
        MembershipUserCollection allUsers = Membership.GetAllUsers(this.PageIndex, this.PageSize, out totalRecords);
        MembershipUserCollection filteredUsers = new MembershipUserCollection();

        // create boolean for dropdown control list
        bool isActive;
        if (active.SelectedValue == "Active Accounts")
        {
            isActive = true;
        }
        else
        {
            isActive = false;
        }

        // create boolean Values for dropdown list
        foreach (MembershipUser user in allUsers)
        {
            if (user.IsApproved == isActive)
            {
                filteredUsers.Add(user);
            }
        }

        // Enable/disable the pager buttons based on which page we're on
        bool visitingFirstPage = (this.PageIndex == 0);
        lnkFirst.Enabled = !visitingFirstPage;
        lnkPrev.Enabled = !visitingFirstPage;

        int lastPageIndex = (totalRecords - 1) / this.PageSize;
        bool visitingLastPage = (this.PageIndex >= lastPageIndex);
        lnkNext.Enabled = !visitingLastPage;
        lnkLast.Enabled = !visitingLastPage;

        UsersGridView.DataSource = filteredUsers;
        UsersGridView.DataBind();
    }
    /// <summary>
    /// Retrieves a collection of all the users.
    /// This implementation ignores pageIndex and pageSize,
    /// and it doesn't sort the MembershipUser objects returned.
    /// </summary>
    public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
    {
        ReadMembershipDataStore();
        MembershipUserCollection users = new MembershipUserCollection();

        foreach (KeyValuePair<string, MembershipUser> pair in _Users)
        {
          users.Add(pair.Value);
        }

        totalRecords = users.Count;
        return users;
    }
 public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
 {
     List<Person> list = PersonModel.ListPerson();
     totalRecords = list.Count;
     MembershipUserCollection ret = new MembershipUserCollection();
     foreach (Person p in list)
         ret.Add(p);
     return ret;
 }
    public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
    {
        List<MembershipUserCollection> mucs = new List<MembershipUserCollection>();
        foreach (string providerName in m_ProviderList)
        {
            MembershipProvider mp = Membership.Providers[providerName];
            mucs.Add(mp.GetAllUsers(pageIndex, pageSize, out totalRecords));
        }
        MembershipUserCollection allUsers = new MembershipUserCollection();
        totalRecords = 0;

        List<string> userNames = new List<string>();

        foreach (MembershipUserCollection muc in mucs)
        {
            foreach (MembershipUser mu in muc)
            {
                if (!(userNames.Contains(mu.UserName)))
                {
                    userNames.Add(mu.UserName);
                    allUsers.Add(mu);
                    totalRecords++;
                }
            }
        }
        return allUsers;
    }
示例#40
0
 public static MembershipUserCollection GetUsersList(string name_part, int group_id)
 {
     string sErr = "";
     DBManager db = new DBManager(ConfigurationManager.AppSettings["SYS_DSN"]);
     MembershipUserCollection result = new MembershipUserCollection();
     try
     {
         string sql = string.Concat("exec spSysGetUsers @SearchString='", name_part, "',@GroupId=", group_id.ToString());
         DataTable dt = db.getDataTable(sql, out sErr);
         db.CloseOleDB();
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             MembershipUser oUser = Membership.GetUser(dt.Rows[i]["UserName"].ToString());
             if (oUser != null)
             {
                 result.Add(oUser);
             }
         }
     }
     catch (Exception exception)
     {
         HttpContext.Current.Response.Write(exception.Message);
     }
     return result;
 }
示例#41
0
 public static MembershipUserCollection GetUsers(string name_part)
 {
     MembershipUserCollection allUsers;
     if (!(name_part == ""))
     {
         MembershipUserCollection users = new MembershipUserCollection();
         MembershipUserCollection result = new MembershipUserCollection();
         foreach (MembershipUser u in Membership.GetAllUsers())
         {
             if ((u == null ? false : u.UserName.Contains(name_part)))
             {
                 result.Add(u);
             }
         }
         allUsers = result;
     }
     else
     {
         allUsers = Membership.GetAllUsers();
     }
     return allUsers;
 }
    //receives a username of type string, and page index and page size of type integer and total records of type out integer
    //returns a collection of users that match the given username
    //returns NULL if no users match the given username
    public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
    {
        //MAS
        using (OrganizationService service = new OrganizationService(OurConnect()))
        {

            ConditionExpression usernameCondition = new ConditionExpression();
            ConditionExpression deleteCondition = new ConditionExpression();
            ConditionExpression appCondition = new ConditionExpression();//creates a new condition.

            usernameCondition.AttributeName = consts.username; //column we want to check against
            usernameCondition.Operator = ConditionOperator.Equal; //checking against equal values
            usernameCondition.Values.Add(usernameToMatch); //checks email against rosetta_email in CRM

            deleteCondition.AttributeName = consts.deleteduser;
            deleteCondition.Operator = ConditionOperator.Equal;
            deleteCondition.Values.Add(false);

            appCondition.AttributeName = consts.appname;
            appCondition.Operator = ConditionOperator.Equal;
            appCondition.Values.Add(_ApplicationName);

            FilterExpression filter = new FilterExpression(); //create new filter for the condition
            filter.Conditions.Add(usernameCondition);
            filter.Conditions.Add(deleteCondition);
            filter.Conditions.Add(appCondition);//add condition to the filter

            QueryExpression query = new QueryExpression(consts.useraccount); //create new query
            query.Criteria.AddFilter(filter); //query CRM with the new filter for email
            EntityCollection collection = service.RetrieveMultiple(query); //retrieve all records with same email

            totalRecords = collection.TotalRecordCount;

            if (totalRecords != 0 && totalRecords >= ((pageSize * pageIndex) + 1))
            {
                MembershipUserCollection usersToReturn = new MembershipUserCollection();
                var start = pageSize * pageIndex;
                var end = (pageSize * pageIndex) + pageSize;
                for (int i = start; i < end; i++)//gets all the records out of ec assigns them to userstoreturn.
                {
                    MembershipUser TempUser = GetUser((string)collection.Entities[i][consts.username]);
                    usersToReturn.Add(TempUser);

                }
                return usersToReturn;
            }
            else
            {
                return null;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Repeater repeater;
        Panel panel;
        ProfileCommon profilecommon;
        string[] user;
        string operation;

        if (!IsPostBack)
        {
            operation = Request.QueryString["operation"];

            if (operation != null)
            {
                if (operation.Equals("edit"))
                {
                    repeater = (Repeater)LoginView1.FindControl("Repeater1");
                    if (repeater != null)
                    {
                        repeater.Visible = false;
                    }

                    panel = (Panel)LoginView1.FindControl("Panel1");
                    if (panel != null)
                    {
                        panel.Visible = true;
                    }

                    ((DropDownList)LoginView1.FindControl("DateOfBirth1")).DataSource = GlobalVariable.day;
                    ((DropDownList)LoginView1.FindControl("DateOfBirth1")).DataBind();
                    ((DropDownList)LoginView1.FindControl("DateOfBirth2")).DataSource = GlobalVariable.month;
                    ((DropDownList)LoginView1.FindControl("DateOfBirth2")).DataBind();
                    ((DropDownList)LoginView1.FindControl("DateOfBirth3")).DataSource = GlobalVariable.year;
                    ((DropDownList)LoginView1.FindControl("DateOfBirth3")).DataBind();
                    ((DropDownList)LoginView1.FindControl("Nationality")).DataSource = GlobalVariable.nationality;
                    ((DropDownList)LoginView1.FindControl("Nationality")).DataBind();
                    ((DropDownList)LoginView1.FindControl("Country")).DataSource = GlobalVariable.country;
                    ((DropDownList)LoginView1.FindControl("Country")).DataBind();

                    profilecommon = Profile.GetProfile(Request.QueryString["username"]);

                    ((TextBox)LoginView1.FindControl("FirstName")).Text = profilecommon.User.FirstName;
                    ((TextBox)LoginView1.FindControl("LastName")).Text = profilecommon.User.LastName;
                    dateofbirth = profilecommon.User.DateOfBirth.Split('/');
                    ((DropDownList)LoginView1.FindControl("DateOfBirth1")).SelectedIndex = Array.IndexOf(GlobalVariable.day, dateofbirth.ElementAt(0));
                    if (dateofbirth.Count() > 1)
                    {
                        ((DropDownList)LoginView1.FindControl("DateOfBirth2")).SelectedIndex = Array.IndexOf(GlobalVariable.month, dateofbirth.ElementAt(1));
                    }
                    if (dateofbirth.Count() > 2)
                    {
                        ((DropDownList)LoginView1.FindControl("DateOfBirth3")).SelectedIndex = Array.IndexOf(GlobalVariable.year, dateofbirth.ElementAt(2));
                    }
                    if (profilecommon.User.Gender.Equals("Male"))
                    {
                        ((RadioButton)LoginView1.FindControl("Gender1")).Checked = true;
                    }
                    else
                    {
                        ((RadioButton)LoginView1.FindControl("Gender2")).Checked = true;
                    }
                    ((DropDownList)LoginView1.FindControl("Nationality")).SelectedIndex = Array.IndexOf(GlobalVariable.nationality, profilecommon.User.Nationality);
                    ((TextBox)LoginView1.FindControl("Street")).Text = profilecommon.User.Street;
                    ((TextBox)LoginView1.FindControl("HouseNumber")).Text = profilecommon.User.HouseNumber;
                    ((TextBox)LoginView1.FindControl("City")).Text = profilecommon.User.City;
                    ((DropDownList)LoginView1.FindControl("Country")).SelectedIndex = Array.IndexOf(GlobalVariable.country, profilecommon.User.Country);
                    ((TextBox)LoginView1.FindControl("PostalCode")).Text = profilecommon.User.PostalCode;
                    ((Label)LoginView1.FindControl("EmailAddress")).Text = Request.QueryString["username"];
                    if (Membership.GetUser(Request.QueryString["username"]).IsApproved)
                    {
                        ((RadioButton)LoginView1.FindControl("Status1")).Checked = true;
                    }
                    else
                    {
                        ((RadioButton)LoginView1.FindControl("Status2")).Checked = true;
                    }
                }
                else if (operation.Equals("delete"))
                {
                    Membership.DeleteUser(Request.QueryString["username"]);

                    Response.Redirect("./managestudent.aspx");
                }
            }
            else
            {
                user = Roles.GetUsersInRole("User");
                membershipusercollection = new MembershipUserCollection();

                foreach (string username in user)
                {
                    membershipusercollection.Add(Membership.GetUser(username));
                }

                repeater = (Repeater)LoginView1.FindControl("Repeater1");
                if (repeater != null)
                {
                    repeater.DataSource = membershipusercollection;
                    repeater.DataBind();
                    repeater.Visible = true;
                }

                panel = (Panel)LoginView1.FindControl("Panel1");
                if (panel != null)
                {
                    panel.Visible = false;
                }
            }
        }
        else
        {
            operation = Request.QueryString["operation"];

            if (operation == null)
            {
                user = Roles.GetUsersInRole("User");
                membershipusercollection = new MembershipUserCollection();

                foreach (string username in user)
                {
                    membershipusercollection.Add(Membership.GetUser(username));
                }

                repeater = (Repeater)LoginView1.FindControl("Repeater1");
                if (repeater != null)
                {
                    repeater.DataSource = membershipusercollection;
                    repeater.DataBind();
                    repeater.Visible = true;
                }

                panel = (Panel)LoginView1.FindControl("Panel1");
                if (panel != null)
                {
                    panel.Visible = false;
                }
            }
        }
    }
 public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
 {
     MembershipUserCollection MembershipUsers = new MembershipUserCollection();
     using (DataContext Context = new DataContext())
     {
         totalRecords = Context.Users.Where(Usr => Usr.Username == usernameToMatch).Count();
         IQueryable<User> Users = Context.Users.Where(Usr => Usr.Username == usernameToMatch).OrderBy(Usrn => Usrn.Username).Skip(pageIndex * pageSize).Take(pageSize);
         foreach (User user in Users)
         {
             MembershipUsers.Add(new MembershipUser(Membership.Provider.Name, user.Username, user.UserId, user.Email, null, null, user.IsApproved, user.IsLockedOut, user.CreateDate.Value, user.LastLoginDate.Value, user.LastActivityDate.Value, user.LastPasswordChangedDate.Value, user.LastLockoutDate.Value));
         }
     }
     return MembershipUsers;
 }
示例#45
0
    public override MembershipUserCollection GetAllUsers(int pageIndex, 
        int pageSize, out int totalRecords)
    {
        // Note: This implementation ignores pageIndex and pageSize,
        // and it doesn't sort the MembershipUser objects returned
        // Make sure the data source has been loaded

        ReadMembershipDataStore();

        MembershipUserCollection users =
        new MembershipUserCollection();

        foreach (KeyValuePair<string, MembershipUser> pair in _Users)
        users.Add(pair.Value);

        totalRecords = users.Count;

        return users;
    }
    //receives as input a page index and page size of type integer and the total records of type out integer
    //returns a collection containing all the users in the CRM account
    //returns NULL if there are no users to return
    public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
    {
        //MAS
        using (OrganizationService service = new OrganizationService(OurConnect()))
        {

            ConditionExpression deleteCondition = new ConditionExpression();
            ConditionExpression appCondition = new ConditionExpression();//creates a new condition.

            deleteCondition.AttributeName = consts.deleteduser;
            deleteCondition.Operator = ConditionOperator.Equal;
            deleteCondition.Values.Add(false);

            appCondition.AttributeName = consts.appname;
            appCondition.Operator = ConditionOperator.Equal;
            appCondition.Values.Add(_ApplicationName);

            FilterExpression filter = new FilterExpression(); //create new filter for the condition
            filter.Conditions.Add(deleteCondition);
            filter.Conditions.Add(appCondition);

            QueryExpression query = new QueryExpression(consts.useraccount); //create new query
            query.Criteria.AddFilter(filter);
            EntityCollection collection = service.RetrieveMultiple(query); //retrieve all records with same email

            totalRecords = collection.TotalRecordCount;

            if (totalRecords != 0 && totalRecords >= ((pageSize * pageIndex) + 1))
            {
                MembershipUserCollection usersToReturn = new MembershipUserCollection();
                var start = pageSize * pageIndex;
                var end = (pageSize * pageIndex) + pageSize;
                for (int i = start; i < end; i++)
                {
                    MembershipUser TempUser = GetUser((string)collection.Entities[i][consts.username]);
                    usersToReturn.Add(TempUser);

                }
                return usersToReturn;
            }
            else
            {
                return null;
            }
        }
    }
 public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
 {
     MembershipUserCollection MembershipUsers = new MembershipUserCollection();
     using (StudentContext Context = new StudentContext())
     {
         totalRecords = Context.Users.Count();
         IQueryable<User> Users = Context.Users.OrderBy(Usrn => Usrn.Username).Skip(pageIndex * pageSize).Take(pageSize);
         foreach (User user in Users)
         {
             MembershipUsers.Add(new MembershipUser(Membership.Provider.Name, user.Username, user.UserId, user.Email, null, null, user.StatusId == (int)UserStatus.Active, user.IsLockedOut, user.InsertedOn, user.LastLoginDate.Value, user.LastActivityDate.Value, user.LastPasswordChangedDate.Value, user.LastLockoutDate.Value));
         }
     }
     return MembershipUsers;
 }
    /// <summary>
    /// Retrieves a collection of all the users.
    /// This implementation ignores pageIndex and pageSize,
    /// and it doesn't sort the MembershipUser objects returned.
    /// </summary>
    public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
    {
        //ReadMembershipDataStore();
        MembershipUserCollection users = new MembershipUserCollection();

        List<Usuario> usuarios = UsuarioDal.GetAllUsuarios();

        if (usuarios != null)
        {
            foreach (Usuario usr in usuarios)
            {
                MembershipUser newuser = GetUser(usr.UserName, true);
                users.Add(newuser);
            }
        }

        totalRecords = users.Count;
        return users;
    }
 public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
 {
     MembershipUserCollection MembershipUsers = new MembershipUserCollection();
     using (PMToolContext Context = new PMToolContext())
     {
         totalRecords = Context.UserProfiles.Count();
         IQueryable<UserProfile> Users = Context.UserProfiles.OrderBy(Usrn => Usrn.UserName).Skip(pageIndex * pageSize).Take(pageSize);
         foreach (UserProfile user in Users)
         {
             MembershipUsers.Add(new MembershipUser(Membership.Provider.Name, user.UserName, user.UserId, user.Email, null, null, user.IsApproved, user.IsLockedOut, user.CreateDate.Value, user.LastLoginDate.Value, user.LastActivityDate.Value, user.LastPasswordChangedDate.Value, user.LastLockoutDate.Value));
         }
     }
     return MembershipUsers;
 }
 public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
 {
     SqlConnection conn = new SqlConnection(connectionString);
         SqlCommand cmd = new SqlCommand("SELECT Count(*) FROM Users", conn);
         MembershipUserCollection users = new MembershipUserCollection();
         SqlDataReader reader = null;
         totalRecords = 0;
         try
         {
             conn.Open();
             totalRecords = (int)cmd.ExecuteScalar();
             if (totalRecords <= 0)
             {
                 return users;
             }
             cmd.CommandText = "SELECT User_Id, User_Name, User_Family, User_Email, User_Phone, User_Password, User_CreateDate, User_LastLogInDate, User_Area " +
                              " FROM T_Users " +
                              " ORDER BY Username Asc";
             reader = cmd.ExecuteReader();
             int counter = 0;
             int startIndex = pageSize * pageIndex;
             int endIndex = startIndex + pageSize - 1;
             while (reader.Read())
             {
                 if (counter >= startIndex)
                 {
                     MembershipUser u = GetUserFromReader(reader);
                     users.Add(u);
                 }
                 if (counter >= endIndex) { cmd.Cancel(); }
                 counter++;
             }
         }
         catch (SqlException e)
         {
             if (WriteExceptionsToEventLog)
             {
                 WriteToEventLog(e, "GetAllUsers ");
                 throw new ProviderException(exceptionMessage);
             }
             else
             {
                 throw e;
             }
         }
         finally
         {
             if (reader != null) { reader.Close(); }
             conn.Close();
         }
         return users;
 }