views:

987

answers:

4

I am currently converting a very old, but working classic ASP site to ASP.Net.

It has a completely custom written user management system. Whilst it works fine, it really needs a refresh as I want it to be more flexible for some future projects in the works.

When I asked someone about this, they said "You need to use the Microsoft Provider" and gave a lecture on how Microsoft release all these things for free and how good they are and should be re used as much as possible.

I have done quite a bit of research on it (mainly looking at the videos on http://asp.net/learn ) and am very impressed by some of the features as there appears to be drag and drop components for items that would take me ages to write.

However, the current membership database is complicated to explain, it is a completely custom written database that has many internal relations... It is not really "compatible" with the default Microsoft Provider.

I have taken a look at How Do I: Create a Custom Membership Provider?, but I feel a little out of my comfort zone and worried it will either be slow, introduce a security hole or simply won't work.

At the end of the day, the Microsoft Membership Provider should work for me - the only customisations I really need is the login to use the username/password field in my database and the create user script which has a lot of custom code to several third party systems (needing to provision services etc.).

I was just wondering, what would you do if faced with a similar situation?

  1. Use the Microsoft Membership Provider and somehow get it to work for you (although I would like suggestions)

  2. Use the Microsoft Membership Provider but use custom provider that is customised around your code.

  3. Use your own completely customised solution?

+2  A: 

If the existing provider works (has the right fields for your data), use that to start. You can VERY easily replace that with a customer provider later (just a single config value change).

Beware there isn't an "out of the box" ASP.NET management interface for that, you'll need to roll your own or use a third party one.

Mark Cooper
+4  A: 

I've been in similar situations in the past. In both cases we created custom implementations of the providers (MembershipProvider, RoleProvider, ProfileProvider) around the existing mechanism.

In both cases we only used the provider implementations for read-only access, e.g. to give us the easy validation gubbins in web.config and suchlike. The user administration code was left well alone as it worked just fine.

Jeremy McGee
+1 for keeping the provider implementations read-only. I have also done this on projects to gain the use of the built in functionality around forms authentication while leaving the rest of the administration code in a separate class library.
Element
+4  A: 

That video does complicate things :) If you're going to implement a custom provider then reflector over the existing one is a good place to start :)

As a quick and dirty option you could, of course, hack the stored procedures that the SQL Membership provider uses but the custom code to provision services is probably stretching that.

If you think about it the remote provisioning of services doesn't really belong in a membership provider, it's not really a membership function - all membership does is provide usernames and passwords and authentication around them. My own feeling is that you should move the provisioning of services out of there, and perform it on the ASP.NET site after a user has been created - even if that's just calling a stored procedure once the membership provider has done its thing. If you do this you may find that the SQL membership provider will do everything you need it to (probably with the Roles & profile providers too), and thus you have way less code to write!

blowdart
I agree with separating them... At the time it was written, it was just a single application and wasn't built modular, or even thought that it would be used in other systems. This is one of the things I want to do in the refresh. I would be worried about editing MS's stored procs incase an update later would screw me over. At this point, I think I may do everything custom (at the end of the day, the system has worked fine for the past ~7 years), and look at implementing the MS stuff later...
Wil
but, yeah, the roles and profiles is what amazed me, took me weeks to write a few things, and they have drag and drop components that work out the box!
Wil
I've not seen the video, but the "How to: Implement a custom membership provider" (http://msdn.microsoft.com/en-us/library/ms366730.aspx) on MSDN gives a very good introduction to a simple membership provider, including recommendations on the DB implementation that could be adapted quite easily.
Zhaph - Ben Duguid
+1@ Zhaph - Ben Duguid, like that site, and also many thanks to Blowdart for all the extra help you have given (+1 and answer!).
Wil
+1  A: 

Use my specialized MembershipProvider to work against my own database tables.

this. __curious_geek