views:

55

answers:

4

Hello,

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;

  1. 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?

  2. How can I see these custom database fields as properties in code completion? example: membershipuser.FirstName;

thanks.

A: 

make a custom membership provider! this will give you the basic idea. just extend the existing asp.net membershipprovider

http://www.davidhayden.com/blog/dave/archive/2007/10/11/CreateCustomMembershipProviderASPNETWebsiteSecurity.aspx

you could also go with the membership provider starter kit if your app is MVC'ish at codeplex

http://mvcmembership.codeplex.com/

David
adding unnecessary complexity and the headaches that go along with it is simply bad advice when there is already a solution in the box.
Sky Sanders
A: 

I recommend you to create a custom membership provider if your application requires features that go beyond the basics provided by the ASP.NET Membership Provider.

Sander Pham
adding unnecessary complexity and the headaches that go along with it is simply bad advice when there is already a solution in the box.
Sky Sanders
A: 

There is a nice library that provides you with custom membership and profile stuff.

http://altairiswebsecurity.codeplex.com/wikipage?title=Simple%20SQL%20Providers&referringTitle=Home

František Žiačik
While I would not recommend to go as far as to completely replace the aspnet providers for something as simple as associating a couple name meta fields to a user, this library may be suitable. It is hard to tell, there are no tests in the source which would make me pretty gunshy in using it to secure anything. but your mileage may vary.
Sky Sanders
Thanks. I couldn't vote up bec. of insufficient reputation points.
radgar
+1  A: 

You would typically use profiles to store user related meta data. This requires only simple configuration and no custom provider implementation.

You should only ever consider custom implementation of the battle tested security related providers when you absolutely must.

here is a link to a fine example of implementing profiles in asp.net.

Sky Sanders
Thanks. This seems to be the way to go. I couldn't vote up bec. of insufficient reputation points.
radgar
@rad - no problem. glad i could help. bump it later if you like.
Sky Sanders