I feel it makes sense NOT to use custom membership & role providers

A

alexandis

We have tables of logins (users), that differs much from standard
microsoft structure - we don't use control question/answer, date
fields, etc. But instead we have several additional fields.

I expanded membership class and it works for logging in, but going
further - creating user - I must make following in CreateUserWizard
template:

1) create 'users' record filling standard microsoft fields and ignore
those I don't use (mentioned above), i.e. put nulls, "", mindate,
etc...
2) update this record, initializing it with MY fields

So, one db operation operation is splitted. It looks ugly...

Concerning role provider: they offer user2role with userName and
roleName fields! But in this case I don't have relationship between
tables, because userName is not a primary key in users table (ID is,
but ID is integer).

I've decided to make custom login control and NOT to use custom
membership provider and role provider.

I ~hope~ it's correct decision. But I'd like to hear objections, until
it's too late :) and good article about further process... maybe there
is one from the person who took the same decision. Is there much work
to go without standard login control and provider? Would it be good to
have classes similar to the one I've already made as custom providers?
Maybe I could just change them and adopt for use as NOT provider-
classes?
 
A

alexandis

Writing custom provider from scratch is not a trivia, so I'd like to
show my thoughts, maybe I'm wrong somewhere?

Let's say, we have 'users' table, that contains obligatory fields not
represented in 'microsoft users table'.

Splitting such info into 2 tables (1:1) won't go, because it's
impossible (as far as i can see) to implement transaction for filling
these 2 tables ('CreateUser' method call is hidden) and all in all -
such structure looks clumsy...

Maybe theoretically it's possible to create additional corresponding
fields in custom membership provider class and initialize them in
'CreatingUser' method, then take them for inserting new record in
'CreateUser'? But such approach also looks ugly... :(

Creating own membership provider from scratch is a headache,
especially for beginners (you have to deal with multithreading,
preventing access to membership while initialize method works).

I wonder why Microsoft just hadn't created one more abstraction layer
for the structure of 'users' table? So instead of having
'CreateUser(param1, param2, ... paramN)' we could have something like
'CreateUser(UserStruct user)'....
 
D

darrel

I wonder why Microsoft just hadn't created one more abstraction layer
for the structure of 'users' table?

Like many of their products, they simply don't have to. They make things
'good enough to sell' but not necessarily 'good enough to use in a pragmatic
fashion'.

I think the membership provider thing is a great idea. I still don't get it.
Mainly because there's some fundamental concepts that I just haven't found a
comprehensive description of yet.

For now, I've reverted back to my own login system (which, admittedly, for
most of my sites, is all I really need) but hope to fight the Membership
Provider again some long weekend when I have nothing else to do.

-Darrel
 
A

alexandis

:)

I decided to stick to provider, the only problem was 'providerUserKey'
- i still can't see elegant way to assign value to it

I wonder - why Microsoft put it as INPUT parameter into CreateUser
method with NO WAY to initialize it manually

So i see 2 ways:
1) easier, but not elegant at all - create session variable and use it
to keep extrafield info: initialize it in CreatingUser and read it
inside CreateUser - so providerUserKey parameter is just left
behind...
2) to make extra property for keeping these extra fields in extended
membershipprovider class. Since this class is a singletone, it should
keep a LIST of objects, where every list item corresponds to specific
userid (login id). So, we assign extrafield info to such object in
CreatingUser and read it inside CreateUser: the same idea as in method
1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top