Associate Business Logic to Current User/Does it still make sence to Extend User and IPrinciple in 2.0

Last post 11-08-2007 3:12 PM by scott@elbandit.co.uk. 1 replies.

Sort Posts:

  • Associate Business Logic to Current User/Does it still make sence to Extend User and IPrinciple in 2.0

    11-07-2007, 9:50 PM
    • Member
      73 point Member
    • dwilliams459
    • Member since 03-01-2006, 4:24 PM
    • Charlotte, NC
    • Posts 37

    I am looking for the best way associate business objects to the current user of the website.  I am guessing the best way to do this is to extend the Identity.User object (i.e. extend the user object to include properties such as User.ID, User.Company. etc.).  A search for a solution reveals a number of discussions and articles about extending IPrinciple etc, but most of these seems old and related to 1.1.  I do not know if this is still the best method in 2.0.  I utilized P&P IPrinciple in the 1.1 days, but have not looked at it since.  Can someone please let me know if extending IPrinciple is still the best way to map your business objects to your current user?  If not can you please point me in a better direction?  In either case can you please provide a link to a 2.0 based article if you know of one? 

    Thanks very much.  I am a little rusty when it comes to security and 2.0

    David Williams MCP
    .Net Senior Developer
    Filed under: , ,
  • Re: Associate Business Logic to Current User/Does it still make sence to Extend User and IPrinciple in 2.0

    11-08-2007, 3:12 PM
    Answer

    Have you had a look at the Profile API? If you need to persist the properties of the object i.e. you need to store them in a database you could have a look at extending the profile and building you own custom profile provider. You can store any type of custom object in the profile and this will be associated with the logged in user, it even has support for annoymous users.

    This link shows you how to store a shopping cart in the profile.
    http://msdn2.microsoft.com/en-us/library/d8b58y5d(VS.80).aspx

    Creating a Custom Profile Provider
    http://www.theserverside.net/tt/articles/showarticle.tss?id=CreatingProfileProvider

    If you are going to use profiles and want to write your own custom provider to persist that data to an exisitng database have a look at the Pet Shop.net sample application, they also talk about it in the documenation:
    http://msdn2.microsoft.com/en-us/library/aa479070.aspx

    My Books:

    Professional Enterprise .NET
    Check out my book on learning all about enterprise programming, including TDD, Mocking, DDD, Dependecy Injection, Inversion of Control, Dependency Inversion, NHibernate, MVC & MVP. Check out the code on the projects codeplex site.

    NHibernate with ASP.net Problem-Design-Solution
    Learn all about NHibernate with ASP.net.
Page 1 of 1 (2 items)