Membership Provider
Could someone provide a sample project which has a standard asp.net SQL membership provider configured for the front end user authentication. This would not in any way be used for logging into the backend. However authticated users in the front end would be bound to site view permissions.
Ivan has provided some code on this in another post but there is of course much more to pulling this off. There is backend profile administration to consider as well as providing a means for front end users to update their profile information and or to register for sites that allow new users to register from the site. I personally register all customers on my system using other means.
I think there are most likely many people desperate for the custom membership wrapper functionality to assist with this so they can use 4.0 to replace current sites with Sitefinity.
Since it is apparently no big deal to just do this manually. Perhaps it would easier then for Telerik's Sitefinity team to simply whip up a working project for us all to use instead of us all wasting another 40 hours of our lives fighting our way through it.
This would be greatly appreciated by the community, I am positive. I know I would greatly appreciate the help.
Thank you
Hi Bill,
We are going to implement the membership wrappers for Q1. We had a discussion about the profile provider which will be extended as well. I will update the post ( within the next few days) with more information once we clear what we will have at the end.
Regards,
Ivan Dimitrov
the Telerik team
Hi,
Like Bill, I'd like to set-up front-end user authentication on a Sitefinity web site and I'm having troubles implementing it: any news on the subject?
Regards,
Carl
Same for me! I've been playing around with it but couldn't get it to work as expected.
For example I never get a 403 to redirect to the login.
As Bill requested a working example would be perfect! I've looked at the starter kits but these don't implement this in the way I would like to use it.
Regards,
Peter
I think I'm almost there but I don't get what I'm missing.
I implemented a membership provider named CustomSitefinityMembershipProvider which derives from the MembershipDataProvider type.
Then in my web.config I added my new provider which I wanna use for front-end user authentication. Here's my web.config:
<membership defaultProvider="Default">
<providers>
<clear/>
<add name="Default" type="Telerik.Sitefinity.Security.Data.SitefinityMembershipProvider, Telerik.Sitefinity" />
<add name="Test" type="SitefinityExtensions.Web.Security.CustomSitefinityMembershipProvider, SitefinityExtensions" />
</providers>
</membership>
Then using the admin, I went in "Administration > Settings > Security > Membership Providers" and added a new membership provider with its Name set as Test and the Provider Type as "SitefinityExtensions.Web.Security.CustomSitefinityMembershipProvider, SitefinityExtensions".
In the Security.config file I do see my membership provider appear as:
<add description="Used for front-end users" resourceClassId="" enabled="True" name="Test" />
Then I'm addind a LoginControl on a page and set its Membership Provider property to Test.
Then when I try to login with an existing user on my front-end site, I get an "Object reference not set exception":
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.
|
[NullReferenceException: Object reference not set to an instance of an object.] DynamicModule.ns.Wrapped_CustomSitefinityMembershipProvider_42b0bb2407094ebca69d4f52c1209447.Clone() +397 Telerik.Sitefinity.Data.ManagerBase`1.SetProvider(String providerName, String transactionName) +453 [TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeMethodHandle._InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct& signature, RuntimeType declaringType) +0 System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +517 Telerik.Sitefinity.Data.ManagerBase`1.GetManager(String providerName, String transactionName) +753 Telerik.Sitefinity.Security.SecurityManager.AuthenticateUser(String membershipProviderName, String userName, String password, Boolean persistent, User& user) +46 Telerik.Sitefinity.Security.Web.UI.LoginForm.LoginForm_Authenticate(Object sender, AuthenticateEventArgs e) +240 System.Web.UI.WebControls.Login.AttemptLogin() +166 System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +93 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +52 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3691 |
Ok, I've got it: it was indeed Unity's wrapper object's Clone method which was invalid. In my MembershipDataProvider implementation I had to override the Clone method and mark it sealed to avoid Unity intercepting it.
Example:
public sealed override object Clone()
return base.Clone();
I also had to set the protected field providerDecorator to a bogus decorator (but non null) to make it work:
public CustomSitefinityMembershipProvider()
providerDecorator = new EmptyDecorator();
I don't get the exception anymore, plus when connecting to the admin, my custom Test provider is now proposed in the listbox.
However, it's not functional yet, since going in "Administration > Users" none of my users are displayed and an "Object reference not set to an instance of an object." message still is displayed at the top of the page. Any ideas what I'm missing, or how to debug this one?
Thanks in advance,
Carl
I got the same problem here.. have you resolved?
Thanks
Nope, it simply isn't supported in version 4.0, according to Telerik it'll be provided with the Q1 release. (http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/membership-providers-wrappers.aspx).
++,
Carl
Hello Carl,
thanks for your reply
but you validate against a SQL membership provider? I don't understand why I should need a wrapper to avoid the object not set... error message...