简体   繁体   English

具有LDAP的Sitecore-以编程方式进行身份验证

[英]Sitecore with LDAP - authenticate programmatically

I am creating an app inside Sitecore and I only want it available to the users via a direct URL. 我正在Sitecore内创建一个应用程序,我只希望它可以通过直接URL提供给用户。 I want the authentication to occur against LDAP. 我希望针对LDAP进行身份验证。 I tried going directly to the app and let it redirect to the auto login page and redirect me to the app but it didn't do it. 我尝试直接转到该应用程序,然后将其重定向到自动登录页面,然后将我重定向到该应用程序,但没有这样做。 Instead it took me to the Sitecore login page. 相反,它带我到了Sitecore登录页面。

I'm wondering if it is possible for me to write some code to auto authenticate a LDAP user and redirect to the app page. 我想知道是否可以编写一些代码来自动认证LDAP用户并重定向到应用程序页面。 I want the user to never see the login page or Sitecore desktop or any of the Sitecore screens other than that one app. 我希望用户永远不要看到登录页面或Sitecore桌面或该应用程序以外的任何Sitecore屏幕。

Thanks 谢谢

We accomplished something similar by combining the AD module with some custom code in the Global.asax. 通过将AD模块与Global.asax中的一些自定义代码结合起来,我们完成了类似的工作。 Below are a few lines that might be helpful. 以下几行可能会有所帮助。 You'll likely need a bunch of logic to check if the user is already logged in, and whether they are accessing a path you want to auto-login for. 您可能需要一堆逻辑来检查用户是否已经登录,以及他们是否正在访问您要自动登录的路径。

NOTE : Make sure windows authentication is enabled in IIS. 注意 :确保在IIS中启用了Windows身份验证。

protected void Session_Start(object sender, EventArgs e){
        // The user from Windows Authentication in IIS
        var user = Context.Request.ServerVariables["LOGON_USER"];
        //Log the user in
        bool success = Sitecore.Security.Authentication.AuthenticationManager.Provider.Login(user, false);

}

You'll note that the sample I provided goes directly to the provider. 您会注意到,我提供的示例直接转到提供者。 You can also call Login at the AuthenticationManager class, and this will also do some other work with cache. 您还可以在AuthenticationManager类上调用Login,这还将对缓存进行其他处理。 In my case, I was trying to bypass that. 就我而言,我试图绕过它。

UPDATE (2017-06-29): In newer versions of Sitecore it is not recommended to make changes to the Global.asax. 更新(2017-06-29):在较新版本的Sitecore中,不建议对Global.asax进行更改。 Unfortunately, there is no equivalent pipeline in Sitecore. 不幸的是,Sitecore中没有等效的管道。 You can attempt to use httpRequestBegin (where the UserResolver processor is) or httpRequestProcessed, but these will fire on every single request. 您可以尝试使用httpRequestBegin(UserResolver处理器所在的位置)或httpRequestProcessed,但是它们会在每个单个请求上触发。

One alternative (credit to @Mark Cassidy on SlackChat) is to use the Initialize pipeline and in that processor register to the session start event. 一种替代方法(在SlackChat上提供@Mark Cassidy的信用)是使用Initialize管道,然后在该处理器中注册会话开始事件。

It is possible yes, a quick Google search turned up these: 可能是的,通过Google的快速搜索可以找到以下内容:

http://www.nehemiahj.com/2013/01/how-to-enable-single-sign-on-in-sitecore.html http://www.nehemiahj.com/2013/01/how-to-enable-single-sign-on-in-sitecore.html

based on the AD Module from Sitecore 基于Sitecore的AD模块

http://sdn.sitecore.net/SDN5/Products/AD/AD11/Documentation.aspx http://sdn.sitecore.net/SDN5/Products/AD/AD11/Documentation.aspx

That should give you a good place to start from. 那应该给您一个很好的起点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM