Postgresql - 针对 Active Directory (AD) 的 LDAP 身份验证 - 来自 linux 服务器的问题,而来自 windows 服务器的正常

标签 postgresql authentication active-directory ldap postgresql-9.4

编辑

我在我的 WINDOWS 笔记本电脑上安装的 postgresql 上放置了相同的 pg_hba 规则,它可以工作......所以我更改了标题:如何让我的 linux 服务器像 Windows Pg 服务器一样使用 AD 验证用户?

/编辑

我需要使用我们的 Active Directory 服务器对 postgresql 数据库用户进行身份验证。我已经测试了很多配置,但到目前为止,我找不到为什么无法使用此身份验证方法对 postgresql 用户进行身份验证。

LDAP:事件目录/Postgresql:Postgresql 9.4

这是我使用的 pg_hba 规则:

host myDB myUser localhost ldap ldapserver="192.168.10.1" ldapbasedn="DC=companygroup,DC=priv" ldapbinddn="cn=LDAP - Lecture,ou=Users,ou=Specials Objects,dc=companygroup,dc=priv" ldapbindpasswd="ldapPassWord" ldapsearchattribute="sAMAccountName"

当使用此用户的正确密码登录“myUser”时,我在 postgresql 日志文件中有以下日志:

2015-11-18 10:01:50 CET [25991-1] [unknown]@[unknown] LOG: 00000: connection received: host=127.0.0.1 port=39074
2015-11-18 10:01:50 CET [25991-2] [unknown]@[unknown] LOCATION: BackendInitialize, postmaster.c:4003
2015-11-18 10:01:50 CET [25991-3] myUser@myDB LOG: 00000: could not search LDAP for filter "(sAMAccountName=myUser)" on server "192.168.10.1": Operations error
2015-11-18 10:01:50 CET [25991-4] myUser@myDB LOCATION: CheckLDAPAuth, auth.c:2030
2015-11-18 10:01:50 CET [25991-5] myUser@myDB FATAL: 28000: LDAP authentication failed for user "myUser"
2015-11-18 10:01:50 CET [25991-6] myUser@myDB DETAIL: Connection matched pg_hba.conf line 104: "host myDB myUser localhost ldap ldapserver="192.168.10.1" ldapbasedn="DC=companygroup,DC=priv" ldapbinddn="cn=LDAP - Lecture,ou=Users,ou=Specials Objects,dc=companygroup,dc=priv" ldapbindpasswd="ldapPassWord" ldapsearchattribute="sAMAccountName"

我看到如果我以某种方式更改 ldapbinddn 或 ldapbindpasswd,我会遇到另一个错误,如“无法为 ldapbinddn 执行初始 LDAP 绑定(bind)”...”。所以这些参数应该没问题。

“操作错误”不是很详细,所以我 tcpdump 了身份验证过程,这是我发现的。 Postgres 似乎执行了两个查询:

  • 首先通过搜索属性搜索用户。此操作似乎没问题,因为在 Active Directory 的响应中,我看到了与我的用户相关的信息。

  • 然后执行另一个查询。在这一个上,来自 LDAP 事件目录服务器的真实消息是:

    LdapErr:DSID-0C0906E8,注释:为了执行此操作,必须在连接上完成成功绑定(bind)。数据 0,v1db1

在第二个查询中,我看到 PG 似乎稍微改变了基本搜索 “DC=ForestDnsZones,DC=companygroup,dc=priv”而不是“DC=companygroup,DC=priv”

(我在 tcp 跟踪中看到了它:

LDAPMessage searchRequest(3) "DC=ForestDnsZones,DC=companygroup,dc=priv" wholeSubtree ...

)

当我尝试使用 Windows 软件“ldapbrowser”进行研究时,我能够通过一个简单的过滤器 (sAMAccountName=myUser) 找到我的帐户,搜索 DN DC=companygroup,DC=priv

我的理解正确吗?是否有可能仅仅因为可能更改了 basedn 而导致搜索不成功?还是我错过了其他东西?

最佳答案

根据您的日志,您对 ldapsearchattribute="sAMAccountName"的配置不起作用。

您可以使用 LDAP 工具(例如 LDAPAdmin 或 OpenLDAP)来测试您的过滤器。当您过滤下面的属性时,请确保以上返回结果

(sAMAccountName=myUser)

关于Postgresql - 针对 Active Directory (AD) 的 LDAP 身份验证 - 来自 linux 服务器的问题,而来自 windows 服务器的正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35480299/

相关文章:

ruby-on-rails - 如何将构建在 rails 上的本地 postgresql 数据库推送到 heroku?

php - 在登录系统 PHP 中实现用户帐户

authentication - 匿名用户的访问 token - JWT

java - LDAP 使用 UPN 在 Active Directory 中搜索用户

powershell - 更改CSV电子邮件地址

c# - 连接字符串不适用于 PostgreSQL

oracle - 相当于 postgres 中 Oracle 的 pragma autonomous_transaction

c# - 使用 Azure AD 的用户管理器

c# - 给定一个代表 Active Directory 中用户的 GUID,我将如何使用它来确定专有名称?

postgresql - Fix 必须出现在 GROUP BY 子句中或用于聚合函数中