Roles/Membership Question

Mondeo

Centurion
Joined
Nov 10, 2006
Messages
128
Location
Sunny Lancashire
I want to use membership on my website and i've setup a role called members. I've set the database up on an SQL 2000 server using the tool.

I have a windows application with 2000 member accounts on, these are also stored on SQL 2000.

I want to go through this database and automatically add the members so they have matching accounts on the website in the members role. How do I do it, what I mean is what entries do I need to make in the membership database(s).

Thanks
 
If you already have an exisiting database containing all the accounts it might be easier to just use it as it is rather than converting it to the format expected by ASP.Net 2.0 - you would need to create your own providers though.

Specifically you would need to create a membership provider and a role provider; http://msdn2.microsoft.com/en-us/asp.net/aa336558.aspx is the offical MS toolkit for this (including the source code to the built in providers). http://www.codeplex.com/Wiki/View.aspx?ProjectName=AltairisWebProviders may be worth a look as it contains a simple example of what you are after plus associated documentation.
 
Thanks, there will be no interaction between the two sets of data though, once I have imported them then thats it. It will be better for me to use the built in providers, and a lot quicker.

I have read that theres a stored procedure for creating users, how do you use it?
 
Mondeo said:
I have read that theres a stored procedure for creating users, how do you use it?
Well, if you are using the SqlMembershipProvider, you simply call the CreateUser method (http://msdn2.microsoft.com/en-us/library/system.web.security.sqlmembershipprovider.createuser.aspx).

I have never used the stored procedure in the database directly. You would probably use it like any other stored procedure:

Visual Basic:
Dim con As New SqlConnection("your connection string")
Dim com As New SqlCommand("EXEC <name of the stored procedure>", con)
com.Parameters.AddWithValue("<parameter1 name>", parameter1_value)
                                   :
                                   :
con.Open()
com.ExecuteNonQuery()
con.Close()

or something like that. That's just off the top of my head with no help from Intellisense, or anything like that, but it should give you the idea.

Todd
 
Back
Top