设为首页 收藏本站
查看: 701|回复: 0

[经验分享] Single Sign-On with Apache and Active Directory – Part 1

[复制链接]

尚未签到

发表于 2017-1-11 06:34:46 | 显示全部楼层 |阅读模式
  This HowTo will describe how to setup single sign-on authentication
with Apache and Microsoft Active Directory.  Most of you are probably
aware that there is no default/built-in support for automatically
authenticating to an Apache web server using the NTLM header information
passed from the web browser (in most cases Microsoft Internet Explorer)
to the Web Server.  Microsoft IIS of course supports this out of the
box but who wants to use IIS?  There are as I have found 3 major
solutions for achieving this and I will outline which I picked and why.

  First I’ll start by explaining which solution I selected and why.  
There are 3 major solutions for this which are mod_ntlm, mod_auth_kerb
and Apache2:AuthenNTLM.  I have chosen Apache2:AuthenNTLM.  Now as for
the why…I bypassed mod_auth_kerb instantly after reading that it
required a working winbind setup.  Keep in mind that I am looking for an
easy quick setup, and configuring winbind first does not fall into that
realm of a quick and easy setup.  Next I tried mod_ntlm which seemed to
be very easy to setup and worked well.  But there was one catch…If the
browser did not send the NTLM information or correct NTLM information1
the user had to login with the username in the form of DOMAIN\username.
In my experience with applications already in place they did not
require this form of DOMAIN\username.  This could be resolved if you
could specify the default domain in mod_ntlm which you cannot.  Reading
the documentation for Apache2:AuthenNTLM you could specify the default
domain as well as many other options that are not available in mod_ntlm.
Configuration proved to be a little tricky, but if it weren’t I
wouldn’t be writing this HowTo.  Now as you may have noticed from the
naming syntax of Apache2:AuthenNTLM that it is indeed a perl module.  
Now as we are using Apache2:AuthenNTLM it will require mod_perl2 which
is not included with CentOS4 or RHEL4.
  Now for the HowTo:
  1) Start by installing Apache and mod_perl by issuing the following commands:

  shell> yum install httpd

shell> wget http://sivel.net/repo/i386/mod_perl-2.0.3-1.el4.sn.i386.rpm

shell> rpm -Uvh mod_perl-2.0.3-1.el4.sn.i386.rpm

  2) Next we need to install the Apache2:AuthenNTLM module

  shell> wget http://sivel.net/repo/i386/perl-Apache2-AuthenNTLM-0.02-1.el4.sn.i386.rpm

shell> rpm -Uvh perl-Apache2-AuthenNTLM-0.02-1.el4.sn.i386.rpm

  3) Now we need to configure Apache to use Apache2:AuthenNTLM

  shell> cd /etc/httpd/conf.d

shell> touch ntlm.conf

shell> vi ntlm.conf



  • Add the following information:

<location

/
directory
>
# Change this to the directory you wish to protect.  Can be /
PerlAuthenHandler Apache2::AuthenNTLM
AuthType ntlm,basic
AuthName Basic
require valid-user
#                    domain  pdc  bdc
PerlAddVar ntdomain "DOMAIN  dc1  dc2" # Change DOMAIN to the netbios name of your domain.  Change dc1 and dc2 to the hostnames of the domain controllers for your domain.  dc2 is not required if your setup does not have a dc2.
PerlSetVar defaultdomain DOMAIN # Change DOMAIN to the netbios name of your domain
PerlSetVar splitdomainprefix 1

</location>


  shell> vi /etc/httpd/conf/httpd.conf

Find ‘KeepAlive Off’ and change it to ‘KeepAlive On’

  4) Now we need to modify /etc/resolv.conf

  shell> vi /etc/resolv.conf



  • We need to make sure that it looks like the following:

  search domain.lan

nameserver 10.0.0.1

nameserver 10.0.0.2



  • Where domain.lan is your Active Directory domain name and the
    nameservers are the name servers for your Active Directory (usually the
    domain controllers)
  5) Let’s start Apache

  shell> /etc/init.d/httpd start

  6) Let’s setup a simple test page that will utilize the server environment variable that AuthenNTLM sets.

  shell> cd /path/set/in/step/3

shell> touch index.php

shell> vi index.php



  • Insert the following information:
  <?
php

echo
"You have logged in as <b>"

.
$_SERVER
[
'REMOTE_USER'
]

.

"</b>;"
;


?>




  • If you do not see your username then you don’t have something in
    step 3 setup correctly.  If you get a login prompt check the footnotes
    below.
  Part 2



  Footnotes



1. Getting a login prompt can be caused by using Firefox with the
default configuration, not being logged on in the domain that you are
attempting to authenticate against, or not having the site listed in the
Local Intranet security zone in Internet Explorer.  Or worst of all you
could have mis configured something in step 3.  You can turn on debug
information by adding ‘PerlSetVar ntlmdebug 2′ to step 3.  Debugging
will log to /var/log/httpd/error_log.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-326618-1-1.html 上篇帖子: Apache Hive入门3–Hive与HBase的整合 下篇帖子: Weblogic加Apache的负载均衡以及群集配置
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表