Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/216.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sitecore预览功能将活动域切换到外部网_Sitecore_Preview - Fatal编程技术网

Sitecore预览功能将活动域切换到外部网

Sitecore预览功能将活动域切换到外部网,sitecore,preview,Sitecore,Preview,在我们基于sitecore的网站中,我们有供sitecore管理员使用的自定义sitecore模块。在每个模块中,我们进行凭证检查,以查看当前用户是否是sitecore用户 using Sitecore.Security.Authentication; if (AuthenticationManager.GetActiveUser().Domain.Name != "sitecore") { //not permitted to use the admin module } 此检查允许

在我们基于sitecore的网站中,我们有供sitecore管理员使用的自定义sitecore模块。在每个模块中,我们进行凭证检查,以查看当前用户是否是sitecore用户

using Sitecore.Security.Authentication;

if (AuthenticationManager.GetActiveUser().Domain.Name != "sitecore")
{
   //not permitted to use the admin module
}
此检查允许管理员使用自定义模块,只要他们登录到sitecore门户。但问题是,每当他们使用sitecore“预览”功能预览某个项目时,当前活动用户就会更改为“extranet\Anonymous”。从这一点开始,我们的自定义模块认为用户不是sitecore管理员,并拒绝访问该模块

如何克服这个问题?我们需要这个安全检查我们的管理模块以及预览功能

提前谢谢


PS.在进一步调查时,在已知问题上看到了这一点

预览应用程序在extranet\anonymous用户的上下文中浏览网站,通过隐藏安全内容等来显示网站访问者的外观/行为。要在模块中执行检查,可以使用
Sitecore.Publishing.PreviewManager.GetShellUser()
Sitecore.Context.PageMode组合使用,以获取您要查找的逻辑。

您使用哪个版本的Sitecore?在页面生命周期的哪个点检查用户的域?我已经在我的项目中检查了它,在预览期间,我得到了管理员用户的
“sitecore”
域。
Sitecore.Context.User.GetDomainName()
是否也为您返回外部网?您确定预览代码中未使用
SecurityDisabler
吗?感谢您试用。我们正在使用Sitecore 6.6.0(版本120918)。我在页面加载中检查域
Sitecore.Context.User.GetDomainName()
也会给出相同的结果。不,我们不在公共网站上使用SecurityDisabler。(我们偶尔在定制代理中使用它)谢谢您的回答<代码>Sitecore.Publishing.PreviewManager.GetShellUser()
仅在使用预览功能后才会填充(否则,即使Sitecore用户已登录,它也将为空)。因此,在我的模块中,为了检查sirecore用户是否已登录,我首先检查
GetDomainName()
,如果失败,我还检查PreviewManager.GetShellUser()。这样我就可以涵盖使用预览功能之前和之后的场景。