我正在使用迁移工具从Sitecore 6.6升级到9。在一页上,我们有一个下拉菜单,其中包含3个用于正常,编辑和预览模式的选项。当用户从普通模式切换到编辑/预览模式时,我们有一个自定义管道,该管道将自动将用户从Extranet域登录到Sitecore域帐户,从而跳过Sitecore登录页面,并带用户进入编辑/预览模式。在模拟用户时也会使用此管道。
这在Sitecore 6.6中都可以正常工作。
但是这在Sitecore 9中不起作用。使用此管道,如果我进入预览模式,则会出现此错误: 所提供的防伪令牌是针对用户“ sitecore \ 123456”的,但当前用户是“ extranet \ 123456”
在Sitecore 9实例中没有管道的情况下,该页面将重定向到sitecore登录页面,当我使用Sitecore域帐户登录时,不会出现任何错误。
<httpRequestBegin>
<processor type="Sitecore.Pipelines.PreprocessRequest.CheckIgnoreFlag, Sitecore.Kernel" />
<processor type="Sitecore.Pipelines.HttpRequest.EnsureServerUrl, Sitecore.Kernel" />
<processor type="Sitecore.Pipelines.HttpRequest.StartMeasurements, Sitecore.Kernel" />
<processor type="Sitecore.Pipelines.HttpRequest.IgnoreList, Sitecore.Kernel">
<prefixes hint="list">
</prefixes>
</processor>
<processor type="Sitecore.Pipelines.HttpRequest.SiteResolver, Sitecore.Kernel" />
<processor type="Sitecore.Pipelines.HttpRequest.UserResolver, Sitecore.Kernel" />
<processor type="Sitecore.Pipelines.HttpRequest.DatabaseResolver, Sitecore.Kernel" />
<processor type="Sitecore.Pipelines.HttpRequest.BeginDiagnostics, Sitecore.Kernel" />
<processor type="Sitecore.Pipelines.HttpRequest.DeviceResolver, Sitecore.Kernel" />
<processor type="Sitecore.Pipelines.HttpRequest.LanguageResolver, Sitecore.Kernel" />
<processor type="Sitecore.Pipelines.HttpRequest.CustomHandlers, Sitecore.Kernel" />
<processor type="Sitecore.Pipelines.HttpRequest.QueryStringResolver, Sitecore.Kernel" />
<processor type="Sitecore.Pipelines.HttpRequest.DynamicLinkResolver, Sitecore.Kernel" />
<processor type="Sitecore.Pipelines.HttpRequest.AliasResolver, Sitecore.Kernel" />
<processor type="Sitecore.Pipelines.HttpRequest.DefaultResolver, Sitecore.Kernel" />
<processor type="Sitecore.Pipelines.HttpRequest.FileResolver, Sitecore.Kernel" />
<processor type="Sitecore.Pipelines.HttpRequest.ItemResolver, Sitecore.Kernel" />
<processor type="Sitecore.Pipelines.HttpRequest.DeviceSimulatorResolver, Sitecore.Kernel" />
<processor type="Sitecore.Pipelines.HttpRequest.LayoutResolver, Sitecore.Kernel" />
<processor type="Test.Pipelines.LoginOverride, Test" />
<processor type="Sitecore.Pipelines.HttpRequest.ExecuteRequest, Sitecore.Kernel" />
</httpRequestBegin>
TestPipeline代码
if (Context.Domain.Name == SITECORE )
{
string username = SITECORE + "\\" + Context.User.LocalName;
username = username.ToLower();
util.WebUtil.SetImpersonatorEmployeeNumber(string.Empty);
if (!string.IsNullOrEmpty(username) && !username.Contains("anonymous") && Sitecore.Security.Accounts.User.Exists(username)
&& !Context.RawUrl.ToLower().Contains("xhtmlvalidator") && !Context.RawUrl.ToLower().Contains("analytics") && username != Context.User.Name.ToLower())
{
AuthenticationManager.Login(username);
}
else if (Context.IsLoggedIn && Context.RawUrl.ToLower() == "/sitecore/shell/default.aspx" && !Sitecore.Security.Accounts.User.Exists(username))
{
Context.Logout();
}
}
Sitecore.config中的管道(测试)放置在布局解析器之后。这是拦截进程并自动登录或模拟用户的正确位置吗?
任何建议都值得赞赏!
谢谢!