下面的信息由红帽公司提供,但是超出了红帽公司在(https://www.redhat.com/support/service/sla/) 公布的服务框架协议和支持流程.按照文本章提供的信息进行的任何配置设置和安装的程序,可能使你的操作系统不再被红帽支持服务所支持.本文章的目的就是提供完成你系统需要的相应的系统,使用本文章的信息的风险在于你自己.
这个方案需要你已经安装了mod_authz_ldap软件包.
本文章假设运行在Apache下的一个特定的目录树的内容在允许客户访问之前被正在验证的用户所保护.在Apache全局/etc/httpd/conf/httpd.conf配置文件中的<Directory>小节部分完成相应配置部分的设置, 这样这个目录(包含下面的子目录)将被验证保护.
配置表明允许在活动目录中的任何有效的域用户在密码提示下输入他们登录的用户名和密码后,才可以访问被保护的目录(和子目录)中的文档.
不需要改变/etc/httpd/conf.d/mod_authz_ldap.conf 配置文件中的任何设置. 这个文件中的行:
LoadModule authz_ldap_module modules/mod_authz_ldap.so
是这个文件中唯一需要去掉注释的行.这样当httpd服务启动时,这个模块就可以被加载.对于被保护的目录的指定的配置设置,将在<Directory>小节被指定.
注意:假设活动目录域名为"example.com".下面的配置是一个例子需要根据你的环境进行修改.
把下面的部分加入到/etc/httpd/conf/httpd.conf:
<Directory "/var/www/html/restricted-area"> AuthType Basic # What the users will see as a "title" of the login prompt: AuthName "Domain Credentials Required" # use plain LDAP authentication: AuthzLDAPMethod ldap # FQDN resolvable hostname (or IP) of the Windows # AD domain controller: AuthzLDAPServer mydomaincontroller.example.com # Distinguished Name (DN) of the user that mod_authz_ldap should # bind to the LDAP server as when searching for the domain user # provided by the web client (Active Directory does not allow # anonymous binds). Note, the cn attribute corresponds to the # "Display Name" field of a user's account in the Active Directory # Users and Computers tool, not their login username: AuthzLDAPBindDN "cn=ldapauthuser,cn=Users,dc=example,dc=com" # the BindDN user's password: AuthzLDAPBindPassword "secretpassword" # LDAP Attribute where the user's domain login username is stored in: AuthzLDAPUserKey sAMAccountName # Base DN to begin searching for users from in the LDAP: AuthzLDAPUserBase "cn=Users,dc=example,dc=com" # Search in sub-containers below the UserBase DN if # necessary (most likely): AuthzLDAPUserScope subtree # Require the username and password provided to be a valid # user in the AD: require valid-user # log verbosity level: AuthzLDAPLogLevel info </Directory>
其他可能存在的情况,例如在.htaccess文件中使用相同的配置,或者在一个<VirtualHost> 小节保护整个虚拟主机。注意在使用.htaccess文件对每个目录验证配置时,这个目录上一级的父目录的配置选项中的AllowOverride选项必须有AuthConfig属性. 对于进一步的信息,请参考Apache的文档或者位于已经安装mod_authz_ldap软件包的红帽企业版Linux上/usr/share/doc/mod_authz_ldap-<version> 中的mod_authz_ldap文档.