Apache Centos 8 httpd无法通过LDAP进行身份验证-未返回结果

Apache Centos 8 httpd无法通过LDAP进行身份验证-未返回结果,apache,active-directory,centos8,mod-ldap,Apache,Active Directory,Centos8,Mod Ldap,我正在服务器2019 AD环境中使用Centos 8,通过reamld进行AD集成,登录到机器时效果良好 我建立httpd的目的是希望它也能与广告对话,这样我就可以只限制广告用户访问 我可以从httpd日志中看到LDAP查询正在发送,但它从未返回任何结果 我已使用ldapsearch确认广告连接详细信息,如下所示 ldapsearch -x -LLL -h company.local -D test -w password -b "OU=Users,OU=COMPANY,dc=Company,d

我正在服务器2019 AD环境中使用Centos 8,通过reamld进行AD集成,登录到机器时效果良好

我建立httpd的目的是希望它也能与广告对话,这样我就可以只限制广告用户访问

我可以从httpd日志中看到LDAP查询正在发送,但它从未返回任何结果

我已使用ldapsearch确认广告连接详细信息,如下所示

ldapsearch -x -LLL -h company.local -D test -w password -b "OU=Users,OU=COMPANY,dc=Company,dc=local" -s sub "(ObjectClass=user)" sAMAccountName'
结果:

dn: CN=test,OU=Users,OU=COMPANY,DC=Company,DC=local
sAMAccountName: test
我运行了与apache用户相同的查询,以验证那里没有发生任何有趣的事情。同样的结果-都很好

现在排队等候httpd。 配置如下:

<Directory "/home/test">
AuthType Basic
AuthName "login to continue"
AuthBasicProvider ldap
LDAPReferrals Off
AuthLDAPBindAuthoritative off
AuthLDAPURL "ldap://company-dc-02.company.local:389/OU=Users,OU=COMPANY,DC=Company,DC=local?SAMAaccountName?sub?(objectClass=*)"
AuthLDAPBindDN test
AuthLDAPBindPassword password
require valid-user
</Directory>


AuthType Basic
AuthName“登录以继续”
AuthBasicProvider ldap
LDAPReferrals关闭
AuthLDAPBindOff
AuthLDAPURL“ldap://company-dc-02.company.local:389/OU=Users,OU=COMPANY,DC=COMPANY,DC=local?SAMAaccountName?sub?(objectClass=*)”
AuthLDAPBindDN测试
AuthLDAPBindPassword密码
需要有效用户
我尝试了各种权威、推荐等组合。我总是得到登录提示,但它从未成功进行身份验证。结果总是一样的。httpd日志显示以下内容:

584] mod_authz_core.c(820): [client 192.168.1.171:51660] AH01626: authorization result of <RequireAny>: denied (no authenticated user yet)
[Mon Dec 30 17:54:05.960367 2019] [authnz_ldap:debug] [pid 14207:tid 140664675235584] mod_authnz_ldap.c(523): [client 192.168.1.171:51660] AH01691: auth_ldap authenticate: using URL ldap://company-dc-02.company.local:389/OU=Users,OU=COMPNAY,DC=Company,DC=local?SAMAaccountName?sub?(objectClass=*)
ldap_create
ldap_simple_bind
ldap_sasl_bind
ldap_send_initial_request
ldap_new_connection 1 1 0
ldap_int_open_connection
ldap_connect_to_host: TCP company-dc-02.company.local:389
ldap_new_socket: 27
ldap_prepare_socket: 27
ldap_connect_to_host: Trying 192.168.1.7:389
ldap_pvt_connect: fd: 27 tm: 10 async: 0
ldap_ndelay_on: 27
attempting to connect:
connect errno: 115
ldap_int_poll: fd: 27 tm: 10
ldap_is_sock_ready: 27
ldap_ndelay_off: 27
ldap_pvt_connect: 0
ldap_open_defconn: successful
ldap_send_server_request
ldap_result ld 0x7fef04008b80 msgid 1
wait4msg ld 0x7fef04008b80 msgid 1 (timeout 60000000 usec)
wait4msg continue ld 0x7fef04008b80 msgid 1 all 0
** ld 0x7fef04008b80 Connections:
* host: company-dc-02.company.local  port: 389  (default)
  refcnt: 2  status: Connected
  last used: Mon Dec 30 17:54:05 2019


** ld 0x7fef04008b80 Outstanding Requests:
 * msgid 1,  origid 1, status InProgress
   outstanding referrals 0, parent count 0
  ld 0x7fef04008b80 request count 1 (abandoned 0)
** ld 0x7fef04008b80 Response Queue:
   Empty
  ld 0x7fef04008b80 response count 0
ldap_chkResponseList ld 0x7fef04008b80 msgid 1 all 0
ldap_chkResponseList returns ld 0x7fef04008b80 NULL
ldap_int_select
read1msg: ld 0x7fef04008b80 msgid 1 all 0
read1msg: ld 0x7fef04008b80 msgid 1 message type bind
read1msg: ld 0x7fef04008b80 0 new referrals
read1msg:  mark request completed, ld 0x7fef04008b80 msgid 1
request done: ld 0x7fef04008b80 msgid 1
res_errno: 0, res_error: <>, res_matched: <>
ldap_free_request (origid 1, msgid 1)
ldap_parse_result
ldap_msgfree
ldap_search_ext
put_filter: "(&(objectClass=*)(SAMAaccountName=test))"
put_filter: AND
put_filter_list "(objectClass=*)(SAMAaccountName=test)"
put_filter: "(objectClass=*)"
put_filter: simple
put_simple_filter: "objectClass=*"
put_filter: "(SAMAaccountName=test)"
put_filter: simple
put_simple_filter: "SAMAaccountName=test"
ldap_send_initial_request
ldap_send_server_request
ldap_result ld 0x7fef04008b80 msgid 2
wait4msg ld 0x7fef04008b80 msgid 2 (timeout 60000000 usec)
wait4msg continue ld 0x7fef04008b80 msgid 2 all 1
** ld 0x7fef04008b80 Connections:
* host: company-dc-02.company.local  port: 389  (default)
  refcnt: 2  status: Connected
  last used: Mon Dec 30 17:54:05 2019


** ld 0x7fef04008b80 Outstanding Requests:
 * msgid 2,  origid 2, status InProgress
   outstanding referrals 0, parent count 0
  ld 0x7fef04008b80 request count 1 (abandoned 0)
** ld 0x7fef04008b80 Response Queue:
   Empty
  ld 0x7fef04008b80 response count 0
ldap_chkResponseList ld 0x7fef04008b80 msgid 2 all 1
ldap_chkResponseList returns ld 0x7fef04008b80 NULL
ldap_int_select
read1msg: ld 0x7fef04008b80 msgid 2 all 1
read1msg: ld 0x7fef04008b80 msgid 2 message type search-result
read1msg: ld 0x7fef04008b80 0 new referrals
read1msg:  mark request completed, ld 0x7fef04008b80 msgid 2
request done: ld 0x7fef04008b80 msgid 2
res_errno: 0, res_error: <>, res_matched: <>
ldap_free_request (origid 2, msgid 2)
ldap_parse_result
ldap_msgfree
ldap_err2string
[Mon Dec 30 17:54:05.968539 2019] [authnz_ldap:debug] [pid 14207:tid 140664675235584] mod_authnz_ldap.c(561): [client 192.168.1.171:51660] AH01694: auth_ldap authenticate: user test authentication failed; URI / [User not found][No such object] (not authoritative)
[Mon Dec 30 17:54:05.968558 2019] [auth_basic:error] [pid 14207:tid 140664675235584] [client 192.168.1.171:51660] AH01618: user test not found: /

584]mod_authz_core.c(820):[client 192.168.1.171:51660]AH01626:的授权结果:拒绝(尚未验证用户)
[Mon Dec 30 17:54:05.960367 2019][authnz_ldap:debug][pid 14207:tid 140664675235584]mod_authnz_ldap.c(523):[client 192.168.1.171:51660]AH01691:auth_ldap身份验证:使用URLldap://company-dc-02.company.local:389/OU=Users,OU=COMPNAY,DC=Company,DC=local?samaccountname?sub?(objectClass=*)
ldap_创建
ldap\u简单\u绑定
ldap\u sasl\u绑定
ldap\u发送\u初始\u请求
ldap\u新建\u连接1 1 0
ldap\u int\u open\u连接
ldap_connect_to_主机:TCP company-dc-02.company.local:389
ldap_新_插槽:27
ldap_准备_插槽:27
ldap\u连接到\u主机:尝试192.168.1.7:389
ldap_pvt_connect:fd:27 tm:10异步:0
ldap\u n显示时间:27
正在尝试连接:
连接错误号:115
ldap_int_poll:fd:27 tm:10
ldap_已准备就绪:27
失业人数:27人
ldap_pvt_连接:0
ldap\u open\u defconn:成功
ldap\u发送\u服务器\u请求
ldap_结果ld 0x7fef04008b80 msgid 1
wait4msg ld 0x7fef04008b80 msgid 1(超时60000000 usec)
wait4msg continue ld 0x7fef04008b80 msgid 1所有0
**ld 0x7fef04008b80连接:
*主机:company-dc-02.company.local端口:389(默认)
参考信息:2状态:已连接
最后使用时间:2019年12月30日星期一17:54:05
**ld 0x7fef04008b80未完成的请求:
*msgid 1,origid 1,状态在进行中
未结转介0,父项计数0
ld 0x7fef04008b80请求计数1(0)
**ld 0x7fef04008b80响应队列:
空的
ld 0x7fef04008b80响应计数0
ldap_chkResponseList ld 0x7fef04008b80 msgid 1所有0
ldap_chkResponseList返回ld 0x7fef04008b80 NULL
ldap_int_select
read1msg:ld 0x7fef04008b80 msgid 1所有0
read1msg:ld 0x7fef04008b80 msgid 1消息类型绑定
read1msg:ld 0x7fef04008b80 0新转介
read1msg:标记请求已完成,ld 0x7fef04008b80 msgid 1
请求完成:ld 0x7fef04008b80 msgid 1
res\u errno:0,res\u error:,res\u matched:
ldap_free_请求(origid 1,msgid 1)
ldap_解析_结果
ldap\u msgfree
ldap\u搜索\u扩展
put_过滤器:(&(objectClass=*)(samaccountname=test))“
put_过滤器:和
put_filter_list“(objectClass=*)(samaccountname=test)”
put_过滤器:“(objectClass=*)”
put_过滤器:简单
put_simple_过滤器:“objectClass=*”
put_过滤器:“(SAMAaccountName=test)”
put_过滤器:简单
放置简单过滤器:“samaccountname=test”
ldap\u发送\u初始\u请求
ldap\u发送\u服务器\u请求
ldap_结果ld 0x7fef04008b80 msgid 2
wait4msg ld 0x7fef04008b80 msgid 2(超时60000000 usec)
wait4msg continue ld 0x7fef04008b80 msgid 2所有1
**ld 0x7fef04008b80连接:
*主机:company-dc-02.company.local端口:389(默认)
参考信息:2状态:已连接
最后使用时间:2019年12月30日星期一17:54:05
**ld 0x7fef04008b80未完成的请求:
*msgid 2,origid 2,进程中的状态
未结转介0,父项计数0
ld 0x7fef04008b80请求计数1(0)
**ld 0x7fef04008b80响应队列:
空的
ld 0x7fef04008b80响应计数0
ldap_chkResponseList ld 0x7fef04008b80 msgid 2全部1
ldap_chkResponseList返回ld 0x7fef04008b80 NULL
ldap_int_select
read1msg:ld 0x7fef04008b80 msgid 2所有1
read1msg:ld 0x7fef04008b80 msgid 2消息类型搜索结果
read1msg:ld 0x7fef04008b80 0新转介
read1msg:标记请求已完成,ld 0x7fef04008b80 msgid 2
请求已完成:ld 0x7fef04008b80 msgid 2
res\u errno:0,res\u error:,res\u matched:
ldap_free_请求(origid 2,msgid 2)
ldap_解析_结果
ldap\u msgfree
ldap_err2string
[Mon Dec 30 17:54:05.968539 2019][authnz_ldap:debug][pid 14207:tid 140664675235584]mod_authnz_ldap.c(561):[client 192.168.1.171:51660]AH01694:auth_ldap身份验证:用户测试身份验证失败;URI/[未找到用户][没有此类对象](非权威)
[Mon Dec 30 17:54:05.968558 2019][auth_basic:error][pid 14207:tid 140664675235584][client 192.168.1.171:51660]AH01618:未找到用户测试:/
可能出了什么问题?这可能是一个简单的配置问题,但我没有看到它


感谢

看起来apache中的ldap模块无法处理两个OU条目(尽管openldap返回了正确的结果,并且用户位于指定的OU中)

我将连接字符串更改为

AuthLDAPURL "ldap://company-dc-02.company.local:389/DC=Company,DC=local?SAMAaccountName?sub?(objectClass=user)"
现在它似乎如预期的那样起作用。
希望这能在将来帮助其他人。

您将范围限制为仅限于特定OU中的用户(
OU=users,OU=COMPANY
),那么您在该OU中实际使用的用户帐户也是这样吗?