当前位置: 首页>>代码示例>>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;未经允许,请勿转载。