Symfony3 LDAP身份验证绑定凭据
问题描述:
我在symfony项目中苦苦寻找ldap身份验证。Symfony3 LDAP身份验证绑定凭据
我的服务是这样的:
ldap:
class: Symfony\Component\Ldap\Ldap
factory: ['Symfony\Component\Ldap\Ldap', 'create']
arguments:
- 'ext_ldap'
- host: 'ldap.example.com'
绑定和示例查询到LDAP服务器都做工精细:
$ldap = $this->get('ldap');
$ldap->bind('binduser', 'bindpw');
$query = $ldap->query('OU=MyBusiness,DC=example,DC=com', 'sAMAccountName=xxx');
现在我想对LDAP服务器进行身份验证。我使用了http://symfony.com/doc/current/security/ldap.html#configuration-example-for-form-login的防火墙设置。 但是,最重要的问题是将绑定凭据放在哪里?这里
相应的日志条目是:
php.DEBUG: Warning: ldap_bind(): Unable to bind to server: Invalid credentials
所以这是很明显缺少了什么,但我无法找到一个方法来提供绑定凭证到form_login_ldap。
关于http://symfony.com/doc/current/reference/configuration/security.html的参考文献也未显示如何提供它们。
谢谢!
答
绑定凭证是那些从窗体中的用户提交的凭证。
正如你在这里看到的http://symfony.com/doc/current/security/ldap.html#configuration-example-for-form-login
service: ldap
dn_string: 'uid={username},dc=example,dc=com'
你只需要指定dn_string和用户将其凭据调用的ldap_bind来验证。
您的用户(您在表单中输入的用户)是否有权使用ldap_bind? 您在LDAP用户提供程序的配置中输入的内容(如果有的话)对此目的而言毫无用处。
的登录表单是一个传统的登录表单可以做以下这http://symfony.com/doc/current/security/form_login_setup.html
嗨,没有将登录表单中输入他们的凭据不允许用户绑定到LDAP服务器。 有一个特定的用户可以连接到ldap服务器,并且可以通过此用户执行查询。 这个项目的基本要求是有两个用户目录。 (至少我想我必须解决它与两个用户目录) – marcus
那么你不能使用'form_login_ldap'。你应该实现你自己的系统。看看这个http://symfony.com/doc/current/security/custom_password_authenticator.html – ste
好吧 - 是的,我阅读和测试得越多,我越发现我必须编写自己的认证器。 感谢您的支持;) – marcus