Tuesday, May 3, 2011

ASP.NET: Total control of the ASP.NET membership provider

I have an application which uses the built in ASP.NET membership provider. There are two roles (admin and staff). I want admins to be able to see a list of current staff, add or delete staff and reset passwords. So far I've found very little information, but Membership.Provider.GetAllUsers looks promising. Is there any way I could show the list in a GridView?

At minimum, I need to be able to add and delete users through the site.

From stackoverflow
  • If you're using SQL Server, you can use the default SqlMembershipProvider class in System.Web.Security to perform the user management tasks you require. GetAllUsers() returns a string array, so you can databind your GridView to the result from this method to display a list of user names in your grid.

  • For an extensive guide on using the Membership and Roleprovider in ASP.NET, see this tutorial: http://aspnet.4guysfromrolla.com/articles/120705-1.aspx

    Creating users programmatically is explained here: http://msdn.microsoft.com/en-us/library/d8t4h2es.aspx.

    But really, MSDN is very complete on this subject. Just read the Introduction into Membership and follow the links. Everything you want is perfectly possible.

    jao : Read http://msdn.microsoft.com/en-us/library/system.web.security.membership.updateuser.aspx for more info on updating user account data
  • I found an excellent tutorial at http://aspnet.4guysfromrolla.com/articles/052307-1.aspx which made the whole thing slightly less murky. A nightmare to implement but it's almost working. Thanks for the replies.

0 comments:

Post a Comment