简体   繁体   English

在mod_auth_sspi_1.0.4-2.2.2中禁用登录提示

[英]Disable Login Prompts in mod_auth_sspi_1.0.4-2.2.2

What I'm trying to do: 我正在尝试做什么:

  • Create a home page on our company's intranet that automatically grabs the logged-in Windows username of the person viewing the page without the person being prompted to enter these credentials when the page loads. 在我们公司的Intranet上创建一个主页,该主页自动抓取查看该页面的人的登录Windows用户名, 而不会在页面加载时提示用户输入这些凭据。

  • Currently, I just want it to grab the local username, since it'll be awhile before our IT guys get a domain setup. 目前,我只是想让它获取本地用户名,因为在我们的IT人员获得域名设置之前还需要一段时间。 For example, right now I'd want it to capture the "(PC-Name)\\windows.user.name" without any prompts. 例如,现在我希望它在没有任何提示的情况下捕获“(PC-Name)\\ windows.user.name”。

Environment: 环境:

  • Apache 2.2.21 on Windows 7 x64 (will be on CentOS once it's in production). Windows 7 x64上的Apache 2.2.21(一旦投入生产,将在CentOS上)。

  • PHP 5.3.8 (VC9-ZTS). PHP 5.3.8(VC9-ZTS)。

  • Internet Explorer 9.0.8x and Firefox 6.0.2 (will worry about Chrome later). Internet Explorer 9.0.8x和Firefox 6.0.2(稍后会担心Chrome)。

  • Current test page is just a PHP script calling print_r( $_SERVER ). 当前的测试页面只是一个调用print_r($ _SERVER)的PHP脚本。

  • To keep things simple, the directory I'm testing this on is not a VirtualHost. 为了简单起见,我正在测试它的目录不是VirtualHost。

Steps I've taken thus far: 到目前为止我采取的步骤:

  • Downloaded mod_sspi_1.0.4-2.2.2 from SourceForge and extracted mod_auth_sspi.so to the Apache modules directory. 从SourceForge下载mod_sspi_1.0.4-2.2.2并将mod_auth_sspi.so解压缩到Apache模块目录。

  • Added the module declaration: 添加了模块声明:

    LoadModule sspi_auth_module modules/mod_auth_sspi.so LoadModule sspi_auth_module modules / mod_auth_sspi.so

  • Added the directory definition: 添加了目录定义:

    AllowOverride None Options None Order allow,deny Allow from all AllowOverride无选项无订单允许,拒绝全部允许

     AuthName "My Intranet" AuthType SSPI SSPIAuth On SSPIAuthoritative Off require valid-user 

  • Enabled Integrated Authentication in Firefox by going to about:config and setting network.automatic-ntlm-auth.trusted-uris to the absolute URL path of the PHP script then restarted Firefox. 在Firefox中启用集成身份验证,转到about:config并将network.automatic-ntlm-auth.trusted-uris设置为PHP脚本的绝对URL路径,然后重新启动Firefox。

  • I haven't done the equivalent step in IE yet but I will once I get Firefox working as that's our primary supported browser internally. 我还没有在IE中完成相同的步骤,但我会让Firefox工作,因为这是我们内部支持的主要浏览器。

  • Restarted Apache and attempted to load the test PHP script. 重新启动Apache并尝试加载测试PHP脚本。

The result: 结果:

  • In both IE and Firefox, I get prompted for a username and password before the page loads. 在IE和Firefox中,在页面加载之前我会收到提示输入用户名和密码。 I don't want that prompt. 我不想要那个提示。 I want the username to be detected automatically without a prompt. 我希望在没有提示的情况下自动检测用户名。

Troubleshooting thus far: 到目前为止的疑难

  • I've tried cycling through the various SSPI options, such as authritative on/off and whatnot. 我尝试过循环使用各种SSPI选项,例如authritative on / off和诸如此类的东西。 No effect. 没有效果。

  • Prompt no longer appears if I remove "require valid-user", but then the username is not passed, either (it isn't NULL; simply not set in the array period). 如果我删除“require valid-user”,则不再出现提示,但是也没有传递用户名(它不是NULL;根本不在数组周期中设置)。

  • If I hit "Cancel" on the prompt, I get the standard "Authentication Required" page. 如果我在提示符下点击“取消”,我会得到标准的“需要身份验证”页面。

  • If I enter an invalid username, or the correct username but with the wrong password, the page will load but the username will be "(PC-Name)\\Guest". 如果我输入的用户名无效,或者用户名正确但密码错误,则会加载该页面,但用户名将为“(PC-Name)\\ Guest”。

  • If I enter the correct username/password, then the username is displayed instead of Guest. 如果我输入正确的用户名/密码,则显示用户名而不是Guest。

  • Once I enter a username/password in IE or Firefox, the browser remembers that username on subsequent page loads until I clear the stored passwords cache or restart the browser. 一旦我在IE或Firefox中输入用户名/密码,浏览器会记住后续页面上的用户名,直到我清除存储的密码缓存或重新启动浏览器。

  • I've spent the last 3 or so hours Googling and random guessing. 我花了大约3个小时谷歌搜索和随机猜测。 Zero success. 零成功。 I've found a few isolated forum posts of people asking this question, but either they went unanswered or offered solutions that I've already tried without success. 我发现了一些人们提出这个问题的孤立的论坛帖子,但要么他们没有得到答复,要么提供我已经尝试过但没有成功的解决方案。

Again, what I want is for the page to load, WITHOUT any prompting, and display the currently logged-on Windows username in the $_SERVER array output. 同样,我想要的是加载页面,没有任何提示,并在$ _SERVER数组输出中显示当前登录的Windows用户名。

As far as I can fathom, this is either: A Windows configuration issue, an Apache configuration issue, or a browser configuration issue. 据我所知,这可能是:Windows配置问题,Apache配置问题或浏览器配置问题。 Other than that, I'm fresh out of ideas. 除此之外,我是新鲜的想法。

I would be very grateful for any help you can offer. 我将非常感谢您提供的任何帮助。 Thanks! 谢谢!

--Kris --Kris

Took a couple days, but I eventually figured it out on my own. 花了几天时间,但我最终自己想出来了。 Apparently, the various documents and tutorials out there describing the Firefox about:config setting are wrong. 显然,那些描述Firefox about:config设置的各种文档和教程是错误的。 They claim that the full URI, including protocol prefix, must be included. 他们声称必须包含完整的URI,包括协议前缀。 As it turns out, the exact opposite is true. 事实证明,恰恰相反。

As a random shot in the dark, I tried setting it to just "localhost" (the domain the test server's running on). 作为黑暗中的随机镜头,我尝试将其设置为“localhost”(测试服务器正在运行的域)。 And voila! 瞧! That fixed it! 修好了! "http://localhost", on the other hand, caused it to break. 另一方面,“http:// localhost”导致它破裂。

Once I got it working in Firefox, having verified that the server-side configuration was correct, applying it to IE and Chrome was a cinch. 一旦我在Firefox中工作,验证了服务器端配置是正确的,将它应用到IE和Chrome是一个很好的。 For IE, I just added "http://localhost" (in this case, you do want the protocol prefix) to the "Intranet" zone. 对于IE,我只是将“http:// localhost”(在这种情况下,您确实需要协议前缀)添加到“Intranet”区域。 And since Chrome makes use of the same network settings that IE uses, that step got it working for both browsers. 由于Chrome使用的是IE使用的相同网络设置,因此该步骤适用于两种浏览器。

As far as server-side config goes, it looks like I had that right from the beginning. 就服务器端配置而言,看起来我从一开始就拥有它。 I was able to simplify it a bit, though, so really all you need in the directory block is this: 不过我能够简化它,所以你在目录块中所需要的只是:

AuthName "Whatever you want to call your intranet"
AuthType SSPI
SSPIAuth On

require valid-user

With this setup, if you point to a PHP script doing a print_r( $_SERVER ), the output will contain something like this: 使用此设置,如果您指向执行print_r($ _SERVER)的PHP脚本,则输出将包含以下内容:

[REMOTE_USER] => dev-kdc-pc01\kris.craig
[AUTH_TYPE] => NTLM
[PHP_AUTH_USER] => dev-kdc-pc01\kris.craig

If you want to get rid of the domain part (ie the "dev-kdc-pc01\\"), you can either parse it out in PHP or add this line to your SSPI stuff in the directory block in httpd.conf mentioned above: 如果你想摆脱域部分(即“dev-kdc-pc01 \\”),你可以用PHP解析它或者将这一行添加到上面提到的httpd.conf目录块中的SSPI内容:

SSPIOmitDomain On

Please note that I've only tested this on a Windows system where the Apache webserver was running on localhost. 请注意,我只在Apache网络服务器在localhost上运行的Windows系统上进行了测试。 I have not yet tested it in a situation where the Apache server is running on Linux, though that shouldn't have any impact on the results since the server is just accepting whatever the browser sends it. 我还没有在Apache服务器在Linux上运行的情况下测试它,尽管这不应该对结果产生任何影响,因为服务器只是接受浏览器发送的任何内容。 This also requires that the client be running Windows or some other SSPI-compatible environment. 这还要求客户端运行Windows或其他一些与SSPI兼容的环境。 I haven't yet determined how to make this work for our Mac-using employees. 我还没有确定如何为我们的Mac使用员工做这项工作。

Also note that I've successfully tested this on a network that does not currently have a domain configured. 另请注意,我已经在当前配置域的网络上成功测试了此项。 According to articles published elsewhere, the behavior should be identical on a workstation that is a member of a domain. 根据其他地方发布的文章,在作为域成员的工作站上,行为应该是相同的。

I hope this helps! 我希望这有帮助! Thanks! 谢谢!

This might be a partial answer. 这可能是部分答案。

BOOL WINAPI GetUserName(
  __out    LPTSTR lpBuffer,
  __inout  LPDWORD lpnSize
);

http://msdn.microsoft.com/en-us/library/windows/desktop/ms724432%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/windows/desktop/ms724432%28v=vs.85%29.aspx

It looks like you can fetch system information using this, the other half might be automating it using PERL or Python to scrape the information, then post it to PHP. 看起来您可以使用此方法获取系统信息,另一半可能是使用PERL或Python自动化它来获取信息,然后将其发布到PHP。

Here's the outline on fetching SysInfo in Windows. 这是在Windows中获取SysInfo的大纲。

http://msdn.microsoft.com/en-us/library/windows/desktop/ms724426%28v=vs.85%29.aspx http://msdn.microsoft.com/en-us/library/windows/desktop/ms724426%28v=vs.85%29.aspx

Honestly this is a pretty easy thing to do with PECL/PAM if you are using Linux. 老实说,如果您使用的是Linux,那么使用PECL / PAM非常容易。

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

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