【指导】openldap与apache集成

本文介绍如何配置Apache使用OpenLDAP进行用户和群组认证,包括启用ldap模块、设置目录选项及配置OpenLDAP服务器信息等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前提:openldap server已配置好

目标:需要对apache的目录使用openldap用户和群组认证

步骤:

1,启用ldap模块:mod_authnz_ldap 和 mod_ldap

httpd.conf 中默认是注释掉了(如下两行),取消注释就行:

LoadModule authnz_ldap_module libexec/apache2/mod_authnz_ldap.so
LoadModule ldap_module libexec/apache2/mod_ldap.so

2,Options 加上或改为 Indexes,方便直接访问目录

#Options FollowSymLinks Multiviews
Options Indexes

3,对限制路径增加openldap 服务器信息和搜索信息:

特殊配置解释:

1)如果只需要限制到ldap用户就可以了,不想细分,那群组信息就不用配置了,直接用 Require valid-user 即可;

2)群组如果有嵌套,需要加上 AuthLDAPMaxSubGroupDepth,默认参数是0,即不递归查找。

3)AuthLDAPGroupAttributeIsDN,是否把用户输入uid当做群组的cn来查找,默认是on,我这里要求必须是用户登陆,而非群组,所以关掉了。

# Enable the LDAP connection pool and shared
# memory cache. Enable the LDAP cache status
# handler. Requires that mod_ldap and mod_authnz_ldap
# be loaded.

LDAPSharedCacheSize 500000
LDAPCacheEntries 1024
LDAPCacheTTL 600
LDAPOpCacheEntries 1024
LDAPOpCacheTTL 600

<AuthnProviderAlias ldap ldap-test>
    AuthLDAPURL "ldap://address:389/ou=users,dc=test,dc=com?uid?sub?(objectClass=*)"
    AuthLDAPBindDN  "cn=admin,dc=test,dc=com"
    AuthLDAPBindPassword "password"
</AuthnProviderAlias>

<Location "/ldap-status">
    SetHandler ldap-status

    Require host localhost

    Satisfy any
    AuthType Basic
    AuthName "LDAP Protected"
    AuthBasicProvider ldap-test
    Require valid-user
</Location>

<Directory "/Library/WebServer/Documents/test">
    Order Allow,Deny

    Satisfy any

    AuthType Basic
    AuthName "LDAP Protected"
    AuthBasicProvider ldap-test
    #Require valid-user
    AuthLDAPGroupAttribute memberUid
    AuthLDAPGroupAttributeIsDN off
    Require ldap-group cn=group1,ou=groups,dc=test,dc=com
    AuthLDAPMaxSubGroupDepth 3
</Directory>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值