Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dan 3 posts 23 karma points
    May 03, 2011 @ 20:05
    Dan
    0

    trying to create custom MembershipProvider

    hello,

    I am an umbraco newbie and am working with version 4.7.

    I have a requirement to get user information from our SalesLogix SQL database.  The backend users can be managed through the Out-Of-Box umbraco membership provider.  Looks like umbraco is encouraging the use of the ASP.NET provider model per this page http://our.umbraco.org/wiki/how-tos/membership-providers.

    Trying to create a custom MembershipProvider prototype, I used the sample code on this page http://msdn.microsoft.com/en-us/library/6tc47t75%28v=VS.85%29.aspx in my class below and added the Users table to my umbraco database.

    namespace UmbracoCustomMembershipProvider
    {
    public sealed class CustomMembershipProvider : MembershipProvider
    {
    //see link above for contents of this class
    }
    }

     

    The following is in my web.config file:

    <connectionStrings>
    <remove name="LocalSqlServer" />
    <!--<add name="LocalSqlServer" connectionString="server=.\sqlexpress;database=aspnetdb;user id=DBUSER;password=DBPASSWORD" providerName="System.Data.SqlClient"/>-->
    <add name="UmbracoConnectionString"
    connectionString="server=.\sqlexpress;database=umbraco;user id=umbracouser;password=mypassword"
    providerName="System.Data.SqlClient" />

    </connectionStrings>


    <membership defaultProvider="UmbracoMembershipProvider" userIsOnlineTimeWindow="15">
    <providers>
    <clear />
    <add name="UmbracoMembershipProvider" type="umbraco.providers.members.UmbracoMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" defaultMemberTypeAlias="Another Type" passwordFormat="Hashed" />
    <add name="CustomMembershipProvider" type="UmbracoCustomMembershipProvider.CustomMembershipProvider" connectionStringName="UmbracoConnectionString" passwordFormat="Clear" />

    </providers>

     

    Now when I try to login to umbraco, I get the following error:

    [NullReferenceException: Object reference not set to an instance of an object.]
    umbraco.cms.presentation.login.Button1_Click(Object sender, EventArgs e) +134
    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
    System.Web.UI.WebControls.Button.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) +36
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

     

    Not sure what I am missing here or how to properly implement this solution. 

    Is there a sample available that shows how to implement a custom membership provider in umbraco based on the ASP.NET provider model?

    thanks!!!!

    Dan

     

     

  • Daniel Bardi 927 posts 2562 karma points
    May 04, 2011 @ 02:15
    Daniel Bardi
    0

    Are you creating a user's membership provider for the backoffice  (looks like it)

    You need to edit the umbracosettings.config to set what membership provider to use for the backoffice.

    The default in the web.config is for the member's membership provider, not the user's membership provicder

     

  • Dan 3 posts 23 karma points
    May 09, 2011 @ 15:49
    Dan
    0

    Looks like I had it backwards...my intention was to customize the provider handling the website users.

    Thanks for you help!

    Dan

  • Daniel Bardi 927 posts 2562 karma points
    May 09, 2011 @ 22:17
    Daniel Bardi
    0

    To do that, changed the defaultProvider attribute in the web.config to your custom provider name.. Done!

  • Dan 3 posts 23 karma points
    May 13, 2011 @ 22:21
    Dan
    0

    I am now able to add a Register/Login control to an umbraco page and have it utilize my custom membership provider.

    The issue I am encountering now is that the Member area in the back office is not seeing any of the Members I create with my custom provider.  It is still looking at the default cmsMember, cmsMember2MemberGroup, and cmsMemberType tables.

    What else needs to be done besides updating Web.config to tell the Umbraco back office to use my new provider/tables?

    thanks!

    Dan

Please Sign in or register to post replies

Write your reply to:

Draft