Memberships, Profiles, & Roles..... Oh my...

Last post 01-30-2009 5:51 PM by guru_sarkar. 3 replies.

Sort Posts:

  • Memberships, Profiles, & Roles..... Oh my...

    01-29-2009, 9:31 PM
    • Member
      point Member
    • mosheah
    • Member since 03-11-2008, 7:37 AM
    • Posts 4

    Ok here is what I want to do but I just can't seem to figure out the best way to architect it.

    I want to use the Membership, Profiles, & Roles features that are shipped with ASP.NET.  I basically want to have 2 types of users. Each of them will have specific roles and they will share some properties but there will be properties that are specific to each type of user. So the 2 users would be Business Users(Could be a Business owner,employee,etc.) and Customer Users.  I see there being several types of Roles, some for Business Users and some for Customers.  For Example I could see a Business User having a Role as an Administrator and maybe one for a Business User as an Employee.  I think I have that part figured out it is when I get to the Profiles that I get confused.  I figure the default membership will work for both Business users and Customer users.  Then I figured I would have several Roles, maybe Customer, BusAdmin, BusEmployee, etc..  But, with the profiles I want the Business & Customers to have similar properties such at address, city, state, zip, phone, etc.   But I also want each type of user to have specific properties, for example a business may have a websiteURL, or a StoreLocation but the Customer would not have those properties.  So this is where I am stuck.  I thought about creating a custom ProfileProviders for each user type but, I am not even sure if I could do that.  I messed with it some but couldn't really get 2 profiles to work. The only other solution I could come up with is just define all the properties of the Business User(since it should be a superset) and then just add Customers to the same profile but just leave a bunch of the properties blank or empty but, that seems like a waste.  Does anyone have a suggestion on how this should be architected or what is the right way?  Any suggestions would be appreciated. Thanks,mosheah.

    Membership             Roles                 Profiles
    Business Users        Customer            ??
    Customer Users        BusAdmin
                                   BusEmployee

     

  • Re: Memberships, Profiles, & Roles..... Oh my...

    01-30-2009, 2:01 AM
    Answer
    hope this will help you http://msdn.microsoft.com/en-us/library/yh26yfzy.aspx
    Avantha Siriwardana
    Beware of bugs in the above code; I have only proved it correct, not tried it.
    (Donald Knuth)
    http://www.linkedin.com/in/avanthasiriwardana
  • Re: Memberships, Profiles, & Roles..... Oh my...

    01-30-2009, 2:13 PM
    • Member
      point Member
    • mosheah
    • Member since 03-11-2008, 7:37 AM
    • Posts 4

    Thanks for the link.  I have read quite a bit about Memberships and I understand the concept and how to use them but, it doesn't shed any light on the scenario that I am trying to implement.  Any other suggestions?

  • Re: Memberships, Profiles, & Roles..... Oh my...

    01-30-2009, 5:51 PM
    Answer
    • All-Star
      17,162 point All-Star
    • guru_sarkar
    • Member since 08-30-2007, 8:00 PM
    • Posts 2,605

    Don't think sharing properties in the way you are thinking is feasible or straightforward.

    but one option is to define two profile providers(BusinessProfile and CustomerProfile) in your web.config with different set of properties.

    When working with profile in code-behind you have to dynamically select the provider ...depending on if its Customer User or Business User.

    e.g.

    Profile.Providers["CustomerProfileProvider"].GetPropertyValues("FirstName")

    Profile.Providers["BusinessProfileProvider"].SetPropertyValues("Url","www.abcxyz.com")

Page 1 of 1 (4 items)