Page 1 of 1

Remote Database question - Adding new users & their ROLEs / Memberships

Posted: Fri 16 Mar 2007 15:56
by Cody21
Bear with me - newbie to all of this, but learning fast.

For Roles/Membership assignments, I seemingly have to use the VS Web Site Admin tool to populate my aspnet_roles and aspnet_membersinroles. After populating my MySql DB and creating those roles, I extracted the contents and then ran the SQL commands on my production site (via their SQL interface). Works fine.

Now the issue: I have a couple of new users that I need to add and I'm not sure the best way to do this. The ROLES created by the initial steps generated "hashed" ROLES (along with userid, etc.) So I *could* go to my ISP server and manually Add my users, but the ROLES field is hashed/terse. If I do that, should I just Copy & Paste one of the other hashed one's?

This all seems a bit convuluted and I think there MUST be an easier way. So what is the PROPER way to do this? Like I said, the ROLES appears to be hashed or something and I don't have a VS WSAT on the ISP server -- only a SQL interface to the MySql DB I created.

Thanks so much. (I have a follow-up question I'll post in a separate thread).

Posted: Fri 16 Mar 2007 16:18
by Alexey
If I got you right, you should utilize the following functions:

Code: Select all

Membership.CreateUser("username", "password", ...) - to create a user

Code: Select all

Roles.CreateRole("rolename") - to create a role

Code: Select all

Roles.AddUserToRole("username", "rolename") - to add a user to a role
Is this what you need?

Posted: Fri 16 Mar 2007 16:24
by Cody21
Yea, I think that's what I need ... So, as a newbiew to this, how do I "execute" those commands? Are they just SQL commands that I would run in a SQL window on the remote server? Or do I create an ASP.NET "form" that I fillout and execute those commands.. You can point me to the right spot in your documentation if that helps. I''ve been searching everything but still haven't figured this out.

Sorry for being so stupid with this, but as I said, this is very new to me and I'm REALLY REALLY trying to learn this.

Thanks again Alexey

Posted: Fri 16 Mar 2007 16:37
by Alexey
Yes, you should create an ASP.NET application and execute those commands.

Posted: Fri 16 Mar 2007 16:42
by Cody21
Thank you ... I will try to learn how to do that... (execute a command from a Page in my site.)

Posted: Fri 16 Mar 2007 16:57
by Alexey
Just add those funstions with appropriate parameters to a freshly created *aspx.cs file and press F5 in VS IDE.

Posted: Fri 16 Mar 2007 17:39
by Cody21
OK,,,, trying... (hopefully you can see that?) see code below of my newly-created .cs file. VS is complaing about an invalid TOKEN "(" Do I need a "USING" statement that somehow points to MySqlDirect stuff???

I've searched your HELP documentation for the proper coding parameters of the Membership.CreateUser and Roles.AddUserToRole and cannot for the life of me find any reference to these commands. (I will likely be very interested to see all of the commands available to me in the future.) If you can point me to that information I will gladly try to solve this myself.

sorry,,,, and thanks again.


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace WebApplication6
{
public class Class1
{
Membership.CreateUser("junk", "something")
Roles.AddUserToRole("junk", "member")
}
}

Posted: Fri 16 Mar 2007 17:48
by Alexey
Those functions are described in MSDN. You need semicolons after each code line.