More in this section
Forums / Developing with Sitefinity / Custom membership provider

Custom membership provider

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Dominic
    Dominic avatar
    10 posts
    05 Oct 2012
    19 Oct 2012
    Link to this post

    I am in the process of evaluating the product.  I can see its fairly easy to quickly build a web site, I have been able to do everything I wanted in regards to integrating my custom user controls into sitefinity pages.

    The problem I have is that I do not want to use the Sitefinity membership provider.  All my usernames and passwords are already stored in a separate SQL Server database.

    But all the menus / submenus are configured using Sitefinity role.  Actually everything is public except a few links in my "Members" section that I put permission to "Authenticated".  So what I need is once the user has been authenticated against my other database, I need to let Sitefinity know the user is authenticated so the menus act as such.

    So I created a custom membership provider and override the necessary methods, in particular the ValidateUser() method so the validation is made against my other database.  But that does not work. 

    For some reason I get an error.

    Here is what I did:
    1- The settings are "Claims Based Authentication"
    2- In Sitefinity I created a page, added a Login widget.
        - I edited the properties and changed the MembershipProvider to my: MyCustomMembershipProvider
    3- In the web.config file, I updated the membership section to look like this:

    <membership defaultProvider="Default">
    <add name="Default" type="Telerik.Sitefinity.Security.Data.SitefinityMembershipProvider, Telerik.Sitefinity"/>
    <add name="MyCustomMembershipProvider" type="Test1.MyCustomMembershipProvider" connectionStringName="stdConnection" passwordFormat="Clear" applicationName="/" />

    I get the error "Object reference not set to an instance of an object."
    Here is the stack pile:
    [NullReferenceException: Object reference not set to an instance of an object.]
    Telerik.Sitefinity.Security.UserWrapper.CopyFrom(MembershipUser user, String applicationName) +161
    Telerik.Sitefinity.Security.MembershipProviderWrapper.GetUser(String userName) +77
    Telerik.Sitefinity.Security.Claims.ClaimsManager.ValidateUser(String domain, String username, String password) +231
    Telerik.Sitefinity.Security.Claims.SecurityTokenServiceHttpHandler.TryParseInputToken(NameValueCollection values, User& user, RequestMessage& message) +445
    Telerik.Sitefinity.Security.Claims.SecurityTokenServiceHttpHandler.ProcessRequest(HttpContext context) +1231
    System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +532
    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +255

    Being able to authenticate a login against my database so the menus/sub menus of the rest of the site act as normal (visitor or authenticated) is the only thing I have to figure out before buying this product.

    I have read many forum message regarding all this but I just can't make it work.  Would it be easier to use a custom login form.  And once I validate the user/password, do some trick to programmatically authenticate a "fake user" created in sitefinity so everybody connecting to the website would use the same user since anyway its just to handle the visible/hidden menu.

    Thanks for helping me.
  2. Ivan Georgiev | Sitefin1ty
    Ivan Georgiev | Sitefin1ty avatar
    33 posts
    24 Sep 2012
    24 Oct 2012
    Link to this post

     Thank you for contacting Telerik. Please send us the databases and you project because it seems that you are doing everything right.

    All the best,
    Ivan Georgiev | Sitefin1ty
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered