基于apache2和NTLM的KSS windows集成认证

17 篇文章 0 订阅

需求: 基于已有系统架构(LAMP)开发出windows集成认证,使得域内用户无需输入用户名和密码即可自动登录系统

原理: 内网用户使用NTLM 通过浏览器取得域用户信息,将信息发给domain controller 验证。 验证成功付给$_SERVER["REMOTE_USER"] 给网站模块用于验证。 外网用户,直接在网站中输入用户名密码,用之前网站的验证方式验证。

解决方案:

1. Apache 模块 AuthenNTLM (应该还有很多种,比如mod_authn_ntlm, mod_authn_kerb, mod_authn_sspi, mod_authn_winbind)

 

http://search.cpan.org/~speeves/Apache-AuthenNTLM-2.10

编译安装
也可以用 aptitude install libapache2-authenntlm-perl 安装
 
2. 编辑apache config配置文件 
KeepAlive On
 
3. 编辑site-enable 里面的000-default文件(Ubuntu系统)
加入
   
    #针对整个网站都起作用 以根目录开始
    <Location />
        # Enable the Authentication module
        PerlAuthenHandler Apache2::AuthenNTLM

        # Do NTLM and basic authentication
        AuthType ntlm,basic

        # The name that should be displayed in the Auth box, if NTLM fails.
        # This will not succeed on our setup where apache is not configured to authenticate on its own
        AuthName XXXX(这个名字可以随便设置)

        # Ask for a valid user.


        require valid-user
        Order Allow,Deny
        Deny from 10 192 172.16.17 (改成你自己需要的ip段)
        Allow from all
        satisfy any
 

        #                    domain      pdc         bdc
        # Domain : Your windows domain
        # pdc : Primary Domain Controller
        # bdc : Backup Domain controller.

        #PerlAddVar ntdomain  "OURDOMAIN  domainpdc domainsdc"
        PerlAddVar ntdomain  "XXX  XXX  XXX" (默认的认证域名   主要的域名控制机  备用的域名控制机 没用备用的可以不写)

        # What should be the default domain
        PerlSetVar defaultdomain XXX (你的默认的认证域名)

        # The user names are in the form "OURDOMAIN\user_name". Let us split it.
        PerlSetVar splitdomainprefix 1

        # Set the debug variables
        PerlSetVar ntlmdebug 0
        PerlSetVar ntlmauthoritative off

 
当然这个也可以写入.htaccess文件。不过写这个文件之前需要在000-default文件中打开AllowOverwrite
当然也可以将以上配置单独写入ntlm.conf文件里,此文件放在 /etc/apache2/conf.d文件夹里,我是这样做的

4. 修改 /etc/hosts 加入这么一条 : ip  主机名(pdc)        ---- 用来ip地址和主机名的对应
   修改 /etc/resolv.conf 加入这么两条:  search domain(就是pdc.domain)             nameserver ip(就是这台pdc的ip地址)

假如没有以上的修改。认证可能会报错,即:Bad/Missing NTLM/Basic Authorization Header for /
 
5. 重启apache2 后就可以使用了。 
 
6. drupal端可以使用webserver authentication模块进行验证  不过需要改写其中部分代码实现header设置,使用户可以logout
 
Note 
  • 浏览器设置

            IE浏览器设置工具--》Internet选项--》安全--》本地Intranet--》站点--》高级 加入网站 IP 这样就不会有密码请求框

             Firefox 可以输入about:config  搜索ntlm 找到trust-ntlm-uris  同样输入网站 ip,这样也不会有密码请求框(多个域名或者IP用逗号分割)

  • 外网密码请求框解决

             使用apache2 的directive 中require deny allow order组合可以达到想要的效果。 详见黄字部分。


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值