本文整理汇总了C#中System.Web.Security.MembershipUserCollection类的典型用法代码示例。如果您正苦于以下问题:C# MembershipUserCollection类的具体用法?C# MembershipUserCollection怎么用?C# MembershipUserCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MembershipUserCollection类属于System.Web.Security命名空间,在下文中一共展示了MembershipUserCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: Show
public ActionResult Show()
{
MembershipUserCollection friendsList = new MembershipUserCollection();
var friends = friendshipRepo.ListAllFriendships((Guid)currentUser.ProviderUserKey);
foreach (var f in friends)
{
MembershipUser theFriend = Membership.GetUser(f.FriendId);
friendsList.Add(theFriend);
}
return View(friendsList);
}
开发者ID:feedme,项目名称:FeedMe,代码行数:12,代码来源:FriendsController.cs
示例17: GetOnlineUsers
/// <summary>
/// Return a MembershipUserCollection of currently online users
/// </summary>
/// <returns></returns>
public static MembershipUserCollection GetOnlineUsers()
{
MembershipUserCollection members = System.Web.Security.Membership.GetAllUsers();
MembershipUserCollection onlineMembers = new MembershipUserCollection();
foreach (MembershipUser user in members)
{
if (user.IsOnline)
onlineMembers.Add(user);
}
return onlineMembers;
}
开发者ID:runin2k1,项目名称:DrivingBarefoot,代码行数:17,代码来源:OnlineMembersWrapper.cs
示例18: OnlineUsers
/// <summary>
/// 在线用户
/// </summary>
/// <returns></returns>
public ActionResult OnlineUsers()
{
var allUsers = Membership.GetAllUsers();
var users=new MembershipUserCollection();
foreach (MembershipUser user in allUsers)
{
if (user.IsOnline)
{
users.Add(user);
}
}
return View(users);
}
开发者ID:dalinhuang,项目名称:college_vod,代码行数:17,代码来源:UserMgrController.cs
示例19: btn_register
protected void btn_register(object sender, EventArgs e)
{
try
{
//string() lbUserName = new string();
string userName;
string passWord;
string email;
DataSet ds = new DataSet();
MembershipUserCollection ExistingUser = new MembershipUserCollection();
MembershipUserCollection ExistingUser11 = new MembershipUserCollection();
MembershipUserCollection getallusers = new MembershipUserCollection();
userName = tbUserName.Text.ToString().Trim();
passWord = tbPassword.Text.ToString().Trim();
email = tbEmail.Text.ToString().Trim();
lbErrorMessage.Visible = false;
ExistingUser = Membership.FindUsersByEmail(email);
if (ExistingUser.Count != 0)
{
lbErrorMessage.Text = "Email already exists";
lbErrorMessage.Visible = true;
return;
}
ExistingUser11 = Membership.FindUsersByName(userName);
if (ExistingUser11.Count != 0)
{
lbErrorMessage.Text = "User name already exists";
lbErrorMessage.Visible = true;
return;
}
Membership.CreateUser(userName, passWord, email);
Roles.AddUserToRole(userName, "User");
Response.Redirect("Welcome.aspx");
//todo should redirect at this point to a result page and tell them to click here to log in
}
catch(Exception ex)
{
lbErrorMessage.Text = "Xin lỗi chúng tôi không thể đăng kí bạn vào lúc này. Xin liên hệ admin tại [email protected] ";
lbErrorMessage.Visible = true;
return;
}
}
开发者ID:honda010181,项目名称:TuDien,代码行数:49,代码来源:Register.aspx.cs
示例20: Page_PreRender
private void Page_PreRender()
{
MembershipUserCollection allUsers = Membership.GetAllUsers();
MembershipUserCollection filteredUsers = new MembershipUserCollection();
bool isLockedOut = true;
foreach (MembershipUser user in allUsers)
{
if (user.IsLockedOut == isLockedOut)
{
filteredUsers.Add(user);
}
}
Users.DataSource = filteredUsers;
Users.DataBind();
}
开发者ID:pijix,项目名称:CallCenter,代码行数:15,代码来源:LockedUsers.aspx.cs
注:本文中的System.Web.Security.MembershipUserCollection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论