【问题标题】:Symfony3 LDAP authentication bind credentialsSymfony3 LDAP 身份验证绑定凭据
【发布时间】:2017-02-23 10:42:26
【问题描述】:

我正在为 symfony 项目中的 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 上的参考资料也没有显示如何提供它们。

谢谢!

【问题讨论】:

    标签: php authentication ldap symfony


    【解决方案1】:

    绑定凭据是用户在表单中提交的凭据。

    正如你在这里看到的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 服务器,我可以使用这个用户执行查询。这个项目的基本要求是有两个用户目录。 (至少我想我必须用两个用户目录来解决它)
    • 那么你不能使用form_login_ldap。你应该实现你自己的系统。看看这个symfony.com/doc/current/security/…
    • 好的 - 是的,我阅读和测试的越多,我就越意识到我必须编写自己的身份验证器。感谢您的支持;)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-27
    • 1970-01-01
    相关资源
    最近更新 更多