Question

I have no doubt on how to retrieve membership id from 1 single user:

currentUser = Membership.GetUser(); 
Guid currentUserId = (Guid)currentUser.ProviderUserKey;

but I can´t find a way to retrieve all users id and usernames.

I tried this way:

MembershipUserCollection AllUsers;
AllUsers = GetAllUsers();

From that point I can´t find a way to retrieve Ids and Usernames from AllUsers. Could I get some help from here?

Was it helpful?

Solution

I think you're looking for Membership.GetAllUsers()

var users = Membership.GetAllUsers();
foreach (MembershipUser membershipUser in users)
{
    // membershipUser.UserName;
}

http://msdn.microsoft.com/en-us/library/system.web.security.membershipprovider.getallusers.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top