I have tried that method to create a user, but I could not figure out the parameters that works.
If (Membership.FindUsersByName("auser").Count = 0) Then
Membership.CreateUser("userName", "userPW", "userEmail", "passwordQuestion", "passwordAnswer ", true, ???)
End If
I don't know what to use for the MembershipCreateStatus as indicated as ???.
wallywli
0 Points
3 Posts
Create users and rols in the global.asax file
Mar 17, 2009 04:03 AM|LINK
Can some tell me how to create roles and users in the Global.asax file?
mohd786hussa...
Contributor
4329 Points
878 Posts
Re: Create users and rols in the global.asax file
Mar 17, 2009 05:09 AM|LINK
Hi,
You can create user in global.asax using the :
Membership.CreateUser();
method.
For creating roles you have to call to stored procedure that creates roles from sqlserver.
Mark as answered if it helps.
Mohammad Hussain
Web design, Logo design & Asp.net development
chetan.sarod...
All-Star
65619 Points
11118 Posts
Re: Create users and rols in the global.asax file
Mar 18, 2009 03:24 AM|LINK
Creating roles in the Application_Start event in the Global.asax file
void Application_Start(Object sender, EventArgs e) { // Code that runs on application startup if (Roles.Enabled) { if (!Roles.RoleExists("ProjectAdministrator")) { Roles.CreateRole("ProjectAdministrator"); } if (!Roles.RoleExists("ProjectManager")) { Roles.CreateRole("ProjectManager"); } if (!Roles.RoleExists("Consultant")) { Roles.CreateRole("Consultant"); } } }http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
wallywli
0 Points
3 Posts
Re: Create users and rols in the global.asax file
Mar 18, 2009 06:53 PM|LINK
Thanks for your replay.
I have tried that method to create a user, but I could not figure out the parameters that works.
If (Membership.FindUsersByName("auser").Count = 0) Then
I don't know what to use for the MembershipCreateStatus as indicated as ???.Membership.CreateUser("userName", "userPW", "userEmail", "passwordQuestion", "passwordAnswer ", true, ???)
End If
Any help is appreciated.
Thanks.
chetan.sarod...
All-Star
65619 Points
11118 Posts
Re: Create users and rols in the global.asax file
Mar 19, 2009 03:23 AM|LINK
Describes the result of a CreateUser operation.
http://msdn.microsoft.com/en-us/library/system.web.security.membershipcreatestatus.aspx
</div></div></div></div>See here
http://msdn.microsoft.com/en-us/library/82xx2e62.aspx
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
wallywli
0 Points
3 Posts
Re: Create users and rols in the global.asax file
Mar 19, 2009 02:43 PM|LINK
Thanks for the reply!
I have figured it out.
chetan.sarod...
All-Star
65619 Points
11118 Posts
Re: Create users and rols in the global.asax file
Mar 20, 2009 03:21 AM|LINK
If you solved it then please mark the reply as Answer so that it will help for other people
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.