How to get a user list / profile from a membership provider?

I use this membership provider. I am stuck in getting a list of users + Profile (FirstName, LastName, Title, etc. Etc.)

I know that there is a method for Membership.GetAllUsers (), but I do not know how to combine it with FirstName, LastName, which I saved in the Profile Provider.

thanks

+4
source share
2 answers

Membership.GetAllUsers () returns a membership in a membership, which you can use to access an individual member. Example:

MembershipUserCollection users = Membership.GetAllUsers(); string email = users["some_username"].Email; 

You can also get ProfileInfo in the same way:

 ProfileInfoCollection profiles = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All); DateTime lastActivity = profiles["some_username"].LastActivityDate; 

However, by default there are no FirstName and LastName properties unless you manually specified them in your profile provider.

Check out the MembershipUser class and ProfileInfo class. More details. You can also check the SqlProfileProvider class as an example of a profile provider if you have not already implemented it.

+4
source

First, when you create a user, create a profile with the same username using:

 // Create an empty Profile for the new User ProfileCommon p = (ProfileCommon) ProfileCommon.Create("username", true); 

Then, to get it next time ..

 // Retrieve a particular profile ProfileCommon userProfile = Profile.GetProfile("username"); 

Thanks.

+2
source

All Articles