• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 376
  • Last Modified:

Membership - CreateUser - enforce Role selection

I am developing application in ASP.NET 2.0.
I am using the "membership" profile for user maintenance.
On the Create user screen I am using the "CreateUserWizard".
How can I enforce (add Role selection dropdown) while creating a new user.
0
vu3lmg
Asked:
vu3lmg
1 Solution
 
sm394Commented:
You can create user something like that
try
        {
               
            MembershipCreateStatus Status;
            Membership.CreateUser("UserName1",
            "1234567890-",
            "UserEmail1@yahoo.com",
            "hello",
            "hello", true,
            out Status);
            StatusLabel.Text = "User created successfully!";
        }
        catch (Exception ex)
        {
            Debug.WriteLine("Exception: " + ex.Message);
            StatusLabel.Text = "Unable to create user!";
        }

then you can get existing roles
        lbxAvailableRoles.DataSource = Roles.GetAllRoles();
        lbxAvailableRoles.DataBind();

finaly you can add user to Role

Roles.AddUserToRole(User.Identity.Name, "Power User");
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now