Membership SQLDataProvider

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

What is the best way to store custom information in the database when using
the Membership class? I need to store an access level and I know I can
write to the database manually but I was wondering if there was something
built in for this.

Thanks

Bob
 
Not really,

Microsoft does not suggest modifying their membership tables in any
way. This is the main reason I opted not to use their membership tables
and just went back to building my own membership system.

IMO, their membership classes are not as flexible as I would like them
to be. Perhaps in future versions this will change.
 
What is the best way to store custom information in the database when using
the Membership class? I need to store an access level and I know I can
write to the database manually but I was wondering if there was something
built in for this.

Thanks

Bob

What would be wrong with using profiles?
 
I just noticed profiles. So if I turn on Profiles as soon as the Membership
is authenticated then the profile is automatically used? Or do I have to
call a method to load the profile separately?
 
Bob said:
What is the best way to store custom information in the database when using
the Membership class? I need to store an access level and I know I can
write to the database manually but I was wondering if there was something
built in for this.

What I ended up doing is to create a custom set of membership and role data
tables, then writing custom MembershipUser, MembershipProvider and RoleProvider
classes to use those tables. A large undertaking, but so far it is working
great.
 
I just noticed profiles. So if I turn on Profiles as soon as the Membership
is authenticated then the profile is automatically used? Or do I have to
call a method to load the profile separately?

The profile for the logged in user is available automatically. Getting
the profile for other users is a bit tricky but seems to involve using
ProfileCommon, ie:

Dim PC as ProfileCommon = Profile.GetProfile(theusername)

You can add any field you want to the profiles in the system.web
section in web config:

<profile enabled="true">
<properties>
<add name="AttyName" type="System.String" defaultValue="[null]"/>
<add name="StaffID" type="System.String" defaultValue="[null]"/>
<add name="LastName" type="System.String" defaultValue="[null]"/>
<add name="FirstName" type="System.String"defaultValue="[null]"/>
</properties>
</profile>

These fields are available at designtime and runtime by typing, say,
profile.AttyName = "John Smith". Well, in VB that's how it works, I'm
assuming the same in C#. By default the provider is SQLExpress, and
the fields are stored in a table in an MDF in the asp_data
subdirectory of the website.

Your added fields do not get their own columns; instead they are
merged into two columns. One has the name of the fields and the
location of the data in the second column, and the second column has
all the data. Well, almost all the data. I think that certain complex
types are stored in a third (binary) column but I haven't hit that
yet.

You could, naturally, write your on providers as someone else has
mentioned, but so far SQLExpress has worked ok for me.
 
Back
Top