當前位置: 首頁>>代碼示例>>C#>>正文


C# Security.MembershipUserCollection類代碼示例

本文整理匯總了C#中System.Web.Security.MembershipUserCollection的典型用法代碼示例。如果您正苦於以下問題:C# MembershipUserCollection類的具體用法?C# MembershipUserCollection怎麽用?C# MembershipUserCollection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MembershipUserCollection類屬於System.Web.Security命名空間,在下文中一共展示了MembershipUserCollection類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FindUsersByEmail

        /// <summary>
        /// Returns a collection of membership users for which the e-mail address field contains the specified e-mail address.
        /// </summary>
        /// <param name="emailToMatch">The e-mail address to search for.</param>
        /// <param name="pageIndex">The index of the page of results to return. 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>
        /// <returns>
        /// A <see cref="T:System.Web.Security.MembershipUserCollection"></see> that contains a page of pageSize<see cref="T:System.Web.Security.MembershipUser"></see> objects beginning at the page specified by pageIndex.
        /// </returns>
        /// <exception cref="T:System.ArgumentException">emailToMatch is longer than 256 characters.- or -pageIndex is less than zero.- or -pageSize is less than one.- or -pageIndex multiplied by pageSize plus pageSize minus one exceeds <see cref="F:System.Int32.MaxValue"></see>.</exception>
        public override MembershipUserCollection FindUsersByEmail(string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            MembershipUserCollection collection = new MembershipUserCollection();
            CustomMembershipUser newUser;
            foreach (MembershipUser oldUser in base.FindUsersByEmail(emailToMatch, pageIndex, pageSize, out totalRecords))
            {
                ProfileBase profile = ProfileBase.Create(oldUser.UserName);
                string firstName = (string)profile.GetPropertyValue("FirstName");
                string lastName = (string)profile.GetPropertyValue("LastName");
                string displayName = (string)profile.GetPropertyValue("DisplayName");

                newUser = new CustomMembershipUser(oldUser.ProviderName,
                                                   oldUser.UserName,
                                                   oldUser.ProviderUserKey,
                                                   oldUser.Email,
                                                   oldUser.PasswordQuestion,
                                                   oldUser.Comment,
                                                   oldUser.IsApproved,
                                                   oldUser.IsLockedOut,
                                                   oldUser.CreationDate,
                                                   oldUser.LastLoginDate,
                                                   oldUser.LastActivityDate,
                                                   oldUser.LastPasswordChangedDate,
                                                   oldUser.LastLockoutDate,
                                                   displayName,
                                                   firstName,
                                                   lastName);
                collection.Add(newUser);
            }
            return collection;
        }
開發者ID:dineshkummarc,項目名稱:BugNet,代碼行數:42,代碼來源:ExtendedSqlMembershipProvider.cs

示例2: Page_PreRender

        private void Page_PreRender()
        {
            MembershipUserCollection 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)
                        {
                            filteredUsers.Add(user);
                            break; // Breaks out of the inner foreach loop to avoid unneeded checking.
                        }
                    }
                }
            }
            else
            {
                filteredUsers = allUsers;
            }
            Users.DataSource = filteredUsers;
            Users.DataBind();
        }
開發者ID:pijix,項目名稱:CallCenter,代碼行數:27,代碼來源:UsersByRole.aspx.cs

示例3: MembershipUser

			FindByUserName_passes_partial_username_to_provider_and_converts_returned_collection_to_PagedListOfMembershipUser()
		{
			//arrange
			var users = new[]
			            	{
			            		new MembershipUser("AspNetSqlMembershipProvider", "TEST1", "", "", "", "", true, false, DateTime.Now,
			            		                   DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now),
			            		new MembershipUser("AspNetSqlMembershipProvider", "TEST2", "", "", "", "", true, false, DateTime.Now,
			            		                   DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now)
			            	};
			var usercollection = new MembershipUserCollection();
			var membership = new FakeMembershipProvider_FindByUserName
			                 	{
			                 		ReturnedUsers = usercollection,
			                 		TotalRecords = 123,
			                 		PageIndex = -1,
			                 		PageSize = -1
			                 	};
			var service = new AspNetMembershipProviderWrapper(membership);
			const int pageNumber = 3;
			const int size = 10;
			var username = new Random().Next().ToString();

			//act
            var result = service.FindByUserName(username, pageNumber, size);

			//assert
            Assert.Equal(pageNumber - 1, membership.PageIndex);
			Assert.Equal(size, membership.PageSize);
			Assert.Equal(usercollection.Count, result.Count());
			foreach (var user in result)
				Assert.Contains(user, users);
		}
開發者ID:dperlyuk,項目名稱:MembershipStarterKit,代碼行數:33,代碼來源:UserServiceFacts.cs

示例4: BindUsers

        private void BindUsers(bool reloadAllUsers)
        {
            if (reloadAllUsers)
            allUsers = Membership.GetAllUsers();

             MembershipUserCollection users = null;

             string searchText = "";
             if (!string.IsNullOrEmpty(gvwUsers.Attributes["SearchText"]))
            searchText = gvwUsers.Attributes["SearchText"];

             bool searchByEmail = false;
             if (!string.IsNullOrEmpty(gvwUsers.Attributes["SearchByEmail"]))
            searchByEmail = bool.Parse(gvwUsers.Attributes["SearchByEmail"]);

             if (searchText.Length > 0)
             {
            if (searchByEmail)
               users = Membership.FindUsersByEmail(searchText);
            else
               users = Membership.FindUsersByName(searchText);
             }
             else
             {
            users = allUsers;
             }

             gvwUsers.DataSource = users;
             gvwUsers.DataBind();
        }
開發者ID:BGCX261,項目名稱:zqerpjohnny-svn-to-git,代碼行數:30,代碼來源:ManageUsers.aspx.cs

示例5: FindUsersByName

        public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            var res = new MembershipUserCollection();
            totalRecords = 0;   //not filled

            try
            {
                var ad = new ADAuthenticationHelper(
                    this.domain, this.contextUsername, this.contextPassword);

                var users = ad.FindUsers(usernameToMatch);
                int counter = 0;
                int startIndex = pageSize * pageIndex;
                int endIndex = startIndex + pageSize - 1;

                foreach (var user in users)
                {
                    if (counter >= startIndex)
                    {
                        MembershipUser u = GetUser(user, true);
                        res.Add(u);
                    }
                    if (endIndex > 0)
                    {
                        if (counter >= endIndex) { break; }
                    }
                    counter++;
                }
            }
            catch (Exception ex)
            {
                throw new ProviderException("FindUsersByName() error in " + providerName, ex);
            }
            return res;
        }
開發者ID:liqueflies,項目名稱:pigeoncms,代碼行數:35,代碼來源:ActiveDirectoryUserProvider.cs

示例6: FindAll_passes_paging_info_to_provider_and_converts_returned_collection_to_PagedListOfMembershipUser

        public void FindAll_passes_paging_info_to_provider_and_converts_returned_collection_to_PagedListOfMembershipUser()
        {
            //arrange
            var users = new[]
                            {
                                new MembershipUser("AspNetSqlMembershipProvider", "TEST1", "", "", "", "", true, false, DateTime.Now,
                                                   DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now),
                                new MembershipUser("AspNetSqlMembershipProvider", "TEST2", "", "", "", "", true, false, DateTime.Now,
                                                   DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now)
                            };
            var usercollection = new MembershipUserCollection();
            var membership = new FakeMembershipProvider_FindAll
                             	{
                             		ReturnedUsers = usercollection,
                             		TotalRecords = 123,
                             		PageIndex = -1,
                             		PageSize = -1
                             	};
            var service = new AspNetMembershipProviderWrapper(membership);
            const int index = 3;
            const int size = 10;

            //act
            var result = service.FindAll(index, size);

            //assert
            Assert.Equal(index, membership.PageIndex);
            Assert.Equal(size, membership.PageSize);
            Assert.Equal(usercollection.Count, result.Count());
            foreach (var user in result)
                Assert.Contains(user, users);
        }
開發者ID:fschwiet,項目名稱:FschwietMembershipStarterKit,代碼行數:32,代碼來源:UserServiceFacts.cs

示例7: Index

        public ActionResult Index(string search)
        {
            MembershipUserCollection users = new MembershipUserCollection();
            if (!string.IsNullOrEmpty(search))
                users = Membership.FindUsersByName("%" + search + "%");

            return View(users);
        }
開發者ID:bjeverett,項目名稱:asp-net-mvc-unleashed,代碼行數:8,代碼來源:LookupController.cs

示例8: UserList

 public UserList(MembershipUserCollection users, int totalRecords)
 {
     this.TotalRecords = totalRecords;
     foreach(MembershipUser u in users)
     {
         this.Users.Add(new User(u));
     }
 }
開發者ID:mrkurt,項目名稱:mubble-old,代碼行數:8,代碼來源:UserManager.cs

示例9: GetMembershipUsers

 public virtual MembershipUserCollection GetMembershipUsers(string providerName)
 {
     MembershipUserCollection muc = new MembershipUserCollection();
     foreach (User u in Children)
     {
         muc.Add(u.GetMembershipUser(providerName));
     }
     return muc;
 }
開發者ID:spmason,項目名稱:n2cms,代碼行數:9,代碼來源:UserList.cs

示例10: GetHybridMembershipUserCollection

		private MembershipUserCollection GetHybridMembershipUserCollection(MembershipUserCollection membershipUserCollection) {
			if(membershipUserCollection == null) {
				return null;
			}
			var hybridMembershipUserCollection = new MembershipUserCollection();
			foreach(System.Web.Security.MembershipUser membershipUser in membershipUserCollection) {
				hybridMembershipUserCollection.Add(GetHybridMembershipUser(membershipUser));
			}
			return hybridMembershipUserCollection;
		}
開發者ID:aelveborn,項目名稱:njupiter,代碼行數:10,代碼來源:HybridMembershipProvider.cs

示例11: CreateCollection

		public virtual MembershipUserCollection CreateCollection(IEnumerable<IEntry> entries) {
			var users = new MembershipUserCollection();
			foreach(var result in entries) {
				var user = Create(result);
				if(user != null) {
					users.Add(user);
				}
			}
			return users;
		}
開發者ID:aelveborn,項目名稱:njupiter,代碼行數:10,代碼來源:LdapMembershipUserFactory.cs

示例12: GetAllUsers

        public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            var col = new MembershipUserCollection();

            foreach (MembershipUser user in base.GetAllUsers(pageIndex, pageSize, out totalRecords)) {
                col.Add(GetUser(user.UserName, false));
            }

            return col;
        }
開發者ID:felipecsl,項目名稱:dover,代碼行數:10,代碼來源:UACMembershipProvider.cs

示例13: ToMembershipUserCollection

        public static MembershipUserCollection ToMembershipUserCollection(this IEnumerable<User> users)
        {
            MembershipUserCollection membershipUsers = new MembershipUserCollection();

            foreach (User user in users)
            {
                membershipUsers.Add(user.ToMembershipUser());
            }

            return membershipUsers;
        }
開發者ID:ThomasSchmidt,項目名稱:MixedStuff,代碼行數:11,代碼來源:MembershipExtensions.cs

示例14: Count

		public void Count ()
		{
			MembershipUserCollection muc = new MembershipUserCollection ();
			Assert.AreEqual (0, muc.Count, "0");
			muc.Add (GetMember ("me"));
			Assert.AreEqual (1, muc.Count, "1");
			muc.Add (GetMember ("me too"));
			Assert.AreEqual (2, muc.Count, "2");
			muc.SetReadOnly ();
			Assert.AreEqual (2, muc.Count, "2b");
		}
開發者ID:Profit0004,項目名稱:mono,代碼行數:11,代碼來源:MembershipUserCollectionTest.cs

示例15: GetAllUsers

        public MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        {
            var collection = new MembershipUserCollection();
            foreach (User user in _userMgr.GetAllUsers())
            {
                collection.Add(new COATMemebershipUser(user));
            }

            totalRecords = collection.Count;
            return collection;
        }
開發者ID:MyRSG,項目名稱:COAT,代碼行數:11,代碼來源:UserRepository.cs


注:本文中的System.Web.Security.MembershipUserCollection類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。