C# - Migrate Users From Custom Table To Membership Tables?

Mar 9, 2011

I'm creating a new middle tier where all of our client calls will go through a WCF service. We're using ASP.NET membership with the service in order to authenticate users. The middle tier will be hitting an existing database in which we already have an InetUsers table containing usernames and passwords.This is where it starts to get messy. This new middle tier will be used by our web application, but not by our existing desktop application, which will - until we rewrite it at some point in the future - be using the old COM+ middle tier. Administration of the users for the web application takes place in the desktop application. In other words, users will be created and passwords set and changed from within the desktop application, which in turn hits the already existing InetUsers table.Ideally, what will happen is when we deploy the new middle tier, we'll take all of the users from the InetUsers table and create records for them in aspnet_Users and aspnet_Membership. Then we'll set a trigger on the InetUsers table to keep aspnet_Users and aspnet_Membership up-to-date.There's a whole bunch of questions wrapped up in this, so I'll try and list them all out here:Is this the right approach? Obviously having this data in two places isn't ideal, but bear in mind here that I'm not the final decision maker here and we're kinda stuck with some legacy stuff here, at least for now. Still - maybe there's a better way.In the same vein - would we be better off coding our own membership provider rather than using the SqlMembershipProvider? How difficult/easy is it to do so?If we use this approach, I plan on using the aspnet_Membership_XXXX stored procedures for the initial population of the tables as well as in the triggers. Having done some research into this, it appears that if I want to call aspnet_Membership_CreateUser directly from SQL (ie in a trigger...) rather than using the API, I have to store clear text passwords since I can't get the salt and the hash right otherwise. Is this true?Does any of this even make sense or am I going about this the wrong way to begin with?

View 2 Replies


Similar Messages:

Membership Tables Empty After Create Users

Sep 2, 2010

I had to upgrade a sites ecuroty from a custom system to .net membership. I created all the users like this.

ds = Wservices.SelectBulkUsers()
If Not ds Is Nothing AndAlso Not ds.Tables(0) Is Nothing AndAlso ds.Tables(0).Rows.Count > 0 Then
For Each dr In ds.Tables(0).Rows
username = dr("username")
password = dr("password")
role = dr("SecurityClearance")
email = dr("email")
Dim newUser As MembershipUser = Membership.CreateUser(username, password, email, "", "", True, status)
Select Case role
Case "1"
Roles.AddUserToRole(username, "normal user")
Case "2"
Roles.AddUserToRole(username, "administrator")
Case "3"
Roles.AddUserToRole(username, "super administrator")
End Select
If newUser Is Nothing Then
errorMsg = username & " - " & status.ToString & "<br />"
End If
Next
litResult.Text = errorMsg
End If

I thought everything was fine and then went through the labourious task of replacing all the usersids used a as a foreign key in all the tables. It was only after doing this and trying to log on I couldnt, and noticed the membership table was empty. I assumed (stupidly) as it had done the users/ roles it must have done the membership. As I have already re-assigned the old user ids I dont want to import again as the userid will chnage. So my question is: Can I create a membership for each of the users in my aspnet_users table? I have the passwords etc in varchar fields at min from old table.

View 3 Replies

Security :: Insert Previous Users Into Membership Tables

Mar 10, 2011

I'm trying to do a bulk insert of data into the aspnet_Membership table. I have existing records from a previous version of the system I am re-building in asp.net. I've been researching and asking questions, but I am still missing something. What is the best way to do this? I believe I need to grab my previous table and iterate over each record and insert into the new membership table via the Membership.CreateUser method. So far I have been unable to make it work. My code so far in the on click event of a button is below.

using System.Web.Security;
using System.Data;
using System.Data.SqlClient; [code]....

View 7 Replies

C# - 4 Custom Membership Provider Tables

Apr 3, 2011

Now this might just be straightforward, but I can't seem to figure it out..

I have set up the Custom Membership provider, and gave it the proper connection stuff.
What I know is that it connects to the correct database, but I know for sure that it doesn't look at the correct table.

How would I set it up to use a specific table? As the table already has users in them.

The table name is: members_info.

the column names are: member___id(key), member_name, member__pwd, member_perm

member___id => Being the Key and the account name to login with
member_name => Being the users Name or Nickname
member__pwd => 10 chars long (for now)
member_perm => holds 1 of the following values: 0) User 1)Admin 2)Banned


now I know that the later one is to be setup by the Role Provider, and I'm sure once I know how to do the membership one that one is similar in some way.

So my question is, how do I point the Custom Membership Provider to the table: members_info and to use member___id for username, members__pwd for password (and possibly get member_name out to say: Welcome {member_name}! when they login).

===

Added info.
Members__uid is the key value as it increases on each new entry.

===

Since you can't tell it to use a specific table

How can I set it up so, that it works with the tool provided in visual studio? (Website > ASP.net Configuration).

As it now says 0 users, on the security tab. I want to be able to manage the users through here too.

View 1 Replies

Security :: Using Custom Membershipuser To Create Users In The AD With Membership?

Jul 28, 2010

I'm have a doubt using membershipuser to create users in the AD with Membership.CreateUser Method, does any one knows how can i send other attibutes to the AD, such as First Name and Last Name?, besides those ones: username

As String, _

password As String, _

email As String, _

passwordQuestion As String, _

passwordAnswer As String,

View 3 Replies

How To Create Users In A Membership Table Without Using CreateUser

Jun 2, 2010

I want to migrate users and posts from an existing forum I am using to a ASP.NET membership table without using CreateUser. Basically I want to maintain userIDs so that when I migrate posts they continue to associate with the correct users. Is there a way to do this or would I be better off just using CreateUser and then finding a way to re-assign the post-by-UserIDs to the correct new IDs?

View 3 Replies

C# - Retrieve UserId From Membership Users Table?

Jun 6, 2010

i'm new to membership. i have a table named contact, with a field, userId that must get its data from the membership users table. so when a user is created i have to get the userId from membership users table. how can i do that?

View 1 Replies

Security :: Add Foreign Key Field To Membership Users Table

Apr 8, 2010

I have set up Membership and Roles and can create users and login using the ASp Login control. However I need to associate users with customers (in a Customers table in the database) and display content according to the customer that the user belongs to. Is the best way of doing this to create a foreign key field in the aspnet_Users table relating back to Customers table which would have to be updated manually after creating the user or is there a better way?

View 1 Replies

Security :: Delete The Member From The Aspnet_membership Table And Roles Related Tables Using Membership.DeleteUser

Mar 21, 2010

I've created a membership system based on asp.net 2. There are other tables that store user information, such as emails sent etc. I've created a users table based on the TableProfileProvider. My question is concerning deleting the member

Is it OK to delete the member from the aspnet_membership table and roles related tables using Membership.DeleteUser, though keep all the custom tables and the information including the information in the Users table created by the TableProfileProvider? or can you foresee problems?

View 1 Replies

VB - Adding UserId To Custom Table After Membership.CreateUser?

Nov 18, 2010

There are lots of posts about this issue but I can't work out the answers as most of them are for C# or similar. I'm trying to automatically insert the UserId generated by Membership into a custom table. I have membership working correctly, as well as the custom table (I'm able to insert other things from the registration form). But I can't get it to extract the generated UserId and insert it into the custom table. Here's my code:

[Code]....

As you can see I've experimented with the parameters for inserting the record, but that doesn't work (I get an error about ProviderKey not being a part of system.web.security.membershipuser).

View 3 Replies

Security :: Migrate Existing Users / Trying To Use GetPassword()?

Dec 9, 2010

I need to migrate existing users, I will be creating the users account and setting a dummy password for the first time login... My problem is that by doing this they will not have their security question and answer filled in... I am trying to create a page that will force the user to set up their question and answer at first long ... The problem that I am having is when i try to get the password i get the following error..

here is the code that I am using:

[Code]....

[Code]....

View 9 Replies

Migrate Existing Users To Forms Authentication?

Feb 19, 2010

How do I migrate users from a existing users table to Forms Authentication?

There seems to be three options:

T-SQL - Iterate through the existing users table and insert into Forms Authentication tables using the stored procedure aspnet_Membership_CreateUser Code - create a utility that will iterate through the existing users table and insert into Forms Authentication tables using Membership.CreateUser() Code - as users login verify credentials against existing users table and insert into Forms Authentication tables using Membership.CreateUser()

Which is the most practical?

I have been currently trying option 1 but I am running into difficulties using the password salt to create the encrypted password from a plain text password

View 3 Replies

Security :: Custom Membership Provider Error "Could Not Load Type Custom.AspNet.Membership.PostPropertyProvider"

Jan 5, 2011

This is my first membership provider; I converted the sample provider [URL] to SQL. I created a vb class provider and put it into the App_Code folder. After it was created I tried to modify my webconfig but the error pops up. I don't know what else to try, I don't know if I have missed something

webconfig:

[code]....

View 1 Replies

Correctly Migrate Urls From Custom Solution To Wordpress?

May 12, 2010

I have a web site built using asp.net with ugly URLs like /DisplayContent.aspx?id=789564.

I know how to migrate the database, but the Wordpress urls will be (naturally) different.

Can I simply write some mapping or do I have to include a rewrite rule for each subpage (300 pages) in .htaccess?

Should I provide a rewrite rule for each existing page that would transform a full old url to the known new url, like for example:

/DisplayContent.aspx?id=789798 -> /2010-5-10/Title-Of-The-Post

Even if I manage to migrate the URLs, the structure of the HTML for the new content will naturally be different. How does this affect SEO?

Should I run asp.net and wordpress side by side and issue the redirects from the asp.net application?

What is the most efficient solution to this kind of migration of URLs without doing PHP programming?

View 2 Replies

Security :: Can Implement Custom MembershipUser/custom Roles And Membership Provider

Oct 13, 2010

I create custom principal for implement logic for users. In identity I store Id, Name. But it abnormally - this classes must use for authenticate and authorize.

I can implement custom MembershipUser, custom Roles and Membership provider.

How to do it? What best practices are?

View 5 Replies

Security :: Custom Membership Provider With Custom Controls?

Mar 21, 2010

I'm new to ASP.NET and I don't exactly understand some features.

I have a custom membership provider TestMembershipProvider which inherits from MembershipProvider. It has the following CreateUser method:

[Code]....

It's absolutely simple code.Then I have two text boxes (login, password) and the button to register a new user. I thas a following code:

[Code]....

[Code]....

Authentication in web.config is set like this:

[Code]....

No matter what I write into textboxes, following error is being returned:

The password retrieval question provided is invalid.

I don't know why. Either in web.config or in get RequiresQuestionAndAnswer I have false value. When I instantiate my TestMembershipProvider and call CreateUser directly instead of using static Membership.CreateUser, it works fine. Do I have to use instance of my TestMembershipProvider or did I missed anything?

View 1 Replies

C# - Dispose Of Custom Object From Within Custom Membership Provider?

Apr 16, 2010

I have created my custom MembershipProvider. I have used an instance of the class DBConnect within this provider to handle database functions. Please look at the code below:

public class SGIMembershipProvider : MembershipProvider
{
#region "[ Property Variables ]"
private int newPasswordLength = 8;
private string connectionString;
private string applicationName;
private bool enablePasswordReset;
private bool enablePasswordRetrieval;
private bool requiresQuestionAndAnswer;
private bool requiresUniqueEmail;
private int maxInvalidPasswordAttempts;
private int passwordAttemptWindow;
private MembershipPasswordFormat passwordFormat;
private int minRequiredNonAlphanumericCharacters;
private int minRequiredPasswordLength;
private string passwordStrengthRegularExpression;
private MachineKeySection machineKey;
**private DBConnect dbConn;**
#endregion
.......
public override bool ChangePassword(string username, string oldPassword, string newPassword)
{
if (!ValidateUser(username, oldPassword))
return false;
ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, newPassword, true);
OnValidatingPassword(args);
if (args.Cancel)
{
if (args.FailureInformation != null)
{
throw args.FailureInformation;
}
else
{
throw new Exception("Change password canceled due to new password validation failure.");
}
}
SqlParameter[] p = new SqlParameter[3];
p[0] = new SqlParameter("@applicationName", applicationName);
p[1] = new SqlParameter("@username", username);
p[2] = new SqlParameter("@password", EncodePassword(newPassword));
bool retval = **dbConn.ExecuteSP("User_ChangePassword", p);**
return retval;
} //ChangePassword
public override void Initialize(string name, NameValueCollection config)
{
if (config == null)
{
throw new ArgumentNullException("config");
}
......
ConnectionStringSettings ConnectionStringSettings = ConfigurationManager.ConnectionStrings[config["connectionStringName"]];
if ((ConnectionStringSettings == null) || (ConnectionStringSettings.ConnectionString.Trim() == String.Empty))
{
throw new ProviderException("Connection string cannot be blank.");
}
connectionString = ConnectionStringSettings.ConnectionString;
**dbConn = new DBConnect(connectionString);
dbConn.ConnectToDB();**
......
} //Initialize
......
} // SGIMembershipProvider

I have instantiated dbConn object within Initialize() event. My problem is that how could i dispose off this object when object of SGIMembershipProvider is disposed off. I know the GC will do this all for me, but I need to explicitly dispose off that object. Even I tried to override Finalize() but there is no such overridable method. I have also tried to create destructor for SGIMembershipProvider.

View 2 Replies

Custom Server Controls :: Get IP With Custom Membership Provider?

Feb 7, 2011

I was made a custom membership provider.

All works good. My problem is Logs.

[Code]....

[Code]....

I dont know how to get user's ip.

I tried these methods...

Dim req as httprequest
ip = req.servervariables("remote_host") 'result = nothing
Dim req as new httprequest
ip = req.servervariables("remote_host") 'result = nothing
Dim req as requestcontext
ip = req.request.servervariables("remote_host") 'result = nothing...

View 2 Replies

How To Add Membership Tables To Existing Database

Oct 5, 2010

I was reading through this post here http://www.misfitgeek.com/op-ed/adding-asp-net-membership-to-your-own-database and thought to my self what the common practice is. What do developers using ASP.NET membership and authorization in their applications recommend as a best practice? creating the membership tables in the same database that stores their applications data or configuring a second database to store ONLY the membership information?.

My current setup is a different database for membership information ONLY but am thinking that increases the number of databases i have to maintain. If I have 5 applications using asp.net membership, then that means 5 more asp.net membership databases. So do you normally create the asp.net membership tables in your main database or you configure a separate membership table? what do you recommend.

View 1 Replies

SQL Server :: ASPNET Membership Tables?

Oct 22, 2010

How can I sync up the aspnet membership tables among 2 different databases?

View 1 Replies

Security :: Membership Connection With The Tables?

Apr 10, 2010

i have Login membership, also have table with database address, with columns: UserId, Address, City, etc... How given the user login,show data after the user login with another database table address (UserId) .

View 19 Replies

Security :: Merging Membership Tables With Database?

Mar 7, 2010

I am using aspnet_regsql.exe to add membership tables to my database.

when I click the exe file it just opens up an XML file in visual web developer and does not start the wizard to merge the databases.

the run command where file is located is below

C:WINDOWSMicrosoft.NETFrameworkv2.0.50727

I just get the file below opening instead

[Code]...

View 1 Replies

Security :: Getting Membership And Roles Tables Created In A Different Db?

Jul 29, 2010

Lets say that I have a database set up with a load of info in it and I decide I want to add the membership and roles functionality to my site but my hosting provider makes me pay for each database I use. I don't want to pay for another db, so how do I set it up so that instread of creating membership and roles tables in the the aspnetdb database, it creates them in my existing database?

View 5 Replies

Sql Server - How To Customize The Membership Database Tables

Jun 21, 2010

I want to add custom columns to some tables created by ASP.NET. For example; I need to add two fields such as FirstName and LastName to the aspnet_Membership table.

I can add this directly by editing the table but;

Is this the right thing to do (I mean; extending the table directly) OR should I create a separate table and hold the extra user data, there?How can I see these custom database fields as properties in code completion? example: membershipuser.FirstName;

View 4 Replies

Security :: Change Membership Tables And Its Column Name?

Mar 26, 2010

I want to rename aspnet_application table and its columns. 1- Does membership framework allow me to do that ?2- Will there be any problem in accessing System.Web.Security functions ?3- I have to change procedures and functions etc ?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved