Sitecore Custom Membership Provider - sitecore

We have a need to use an existing external database for our membership needs. This database will contain all the basic information needed to authenticate and authorize users. I'm looking to see if you have documentation that can guide me through this process. I've seen posts online for custom membership providers implementation. But I haven't seen examples on how to integrate the custom membership provider with Sitecore API so Sitecore.Context.User will return the information of the logged in user.
Also, is there a way to access the custom profile information via Sitecore API?
Thanks

As promised in my comment here is our setup for enabling the Sitecore setup to stay the same while adding an extra membership provider to use in your website specifically.
First this can be found inside of our web.config transform file under the <system.web>:
<membership hashAlgorithmType="SHA256" xdt:Transform="SetAttributes(hashAlgorithmType)">
<providers>
<add name="sitecore" type="Sitecore.Security.SitecoreMembershipProvider, Sitecore.Kernel" realProviderName="switcher" providerWildcard="%" raiseEvents="true" xdt:Locator="Match(name)" xdt:Transform="Replace" />
<add name="myprovider" type="MyProject.SecurityProviders.MembershipProvider, MyProject.SecurityProviders" applicationName="sitecore" xdt:Transform="Insert"/>
</providers>
</membership>
<roleManager>
<providers>
<add name="sitecore" type="Sitecore.Security.SitecoreRoleProvider, Sitecore.Kernel" realProviderName="switcher" raiseEvents="true" xdt:Locator="Match(name)" xdt:Transform="Replace" />
<add name="myprovider" type="MyProject.SecurityProviders.RoleProvider, MyProject.SecurityProviders" applicationName="sitecore" xdt:Transform="Insert"/>
</providers>
</roleManager>
Next this is found in a separate config include file directly under <sitecore>:
<switchingProviders>
<membership>
<provider providerName="myprovider" storeFullNames="false" wildcard="%" domains="websitedomain" patch:before="*"/>
</membership>
<roleManager>
<provider providerName="myprovider" storeFullNames="false" wildcard="%" domains="websitedomain" patch:before="*"/>
</roleManager>
</switchingProviders>
These 2 changes in configuration will enable you to create a custom membership and role provider (in case you need one). As you can see the tricky part is not making the switching membership provider of sitecore the default provider (as stated in the documentation 2.6.2) but setting the realProviderName of the sitecore provider to switcher.
From hereon it is straightforward implementation of ASP.NET Membership.

You have seen this document already?
A Developer's Guide to Integrating Authentication Systems with Sitecore
It talks you through the whole process of creating an ASP.net membership provider. The whole point of the provider is that it abstracts the API from the implementation, so you can definitely achieve what you need.
Essentially, you need to override all the relevant methods from the base ASP.Net provider, using them to "wrap" around equivalent calls to your external database.

Related

Sitecore 6.6 publishing to multiple targets

Currently working on a sitecore solution which is running version 6.6 and we're experiencing some odd behavior. The site is setup to have multiple targets which are all pointing to individual databases for a webserver for instance web1 - web3 etc... I can confirm that all connection strings are correct and that the web servers are able to communicate to/from the sitecore cms server.
With a lot of reading I found out about the EnableEventQueues (http://www.sitecore.net/learn/blogs/technical-blogs/getting-to-know-sitecore/posts/2010/07/introducing-the-sitecore-event-queue.aspx) which in theory should have resolve this problem, however having enabled this on all web nodes and the cms server it's still experiencing issues.
Our other theory was to recycle an app pool to check if sitecore had cached old content and was waiting on a period to update its cache? However this seemed to fail but pointing the connection string to a working on then worked, so it was like sitecore had only published the changed to a select few nodes.
We're currently at a stand still as to what could be causing this, unless there's any other configs which require enabling?
The ScalabilitySettings.config looks like:
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<settings>
<setting name="EnableEventQueues">
<patch:attribute name="value">true</patch:attribute>
</setting>
<setting name="InstanceName">
<patch:attribute name="value"></patch:attribute>
</setting>
<setting name="Publishing.PublishingInstance">
<patch:attribute name="value"></patch:attribute>
</setting>
<setting name="Counters.InstanceName">
<patch:attribute name="value"></patch:attribute>
</setting>
<setting name="Caching.SecurityCacheExpiration">
<patch:attribute name="value">00:20:00</patch:attribute>
</setting>
<setting name="Media.DisableFileMedia">
<patch:attribute name="value">false</patch:attribute>
</setting>
<setting name="Media.FileFolder">
<patch:attribute name="value">/App_Data/Replicated/MediaFiles</patch:attribute>
</setting>
</settings>
</sitecore>
</configuration>
Many thanks,
Shaun
Can you show your scalability settings? Specifically, the Instance Name and Publishing Instance Name for your CDs and CMs?
Usually, it is the event queues, as you surmised, but perhaps you have something off in those particular files for the instance names. They should all have the same publishing instance name value and unique values for the instance name.
Update:
Now that I see your scalability settings, I can see the issue. You will need to give your content management instance where publishing is occurring a name. Perhaps something as simple as "CM".
On the content management server, the scalability settings will need to be setup with the same value in the Publishing.PublishInstance and InstanceName settings (e.g. "CM").
On your content delivery servers, the scalability settings will need to be setup with the publishing instance value (e.g. Publishing.PublishInstance = "CM")
You can provide unique InstanceName values on each CD if you like, or leave it blank and Sitecore will generate a unique value for each CD.
Why is this needed?
The event queue informs all sitecore instances connected to it about the events coming from the publishing instance. Each instance needs to know who their associated publisher is so that they know which events to process.

How do I add a custom .aspx page to sitecore?

I've recently created an aspx and aspx.cs page that needs to run alongside a sitecore website. Does anyone know how i can add these pages into the site? Our set up is very odd and would like to know recommendations before trying anything and risking breaking our setup.
You don't necessarily have to add your page to the IgnoreUrlPrefixes.
Before the ItemResolver is executed, the FileResolver is executed which checks if your request points directly to a file on disk.
You do need to configure the allowed URL extensions in the FilterUrlExtensions processor of the preprocessRequest pipeline, as such:
<preprocessRequest
<processor type="Sitecore.Pipelines.HttpRequest.FilterUrlExtensions, Sitecore.Kernel">
<param desc="Allowed extensions (comma separated)">aspx, ashx, asmx</param>
<param desc="Blocked extensions (comma separated)">*</param>
</processor>
</preprocessRequest>
So that configuration will allow *.aspx, *.ashx and *.asmx to be requested directly (it's the default configuration in Sitecore 7.0).
If you're using Sitecore 6.6 or lower, the FilterUrlExtensions processor can be found in the httpRequestBegin pipeline.
If you just drop the ASPX page in at the path you'd like it to reside, by default, Sitecore should let it be served as is by going to the corresponding URL.
Just add the pages to the projects as normal (as DustinDavis suggested) but you also need to modify IgnoreUrlPrefixes in web.config (or add a config patch file) and include the pages or folders as pipe delimited values that you want the Sitecore handlers to ignore.
You can configure the value attribute of the
/configuration/sitecore/settings/setting element in web.config with
name IgnoreUrlPrefixes to prevent Sitecore from processing specific
requests, causing ASP.NET to process the request without Sitecore.
From Sitecore Presentation Component Reference
There is more information about the how and why in this blog post by Alex Ahyba
If you have sitecore open in Visual Studio, just add them in to the project. You can access the new page directly.

website not updated after sitecore publish

I have setup my Sitecore installation to two different IIS Sites. One has all of the Sitecore Admin files and the other one has a clean web only files sharing the same Web.config, and my Data folder is outside of both folders.
-Sitecore.Data
--Licenses and Logs
-Sitecore.Admin
--Sitecore (folder with files)
-Sitecore.Web
--html,css, and js files
The problem I am running into is that after I do a publish from Sitecore.Admin folder, the Sitecore.Web doesn't update with the changes unless I recycled the app pool for Sitecore.Web. I tried to add a task for recycle the app pool programmatically, but had no success.
<processor type="MySite.Sitecore.Publishing.IISReset, MySite.Sitecore" />
Any suggestion on how to propagate the changes from one IIS node to the other one. I think the problem is that the HtmlCacheClearer is run for the Sitecore.Admin Node, but not for the other one.
You need to enable the EventQueues.
The EventQueues propagates the different events, like publishing, item saved etc. to the frontend servers.
Basically you need to rename a config file.
/App_Config/Include/ScalabilitySettings.config.example to ScalabilitySettings.config
That config file enables the event queue, and some other configurations.
I recommend reading the Sitecore Scaling guide.
http://sdn.sitecore.net/Reference/Sitecore%206/Scaling%20Guide.aspx
Just like dunston said, make sure that ScalabilitySettings.config file is configured right
By enabling EventQueue
And making sure that instance name on Content Delivery server is Unique per server, like 'MachineName-CD1, MachineName-CD2'.
And make sure that HtmlCacheClearer event is added for your website name on PublishEnd:Remote event.
Besides enabling event queue like dunston said, also make sure that your website name is added to the publish:end and publish:end:remote HtmlCacheClear events, if you are using a different site then the default "website" otherwise you Html cache doesn't get cleared at all after a publish.
<event name="publish:end">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<site>website</site>
</sites>
</handler>
</event>
<event name="publish:end:remote">
<handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
<sites hint="list">
<site>website</site>
</sites>
</handler>
</event>
By publishing though, it sounds like you are possibly talking about deploying new code and you want it to trigger an application pool restart across multiple web servers, regardless? If that is the case, you could add something like this to the logic of that Publishing.IISReset that you built. It could connect to your various public-facing only instances and execute something like:
appcmd recycle apppool sitecore6
This will obviously restart Sitecore on those boxes and cause all the caches to reset completely, free of doubt.

SignalR and Sitecore

Does anybody have SignalR and Sitecore working together?
There is an issue in Sitecore with hitting the
Application_Start in Sitecore and getting it to kickoff RouteTable.Routes.MapHubs().
I have double checked that I am mapping to my URL/signalR/hubs default on the layouts.
The script blocks for JQuery, JQuery SignalR, and the custom JS are also included.
It pulls everything down fine on the Client Side, except that the URL/signalr/hubs is not mapping.
I have noticed some special handling needed in Sitecore for MVC RouteTables, but these do not directly address the issue currently experienced.
Thanks -
So after so working on this for a bit...
It was the simple thing that makes this work.
You have to add the /signalr and /signalr/hubs to the Ignore Path for SignalR to work with Sitecore.
<setting name="IgnoreUrlPrefixes" value="/sitecore/default.aspx|/trace.axd|.....|/signalr|/signalr/hubs" />
After I got that into place, I was able to see the MapHubs wire up correctly in the Application_Start. It would not consistently hit the break point before since it couldn't provide the URL without trying to get a Sitecore item. Now I see it hit the breakpoint consistently.
Thanks for the responses!
I'm assuming that you are using Sitecore 6.6 as you've mentioned the Sitecore MVC RouteTables. Try using WebActivator to register your hub mappings in the RouteTable. WebActivator gives you options to add this bootstrap code into either a PreApplicationStartMethod or a PostApplicationStartMethod so that you can register your routes and avoid Sitecore's wildcard route taking precedence. I have used this approach to bootstrap Web API routes under Sitecore.
using System;
[assembly: WebActivator.PreApplicationStartMethod(
typeof($rootnamespace$.App_Start.MySuperPackage), "PreStart")]
namespace $rootnamespace$.App_Start {
public static class MySuperPackage {
public static void PreStart() {
// Add your start logic here
}
}
}
An alternative approach would be to add the registration code into a custom pipeline processor and add this processor into the initialize event pipeline in App_Config\Include\Sitecore.Mvc.config
<pipelines>
<!-- Loader -->
<initialize>
<processor type="Sitecore.Mvc.Pipelines.Loader.InitializeGlobalFilters, Sitecore.Mvc"/>
<processor type="Sitecore.Mvc.Pipelines.Loader.InitializeControllerFactory, Sitecore.Mvc"/>
<processor type="Sitecore.Mvc.Pipelines.Loader.InitializeRoutes, Sitecore.Mvc"/>
</initialize>

DotNetNuke : How to do single sing-on to multiple portals

I have a Dotnetnuke environment with multiple portals running at different subdomains (serviceA.company.com, serviceB.company.com). I can allow users the access to each portal by adding rows to UserPortals table, but since DNN uses full domain name in the auth cookie, the users need to log separately to each portal.
I'd like to have the system working so, that you only need to log in once on some of the portals, and wouldn't have to log in on the others. Is this possible?
This is possible by changing the web.config.
It's been a while since I did this, but I think you need to change the following
<httpCookies httpOnlyCookies="true" requireSSL="false" domain="" />
to
<httpCookies httpOnlyCookies="true" requireSSL="false" domain="*.company.com" />
I might be off on the setting, but there is a way to do this in the web.config. Let me know if that works.