Loading user personalization settings as Guest

Last post 10-04-2006 3:50 PM by ajjvn. 10 replies.

Sort Posts:

  • Loading user personalization settings as Guest

    02-21-2006, 3:02 PM
    • Member
      95 point Member
    • Danijel
    • Member since 02-21-2006, 7:38 PM
    • Slovenia,Sp.Duplek
    • Posts 19

    I need to create portal like myspaces.

    If i have a list of users that can store their perosnalization settings. Now what would be the best possible way for a guest to retrive user personalization data?

    Is there a Method that can retrive users personalization settings from database?

    (my first post and bad english) :)

     

     

  • Re: Loading user personalization settings as Guest

    02-21-2006, 9:35 PM
    • Contributor
      3,067 point Contributor
    • sschack
    • Member since 09-16-2003, 4:06 PM
    • Posts 613
    • AspNetTeam
      Moderator

    If you are looking to load Profile data for an arbitrary user, take a look at the code I posted for another question:

    http://forums.asp.net/1204732/ShowPost.aspx

     

    -Stefan
    ----------------------------------------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Loading user personalization settings as Guest

    02-22-2006, 3:06 PM
    • Member
      95 point Member
    • Danijel
    • Member since 02-21-2006, 7:38 PM
    • Slovenia,Sp.Duplek
    • Posts 19

    Thank you for quick reply. I tried this and it works. But I was thinking how could I retrieve profile regarding web parts (zones,webparts).

    If authorized user access a page with his username all his zones and webparts are loaded. But if an unauthorized user accesses this same page he will see only webparts and zones that were added by user with saredscope (page owner-admin). This results that unauthorized user can only access one instance of page (owners). I would like to retrieve webparts and zones for custom user.

    Will I need to create multiple pages and one user-owner per page and than set Scope to shared. This would work but I think it is not an elegant solution.

    Hope you all understand what i ment ;)

  • Re: Loading user personalization settings as Guest

    02-22-2006, 9:14 PM
    • Contributor
      3,067 point Contributor
    • sschack
    • Member since 09-16-2003, 4:06 PM
    • Posts 613
    • AspNetTeam
      Moderator

    In ASP.NET 2.0 web parts personalization only supports displaying shared scope data to anonymous users.  For shared scope data, there is always one set of shared data per page.  As a result there really isn't the concept of different user-owners per page.  Instead, if an authenticated website user has rights to enter shared scope, as well as modify state, then that user is allowed to switch each page into shared scope and make personalization changes for the shared-scope view of that page.

    Are you looking to retrieve the per-user personalization data of a page even though the current user is anonymous?

    -Stefan
    ----------------------------------------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Loading user personalization settings as Guest

    02-23-2006, 5:49 AM
    • Member
      95 point Member
    • Danijel
    • Member since 02-21-2006, 7:38 PM
    • Slovenia,Sp.Duplek
    • Posts 19
    sschack wrote:
    Are you looking to retrieve the per-user personalization data of a page even though the current user is anonymous?

    Exactly

    I should create portal  like MSN MySpaces. But as I am investigating WebParts framework I think this can only be done by creating a new page for each user and  his scope set shared. (only one user per page and all of the other users are guest that can only see data that was set by page owner).


  • Re: Loading user personalization settings as Guest

    02-24-2006, 2:28 PM
    • Contributor
      3,067 point Contributor
    • sschack
    • Member since 09-16-2003, 4:06 PM
    • Posts 613
    • AspNetTeam
      Moderator

    Scratched my head quite a bit on this since its a tough problem to solve with Web Parts.  I haven't tried out what I outline below - but from looking at the code I *think* it will work.

    Try deriving from SqlPersonalizationProvider, and overriding the LoadPersonalizationBlobs method.  The trick here is along the lines of what you are suggesting - you need to make the personalization system think it is loading the shared scope data for a page, but instead you want to return the per-user data for a specific user.  The reason for deriving from SqlPersonalizationProvider is so you can fake out the personalization stack.

    For LoadPersonlizationBlobs, you want the override to return the per-user data even though it is being asked to load shared state.  You will have to fill in a non-null value for the username parameter - the value will be the user whose personalized data you want to retrieve.  Than call base.LoadPersonalizationBlobs.  When the call returns, you should have a null value for the sharedDataBlob (assuming that no one ever set shared state for the page) and a non-null value for the userDataBlob.  Swap those values around - so that your custom provider returns the userDataBlob from the base provider in the sharedDataBlob parameter.  And the null value is instead returned in the userDataBlob parameter. 

    This should have the effect of making the personalization stack think it just retrieved the shared data for the page, when in reality it now has the personalized data of the page for a specific user.

    -Stefan
    ----------------------------------------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Loading user personalization settings as Guest

    02-27-2006, 5:07 PM
    • Member
      95 point Member
    • Danijel
    • Member since 02-21-2006, 7:38 PM
    • Slovenia,Sp.Duplek
    • Posts 19

    I really appreciate your quick answer.

    I tried your trick and i tworked. I just hope this will be enough to use it with all other features that I need to implement for my degree:)

    Thanks again.

  • Re: Loading user personalization settings as Guest

    10-04-2006, 1:20 PM
    • Member
      20 point Member
    • ajjvn
    • Member since 10-04-2006, 2:32 AM
    • Posts 4

    I came up with this same idea after reading MSDN articles for hours.  I implemented it and no go.  What I hadn't done is the swap the user and shared BLOBs around.  I did that and no go.  I proceded to try all sorts of web.config and (custom) WebPartManager setting adjustments.  No go.  Aaargh!

     I'm at wits end.

     A

     

    sschack:

    Scratched my head quite a bit on this since its a tough problem to solve with Web Parts.  I haven't tried out what I outline below - but from looking at the code I *think* it will work.

    Try deriving from SqlPersonalizationProvider, and overriding the LoadPersonalizationBlobs method.  The trick here is along the lines of what you are suggesting - you need to make the personalization system think it is loading the shared scope data for a page, but instead you want to return the per-user data for a specific user.  The reason for deriving from SqlPersonalizationProvider is so you can fake out the personalization stack.

    For LoadPersonlizationBlobs, you want the override to return the per-user data even though it is being asked to load shared state.  You will have to fill in a non-null value for the username parameter - the value will be the user whose personalized data you want to retrieve.  Than call base.LoadPersonalizationBlobs.  When the call returns, you should have a null value for the sharedDataBlob (assuming that no one ever set shared state for the page) and a non-null value for the userDataBlob.  Swap those values around - so that your custom provider returns the userDataBlob from the base provider in the sharedDataBlob parameter.  And the null value is instead returned in the userDataBlob parameter. 

    This should have the effect of making the personalization stack think it just retrieved the shared data for the page, when in reality it now has the personalized data of the page for a specific user.

  • Re: Loading user personalization settings as Guest

    10-04-2006, 1:25 PM
    • Member
      20 point Member
    • ajjvn
    • Member since 10-04-2006, 2:32 AM
    • Posts 4

    I should add I can see the genned stored procedures, via Profiler, query the database with the username and path supplied.  I can also see results coming back into the (custom) SqlPersonalizationProvider's overridden LoadPersonalizationBlob via debugger.  It just does seem to be utilzed by the Pers/WebPart engine.  I think I have tried all the various settings to tweak to (shared/user, authorization, authentication, etc.).

     A

     

  • Re: Loading user personalization settings as Guest

    10-04-2006, 1:27 PM
    • Member
      20 point Member
    • ajjvn
    • Member since 10-04-2006, 2:32 AM
    • Posts 4

    (Ugh, can't edit posts as a new member!)

    Sorry, the line "It just does seem to be utilzed by the Pers/WebPart engine" should read "It just doesn't seem to be utilzed by the Pers/WebPart engines".

    A

     

  • Re: Loading user personalization settings as Guest

    10-04-2006, 3:50 PM
    • Member
      20 point Member
    • ajjvn
    • Member since 10-04-2006, 2:32 AM
    • Posts 4

    I posted the above when I awoke after being up until 5am messing with this.  After a shower and some breakfast (err lunch), it occured to me to check something.  Sure enough, that was it.  I had duped the page that the authenticated users use to create their personalized web parts pages.  The duped page would be in the non-authenticated area of the site.  I had inadvertantly changed the names of some of the web part objects so when I faked the username and path for this new page, the personalization pulled from the DB couldn't be applied to these non-existent (err, mis-named) web part objects.  :)  I should have just went to bed at 2am!

    These forums look like they will be a great resource from some of the stuff I have read on other topics.

    A

     

Page 1 of 1 (11 items)