3

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.

p.campbell
  • 98,673
  • 67
  • 256
  • 322
Onur Yıldırım
  • 32,327
  • 12
  • 84
  • 98

4 Answers4

3

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.

Community
  • 1
  • 1
Sky Sanders
  • 36,396
  • 8
  • 69
  • 90
1

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
  • 7,511
  • 1
  • 34
  • 59
  • 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 Jul 18 '10 at 02:16
0

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 Fox
  • 10,603
  • 9
  • 50
  • 80
  • 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 Jul 18 '10 at 02:09
-1

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.

S P
  • 4,615
  • 2
  • 18
  • 31
  • 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 Jul 18 '10 at 02:10