Mulitple Membership Providers

Posted by Community Admin on 03-Aug-2018 21:07

Mulitple Membership Providers

All Replies

Posted by Community Admin on 28-Apr-2011 00:00

Getting frustrated here...not sure what Im doing wrong.

Ok so we have the Sitefinity users table which handles backend users and we have a customers database which is a seperate table that has no relationship with the Sitefinity user table. How can we handle multiple Membership Providers? I have a Customer Membership provider setup and it works independently but as soon as I try and login to the Sitefinity Admin site it tries to call routines in my Customer Membership.  What is going on?

I have my membership provider defined in the web.config

    <membership defaultProvider="Default">
      <providers>
        <clear/>
<add name="CustomerMembership" type="DynastyRogues.Data.CustomerMembership" connectionStringName="Sitefinity"  />
        <add name="Default" type="Telerik.Sitefinity.Security.Data.SitefinityMembershipProvider, Telerik.Sitefinity"/>
      </providers>
    </membership>


I saw a few posts about this but none of them seemed to be answered that I had found. Help on this would be greatly appreciated.

Posted by Community Admin on 30-Apr-2011 00:00

Little help please?

Posted by Community Admin on 03-May-2011 00:00

Hello Jerami,

What is the base class of DynastyRogues.Data.CustomerMembership - is it like SqlMembebshipProvider? Could you use the base SqlMembebshipProvider class instead?

All the best,
Lubomir Velkov
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

Posted by Community Admin on 05-May-2011 00:00

I have the same frustration here... trying to build a VERY simple custom membership but can't get it to work. It looks like that most tutorials/docs on how to do this are only valid with the old 3.x version of Sitefinity.

Posted by Community Admin on 07-May-2011 00:00

I modified my Membership Provider to inherit SQLMembershipProvider...and I can log in to my users table now...but I then can't login to the Default Membership Provider of Sitefinity...it keeps trying to read from my CustomMembership Provider...how can I say if you login to the Front End use this membership provider and if you log into the Back End use the Sitefinity Membership Provider?

Posted by Community Admin on 10-May-2011 00:00

Still only able to use one membership provider at a time. So basically if I have my custom membership provider in the web.config I cannot log into Sitefinity...but I can log in correctly to my custom database. So my workflow is keep both my membership providers in the web.config until I want to log into the backend...then take out my custom membership and do my work in Sitefinity. Then put my membership provider back in so users on the site can access restricted front end parts of the site. Not a real good workflow going on here.

Posted by Community Admin on 11-May-2011 00:00

Hi Jerami,

Could you send us your web.config and the files in the App_Data/Sitefinity/Configuration folder? I will try to reproduce the issue locally.

Greetings,
Lubomir Velkov
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

Posted by Community Admin on 11-May-2011 00:00

Thanks for taking a look at this...I had to submit this via support ticket  423130

Posted by Community Admin on 11-May-2011 00:00

If you get this to work, can you repost your configuration files -- scrubbing anything secretive first, of course.

I think I'm having the same issue. I can only get HttpContext.Current.User to get populated if I log into the backend, never through my alternate provider. But the forms authentication cookie is getting set.

I wonder if I just need to get rid of the SF provider and just use my SQL/ASP.NET provider.

Thanks

Posted by Community Admin on 13-May-2011 00:00

Hello Eric,

You can't get rid of the default provider - it is named "Default" and will always be available.

When you get the backend Login screen you should get a dropdown of all available membership providers that would allow you to log to the backend.

When you login to the front-end are you using the Login control from the toolbox? It should allow you to select a provider against which to verify the username and password. 

Greetings,
Lubomir Velkov
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

Posted by Community Admin on 17-May-2011 00:00

I'm using a custom control that has the regular ASP.NET login control. That control points to the custom provider. This works fine, it's just that the profile object is anonymous after logging in.

Posted by Community Admin on 19-May-2011 00:00

Hi Eric,

You should make the following call to authenticate in Sitefinity:

var reason = SecurityManager.AuthenticateUser("AspNetSqlMembershipProvider", this.LoginControl.UserName, this.LoginControl.Password, true);

You could call this in the OnLoggedIn event handler of the <asp:Login> control - e.g.

<asp:Login ID="LoginControl" runat="server" MembershipProvider="AspNetSqlMembershipProvider" OnAuthenticate="OnAuthenticate" OnLoggedIn="OnLoggedIn"></asp:Login>

protected void OnLoggedIn(object sender, EventArgs e)

    var reason = SecurityManager.AuthenticateUser("AspNetSqlMembershipProvider", this.LoginControl.UserName, this.LoginControl.Password, true);
    if (reason != UserLoggingReason.Success)
   
        // Could not login for some reason
   

Regards,
Lubomir Velkov
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

Posted by Community Admin on 23-May-2011 00:00

Just got this to work propertly.

Basically I set up two membership providers in the web.config as follows:

<membership defaultProvider="Default">
      <providers>
        <clear/>
        <add name="Default" type="Telerik.Sitefinity.Security.Data.SitefinityMembershipProvider, Telerik.Sitefinity"/>
        <add name="CustomerMembership" type="DynastyRogues.Data.CustomerMembership" connectionStringName="Sitefinity" enablePasswordRetrieval="false"
                                           enablePasswordReset="true" requiresQuestionAndAnswer="false"
                                           requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6"
                                           minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
                                           applicationName="/" />
      </providers>
    </membership>

Then in my Custom Membership Provider I implemented the GetAllUsers method to this:

public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
        
            var coll = new MembershipUserCollection();
            totalRecords = 0;
 
            return coll;
        

Not sure why I had to do this but this was the method that was causing the sqawking. Initially this still didn't work I was still getting errors but that was because I had Integrated Windows Authentication checked in the Directory Security/Authentication Methods of my IIS6 website. I unchecked this and just had the Enable Anonymous Access checked. I was then able to accomodate the multiple membership providers.

Also note my MembershipProvider had to implement SqlMembershipProvider.

Hope this helps others.

This thread is closed