【发布时间】:2016-03-25 17:52:46
【问题描述】:
我正在尝试在 Symfony 2.8 中使用新的 LdapUserProvider。我相信我已经配置了一切per the docs。
我的用户可以成功进行身份验证,然后被重定向到安全页面。重定向之后是问题开始的地方。 Symfony 尝试以经过身份验证的用户身份绑定,但密码为空,被 open ldap 拒绝。
这里是相关的日志条目和配置值。
配置:
services:
app.ldap:
class: Symfony\Component\Ldap\LdapClient
arguments: [ "localhost" ]
安全性:
security:
firewalls:
restricted_area:
provider: app_users
form_login_ldap:
service: app.ldap
dn_string: "uid={username},DC=mydomain,DC=net"
check_path: login_check
login_path: login
providers:
app_users:
ldap:
service: app.ldap
base_dn: dc=mydomain,dc=net
search_dn: cn=Manager,DC=mydomain,DC=net
search_password: secretPassword
filter: "(&(aptAccountEnabled=1)(ObjectClass=aptAccount)(uid={username}))"
default_roles: ROLE_USER
还有日志文件:
[2015-12-18 13:55:11] request.INFO: Matched route "login_check". {"route_parameters":{"_route":"login_check"},"request_uri":"http://ancdev.admin.aptalaska.net/~dmorphis/Portal/web/app_dev.php/Login/Verify"} []
[2015-12-18 13:55:11] security.DEBUG: Read existing security token from the session. {"key":"_security_restricted_area"} []
[2015-12-18 13:55:11] security.DEBUG: User was reloaded from a user provider. {"username":"dan.smartrg","provider":"Symfony\\Component\\Security\\Core\\User\\LdapUserProvider"} []
[2015-12-18 13:55:26] security.INFO: User has been authenticated successfully. {"username":"dan.smartrg"} []
<snip>
[2015-12-18 13:55:26] security.DEBUG: Stored the security token in the session. {"key":"_security_restricted_area"} []
<snip>
[2015-12-18 13:55:27] request.INFO: Matched route "home.index". {"route_parameters":{"_controller":"Apt\\PortalBundle\\Controller\\DefaultController::indexAction","_route":"home.index"},"request_uri":"http://ancdev.admin.aptalaska.net/~dmorphis/Portal/web/app_dev.php/"} []
[2015-12-18 13:55:28] security.DEBUG: Read existing security token from the session. {"key":"_security_restricted_area"} []
[2015-12-18 13:55:28] security.DEBUG: User was reloaded from a user provider. {"username":"dan.smartrg","provider":"Symfony\\Component\\Security\\Core\\User\\LdapUserProvider"} []
[2015-12-18 13:56:15] php.DEBUG: ldap_bind(): Unable to bind to server: Server is unwilling to perform {"type":2,"file":"/home/dmorphis/public_html/Portal/vendor/symfony/symfony/src/Symfony/Component/Ldap/LdapClient.php","line":73,"level":28928} []
[2015-12-18 13:56:15] app.ERROR: Bad credentials. [{"file":"/home/dmorphis/public_html/Portal/app/cache/dev/classes.php","line":2697,"function":"authenticate","class":"Symfony\\Component\\Security\\Core\\Authentication\\Provider\\UserAuthenticationProvide <truncated>
[2015-12-18 13:56:15] security.INFO: An AuthenticationException was thrown; redirecting to authentication entry point.
【问题讨论】:
-
文档说要使用 Symfony\Component\Security\Ldap\Ldap,但文档是错误的。实际的类是 Symfony\Component\Ldap\LdapClient
-
这看起来很严重。也许在 GitHub 上打开一个关于它的问题? (那里的知名度更高)
标签: php symfony authentication symfony-2.8