Home » forms authentication » Forms Authentication – Managing Users

Forms Authentication – Managing Users


While there are a lot of controls available in ASP.NET that allow you to manage forms authentication, one control that doesn’t exist is something that will allow you to manage your user list.

Most of the time you don’t need this, but when you do, there is an obvious hole.

Since we need to write this code ourselves, how do access the user list from our code?

The Membership API built into ASP.NET gives you access to the user information and a lot more.

To access the list of users, you’ll need to call Membership.GetAllUsers();

Since I like working with datasets because of their flexibility, I create a DataTable that has the information I want to store and loop through the collection that Membership.GetAllUsers() returns and fill the DataTable.

DataSetContentEditors.LoginsDataTable logins =
    new DataSetContentEditors.LoginsDataTable();
MembershipUserCollection muc = Membership.GetAllUsers();
foreach (MembershipUser mu in muc)

To change the password for the user, you can call the MembershipUser’s ResetPassword to generate a new password and then call the ChangePassword() method to set it to what you want it to be.

MembershipUser u = Membership.GetUser(userName);
string resetPassword = u.ResetPassword();
u.ChangePassword(resetPassword, newPassword);

Like this Article? Subscribe to get every article sent to your email.

Related Post

  • Forms Authentication – Creating UsersForms Authentication – Creating Users Last week we installed the tables into our database and set up the database connection so that we could implement forms based authentication. This week, we need to put into place a way […]
  • DotNetNuke Modules – Creating Base ModulesDotNetNuke Modules – Creating Base Modules Now that we have DotNetNuke installed into Visual Studio we can go ahead and create our first modules. Actually, creating the modules is pretty simple. But it is even easier to do it […]
  • WordPress w/ Forms Authentication on IIS6WordPress w/ Forms Authentication on IIS6 I know I said yesterday that I'd start a series about creating DotNetNuke modules, but I solved a problem yesterday after I wrote that post that I think a lot of you will be interested […]
  • The Google Appliance and Forms AuthenticationThe Google Appliance and Forms Authentication I’ve been working with a client to implement the Google Appliance on one of their sites that has forms authentication enabled.For those of you who aren’t aware, Google provides a […]
  • Determine The Role of a User in ASP.NETDetermine The Role of a User in ASP.NET There are several controls that allow you to display content based on the role a user is in, including: - LoginView - LoginStatus And the web.config file allows us to control which […]

About Dave Bush

Dave Bush is a Full Stack ASP.NET developer. His commitment to quality through test driven development, vast knowledge of C#, HTML, CSS and JavaScript as well as his ability to mentor younger programmers and his passion for Agile/Scrum as defined by the Agile Manifesto and the Scrum Alliance will certainly be an asset to your organization.