Saturday, October 14, 2006

User Management in Admin Role



Some friends have asked me that how I activate user’s account on my web site. I would like to show you my admin area, which will provide you an idea as how it works.



Site Management






Account Management

Here, I can search an account or list all accounts. For each user account I have created two options – Edit or Delete. In order to approve an account, I have to edit a user, to assign a role and then approve.





Edit User Account

Here, I can create a new role other than Administrator and Friends, but do not require right now.


Alternative Option

If you do not wish to build your User Interface and would like to add new users in a role and approve it automatically then you can add following few lines of code to automatically assign a role and approve an account. This code will go in Register.Aspx.vb file.

Imports System.Web.Security

Protected Sub cuwCreateUserWizard_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs) Handles cuwCreateUserWizard.CreatedUser

Dim objUser As MembershipUser
Roles.AddUserToRole(cuwCreateUserWizard.UserName, "Friends")
objUser = Membership.GetUser(cuwCreateUserWizard.UserName)
objUser.IsApproved = True
Membership.UpdateUser(objUser)

End Sub

0 comments: