Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.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
.net 处理Sitecore 5.3.1中用户的身份验证_.net_Authentication_Sitecore - Fatal编程技术网

.net 处理Sitecore 5.3.1中用户的身份验证

.net 处理Sitecore 5.3.1中用户的身份验证,.net,authentication,sitecore,.net,Authentication,Sitecore,在Sitecore 6+中,我可以使用以下代码检查用户是否已登录: string logonUser = base.Request.ServerVariables["LOGON_USER"]; // check of de gebuiker geautenticeerd is (bijv. door in een andere browser venster in het beheer in te loggen.) if (Sitecore.Context.User.IsAu

在Sitecore 6+中,我可以使用以下代码检查用户是否已登录:

   string logonUser = base.Request.ServerVariables["LOGON_USER"];

   // check of de gebuiker geautenticeerd is (bijv. door in een andere browser venster in het beheer in te loggen.)
   if (Sitecore.Context.User.IsAuthenticated)
   {
      Response.Redirect("/", true);
   }
在Sitecore 5.3.1中。我想在哪个客户上运行类似的功能。我想确定用户是否输入了有效凭据,然后将该用户登录到系统。之后,我希望能够通过检查每次返回网站时的会话变量来确定该用户是否登录。我找不到这样做的方法。
有什么好主意吗?

嗯。。我认为,只要可以在当前上下文中找到用户,就可以假定该用户已登录

所以


可能足够了。

我鼓励您浏览
Sitecore.SecurityModel
命名空间,尤其是
类。它包含您可能会发现有用的方法(
IsLoggedIn
Login
Logout
)。您可以从下载Sitecore API的帮助文件


此外,Sitecore安全模型基于ASP.NET安全性,从版本6开始。在5.x中,用户仍然是相应数据库中的一个项。希望这些信息能对您有所帮助。

我认为这样做应该会奏效:

if (Sitecore.Context.IsLoggedIn) {

} else {
  Response.Redirect("http://" + Request.Url.Host + "/sitecore/login");
}

再次感谢燕。我已经有了解决方案,但你的答案与我的发现最接近:)。
if (Sitecore.Context.IsLoggedIn) {

} else {
  Response.Redirect("http://" + Request.Url.Host + "/sitecore/login");
}