1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / UserManager providers question

UserManager providers question

9 posts, 0 answered
  1. Darren
    Darren avatar
    72 posts
    Registered:
    19 Mar 2008
    13 Jan 2010
    Link to this post
    Is it possible to specify a RoleProvider for UserManager?

    I have a site which is using my own role provider and Membership provider but is using the Profile provider from Sitefinity.
    Everything is fine except when I go to manage users through the CMS.

    In the left hand menu it lists the roles and correct number of users in that role but if I select a role I get a "Role not found error".
    I can manage roles OK though.

    So the security provider block looks like this.

    <security defaultProvider="DefaultSecurityProvider" cmsProvidersName="Sitefinity">
          <roles>
            <clear />
            <add name="Administrators" permission="Unrestricted" />
          </roles>
          <providers>
            <clear />
            <add name="DefaultSecurityProvider" connectionStringName="DefaultConnection" type="Telerik.Security.Data.DefaultSecurityProvider, Telerik.Security.Data" membershipProvider="CustomProvider" roleProvider="CustomProvider" />
          </providers>
        </security>

    Now if I change the cmsProviderName to CustomProvider then it will allow me to go further, opening the list of users in a role and then open the user itself along with all the controls for the profile but the users profile data is missing and if I re-add it and save then open the users profile again then its missing.
    I think the problem is that UserManager should be using the Sitefinity provider but the role provider and membership provider should be custom which is why I was wondering whether it's possible to explicitly specify which role, membership and profile providers whould be used by UserManager.

    Thanks
    Darren
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    13 Jan 2010
    Link to this post
    Hello Darren,

    The role, membership and profile providers are set in the following sections of project's web.config
    <roleManager>, <membership>, <profile>. You do not have to check the provider under <security> node.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Darren
    Darren avatar
    72 posts
    Registered:
    19 Mar 2008
    16 Jan 2010
    Link to this post
    Yes, I'm well aware of that but let me put it another way.

    Originally this used the standard Membership, Role and Profile providers and everything worked fine.
    I then changed the Membership and Role providers but left the Profile provider.
    Still everything worked except when I go to manage users I find that all of their extended profile controls are there but their profile data is not loaded.
    Equally if I change their profile values and save then the data is not persisted.

    Now this page including all of the extended profile properties was working but the act of changing the Membership and Role provider has stopped it working.
    I've checked that the original profile data is still stored in the Sitefinity database and I've checked that the UserId's against their profile metadata and their UserId's in the new provider match so I would have expected it to pull the data from the original profile provider, display the data and save it again.
    I've also noticed that First name is being set to Username in the manage users page but this may be unrelated.

    So theres no errors and it claims to have successfully stored the users profile but clearly it hasn't.
    I will debug this further to try to see what's happening but it appears that each step is working but the data just isn't being read or written.
  4. Darren
    Darren avatar
    72 posts
    Registered:
    19 Mar 2008
    16 Jan 2010
    Link to this post
    I think I've found the answer to this.
    It sounds identical to this post so I'll look at creating a new profile provider.

  5. Darren
    Darren avatar
    72 posts
    Registered:
    19 Mar 2008
    18 Jan 2010
    Link to this post
    This appears to be the issue since as a test I altered the stored procedures for reading and writing profile and user data to use tables in the second database and now all the users profile data is displayed.

    However, I can't persist user settings. For instance, through the CMS if I alter user profile values and click save I get the following error. Can you tell me which stored procedures are called from the standard Sitefinity profile provider when storing profiles?
    Presumably you are creating transactions which are now failing so I'm trying to work out which calls from the profile provider are not working.

    The object belongs already into a different transaction

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: Nolics.ORMapper.Base.NolnetException: The object belongs already into a different transaction

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [NolnetException: The object belongs already into a different transaction]
       Telerik.DataAccess.AspnetProviders.TelerikProfileProvider.SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection properties) +1736
       System.Configuration.SettingsBase.SaveCore() +375
       System.Configuration.SettingsBase.Save() +93
       System.Web.Profile.ProfileBase.SaveWithAssert() +31
       System.Web.Profile.ProfileBase.Save() +63
       Telerik.Security.WebControls.ManageProfile.SetProfileProperties(String username) +1674
       Telerik.Security.WebControls.ManageUsers.AttemptSaveProfile() +67
       Telerik.Security.WebControls.ManageUsers.editCnt_Command(Object sender, CommandEventArgs e) +207
       Telerik.Cms.Web.UI.GenericContainer`1.OnCommand(Object sender, CommandEventArgs e) +25
       Telerik.Cms.Web.UI.GenericContainer`1.OnBubbleEvent(Object source, EventArgs args) +66
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +118
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
    

  6. Darren
    Darren avatar
    72 posts
    Registered:
    19 Mar 2008
    19 Jan 2010
    Link to this post
    OK, I've got this working by further reworking the stored procedures.
    I may write an article on the end to process of integrating Sitefinity with YAF since theres been a lot of complications along the way, not just with Sitefinity but also in YAF but I have them now apparently working together fully.

  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    19 Jan 2010
    Link to this post
    Hi Darren,

    It will be great if you share your experience with us.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. Darren
    Darren avatar
    72 posts
    Registered:
    19 Mar 2008
    28 Jan 2010
    Link to this post
    I may may post all the steps somewhere but essentially I managed to get everything fully integrated by switching to YAF's Membership, Role and Profile providers and just keeping the Sitefinity Personalization provider.
    Now I'd have much preferred to use Sitefinity's providers, especially Sitefinity's Profile providers but this was just a non-starter sadly.

    The basic steps and issues I had are listed below.

    Step 1. Copy all of the YAF assemblies, user controls, resources and other bits and pieces into the Sitefinity project.

    Step 2. Merge the two web.config files, adding any missing references and properties but also remembering to update <Membership>, <role>, <Profile> and <Security> blocks to use whichever providers you are using. I missed the <Security> reference the first time which of course caused some issues.

    Issue 1: YAF has a design flaw in that the User table contains a lot of addtional information that should really be in a separate table. As a result I found it much easier to just use YAF's Membership provider than try to fix this in YAF.
    Since in my case I was integrating two sites which were in active use this also allowed me to pick up their forum stats etc which were stored in their user tables. I also switched to YAF's role provider just so I was using a Membership and Role provider in the same database and then went through a cycle of merging any user accounts that were in Sitefinity site A but which were missing from YAF site B.

    Issue 2: I then found that profiles didn't work. Telerik pointed me to the fact that some stored procedures cross referenced tables so while my Membership and Role tables were now in another database and happily working for their providers, the Profile provider no longer worked since it was assuming content was still being added to the tables in the Sitefinity database.
    Now I didn't want to start duplicating data so rather than try to synch the tables between the two databases I just re-write the stored procedures to look in the new database which was luckily on the same server.
    Now this worked except I then started to have strange nolics errors at intervals.

    In essence the site would be working fine and then suddenly I'd just get nolics errors. The only way to get things running would be to clear all cookies, create a new temporary user and then everything started to work again.
    Now I diffed the databases when working and not working and nothing had changed in the database and since switching client machines had no effect it was down to something in application state on the server but I never pinned down what it was.

    So in the end I switched my Profile provider to YAF's which fixed everything. However, YAF's profile provider isn't that great since it uses tables with hardcoded column names so while in Sitefinity I can just add new profile properties in the web.config, in YAF I have to start editing tables and classes.

    The final step for me was/is still to add some new profile columns to YAF and copy across a bit of data but other than that it works like a charm.

    You can see the results of this merge at www.marsdrive.com , just click on forums to see the YAF forums.

  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    28 Jan 2010
    Link to this post
    Hello Darren,

    Thanks for sharing your experience with us. I believe that this will help to the other community members if they are going to implement similar/same functionality. Your Telerik points have been updated.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
9 posts, 0 answered