【问题标题】:Symfony 2.8 LDAP authenticationSymfony 2.8 LDAP 身份验证
【发布时间】:2017-03-08 15:14:32
【问题描述】:

我正在尝试在 Symfony 2.8 中使用 LDAP 身份验证,但我无法登录。

我根据文档 (ldap) 配置了所有内容,尝试了很多不同的方法,但没有任何解决方法。 我可以查询我的 ldap 服务器,如果我拼错密码,登录表单会正确显示“无效凭据”,但如果我输入正确的用户和密码,似乎什么也没有发生。我总是卡在没有会话的登录页面。

我一直在使用 xdebug symfony ldap 类和 Symfony\Component\Security\Core\Use\LdapuserProvider 进行调试,我发现我的用户已从 LDAP 正确返回,Symfony 使用返回的信息创建了一个用户,但在end 我还没有登录,LdapProvider 也没有创​​建会话。

有人成功配置了 ldap 吗? 有谁知道是否需要创建用户实体类或配置文档未涵盖的内容?

这些是我当前的配置:

services.yml:

ldap:
    class: Symfony\Component\Ldap\LdapClient
    arguments:
        - "my ip"           # host
        - 389               # port
        - 3                 # version
        - false             # SSL
        - false             # TLS

安全性:

providers:
    in_memory:
        memory: ~

    my_ldap:
        ldap:
            service:         ldap
            base_dn:         ou=MyOU,dc=myDomain,dc=lan
            search_dn:       "admin-user@myDomain.lan"
            search_password: MyPassword
            filter:          ({uid_key}={username})
            default_roles:   ROLE_USER
            uid_key:         sAMAccountName

firewalls:
    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false

    main:
        pattern: ^/
        provider: my_ldap
        anonymous: ~

        form_login_ldap:
            provider:    my_ldap
            login_path:  login
            check_path:  login
            service:     ldap
            dn_string:   "{username}@mydomain.lan"

access_control:
    - { path: ^/login$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/, roles: [IS_AUTHENTICATED_FULLY, IS_AUTHENTICATED_REMEMBERED] }

encoders:
    AppBundle\Entity\User: bcrypt

日志:

[2017-03-08 15:48:24] request.INFO: Matched route "login". {"route_parameters":{"_controller":"AppBundle\\Controller\\UserController::loginAction","_route":"login"},"request_uri":"http://noc/app_dev.php/login"} []
[2017-03-08 15:48:24] php.INFO: The Symfony\Component\Ldap\LdapClient class is deprecated since version 3.1 and will be removed in 4.0. Use the Ldap class directly instead. {"type":16384,"file":"/var/www/html/vendor/symfony/ldap/LdapClient.php","line":14,"level":28928,"stack":[{"function":"handleError","class":"Symfony\\Component\\Debug\\ErrorHandler","type":"->"},{"file":"/var/www/html/vendor/symfony/ldap/LdapClient.php","line":14,"function":"trigger_error"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/Debug/DebugClassLoader.php","line":169,"args":["/var/www/html/vendor/symfony/ldap/LdapClient.php"],"function":"require_once"},{"function":"loadClass","class":"Symfony\\Component\\Debug\\DebugClassLoader","type":"->"},{"file":"/var/www/html/app/cache/dev/appDevDebugProjectContainer.php","line":1534,"function":"spl_autoload_call"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php","line":314,"function":"getLdapService","class":"appDevDebugProjectContainer","type":"->"},{"file":"/var/www/html/app/cache/dev/appDevDebugProjectContainer.php","line":3612,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php","line":314,"function":"getSecurity_User_Provider_Concrete_MyLdapService","class":"appDevDebugProjectContainer","type":"->"},{"file":"/var/www/html/app/cache/dev/appDevDebugProjectContainer.php","line":3540,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php","line":314,"function":"getSecurity_Authentication_ManagerService","class":"appDevDebugProjectContainer","type":"->"},{"file":"/var/www/html/app/cache/dev/appDevDebugProjectContainer.php","line":2131,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php","line":314,"function":"getSecurity_Firewall_Map_Context_MainService","class":"appDevDebugProjectContainer","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php","line":40,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/Security/Http/Firewall.php","line":61,"function":"getListeners","class":"Symfony\\Bundle\\SecurityBundle\\Security\\FirewallMap","type":"->"},{"function":"onKernelRequest","class":"Symfony\\Component\\Security\\Http\\Firewall","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php","line":61,"function":"call_user_func"},{"function":"__invoke","class":"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php","line":184,"function":"call_user_func"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php","line":46,"function":"doDispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php","line":140,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php","line":125,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php","line":64,"function":"handleRaw","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php","line":69,"function":"handle","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php","line":185,"function":"handle","class":"Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel","type":"->"},{"file":"/var/www/html/web/app_dev.php","line":28,"function":"handle","class":"Symfony\\Component\\HttpKernel\\Kernel","type":"->"}]} []
[2017-03-08 15:48:24] php.INFO: The "find" method is deprecated since version 3.1 and will be removed in 4.0. Use the "query" method instead. {"type":16384,"file":"/var/www/html/vendor/symfony/ldap/LdapClient.php","line":63,"level":28928,"stack":[{"function":"handleError","class":"Symfony\\Component\\Debug\\ErrorHandler","type":"->"},{"file":"/var/www/html/vendor/symfony/ldap/LdapClient.php","line":63,"function":"trigger_error"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/Security/Core/User/LdapUserProvider.php","line":62,"function":"find","class":"Symfony\\Component\\Ldap\\LdapClient","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/LdapBindAuthenticationProvider.php","line":65,"function":"loadUserByUsername","class":"Symfony\\Component\\Security\\Core\\User\\LdapUserProvider","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/Provider/UserAuthenticationProvider.php","line":70,"function":"retrieveUser","class":"Symfony\\Component\\Security\\Core\\Authentication\\Provider\\LdapBindAuthenticationProvider","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/Security/Core/Authentication/AuthenticationProviderManager.php","line":80,"function":"authenticate","class":"Symfony\\Component\\Security\\Core\\Authentication\\Provider\\UserAuthenticationProvider","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php","line":112,"function":"authenticate","class":"Symfony\\Component\\Security\\Core\\Authentication\\AuthenticationProviderManager","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php","line":146,"function":"attemptAuthentication","class":"Symfony\\Component\\Security\\Http\\Firewall\\UsernamePasswordFormAuthenticationListener","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/Security/Http/Firewall.php","line":69,"function":"handle","class":"Symfony\\Component\\Security\\Http\\Firewall\\AbstractAuthenticationListener","type":"->"},{"function":"onKernelRequest","class":"Symfony\\Component\\Security\\Http\\Firewall","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php","line":61,"function":"call_user_func"},{"function":"__invoke","class":"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php","line":184,"function":"call_user_func"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php","line":46,"function":"doDispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php","line":140,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php","line":125,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php","line":64,"function":"handleRaw","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php","line":69,"function":"handle","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php","line":185,"function":"handle","class":"Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel","type":"->"},{"file":"/var/www/html/web/app_dev.php","line":28,"function":"handle","class":"Symfony\\Component\\HttpKernel\\Kernel","type":"->"}]} []
[2017-03-08 15:48:24] security.INFO: User has been authenticated successfully. {"username":"ddias"} []
[2017-03-08 15:48:24] security.DEBUG: Stored the security token in the session. {"key":"_security_main"} []
[2017-03-08 15:48:24] request.INFO: Matched route "homepage". {"route_parameters":{"_controller":"AppBundle\\Controller\\DefaultController::indexAction","_route":"homepage"},"request_uri":"http://noc/app_dev.php/"} []
[2017-03-08 15:48:24] php.INFO: The Symfony\Component\Ldap\LdapClient class is deprecated since version 3.1 and will be removed in 4.0. Use the Ldap class directly instead. {"type":16384,"file":"/var/www/html/vendor/symfony/ldap/LdapClient.php","line":14,"level":28928,"stack":[{"function":"handleError","class":"Symfony\\Component\\Debug\\ErrorHandler","type":"->"},{"file":"/var/www/html/vendor/symfony/ldap/LdapClient.php","line":14,"function":"trigger_error"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/Debug/DebugClassLoader.php","line":169,"args":["/var/www/html/vendor/symfony/ldap/LdapClient.php"],"function":"require_once"},{"function":"loadClass","class":"Symfony\\Component\\Debug\\DebugClassLoader","type":"->"},{"file":"/var/www/html/app/cache/dev/appDevDebugProjectContainer.php","line":1534,"function":"spl_autoload_call"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php","line":314,"function":"getLdapService","class":"appDevDebugProjectContainer","type":"->"},{"file":"/var/www/html/app/cache/dev/appDevDebugProjectContainer.php","line":3612,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php","line":314,"function":"getSecurity_User_Provider_Concrete_MyLdapService","class":"appDevDebugProjectContainer","type":"->"},{"file":"/var/www/html/app/cache/dev/appDevDebugProjectContainer.php","line":3540,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php","line":314,"function":"getSecurity_Authentication_ManagerService","class":"appDevDebugProjectContainer","type":"->"},{"file":"/var/www/html/app/cache/dev/appDevDebugProjectContainer.php","line":2131,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php","line":314,"function":"getSecurity_Firewall_Map_Context_MainService","class":"appDevDebugProjectContainer","type":"->"},{"file":"/var/www/html/app/cache/dev/classes.php","line":2986,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->"},{"file":"/var/www/html/app/cache/dev/classes.php","line":2628,"function":"getListeners","class":"Symfony\\Bundle\\SecurityBundle\\Security\\FirewallMap","type":"->"},{"function":"onKernelRequest","class":"Symfony\\Component\\Security\\Http\\Firewall","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php","line":61,"function":"call_user_func"},{"function":"__invoke","class":"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener","type":"->"},{"file":"/var/www/html/app/cache/dev/classes.php","line":1863,"function":"call_user_func"},{"file":"/var/www/html/app/cache/dev/classes.php","line":1778,"function":"doDispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php","line":140,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php","line":125,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php","line":64,"function":"handleRaw","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php","line":69,"function":"handle","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php","line":185,"function":"handle","class":"Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel","type":"->"},{"file":"/var/www/html/web/app_dev.php","line":28,"function":"handle","class":"Symfony\\Component\\HttpKernel\\Kernel","type":"->"}]} []
[2017-03-08 15:48:24] security.DEBUG: Read existing security token from the session. {"key":"_security_main"} []
[2017-03-08 15:48:24] security.WARNING: Username could not be found in the selected user provider. {"username":"ddias","provider":"Symfony\\Component\\Security\\Core\\User\\InMemoryUserProvider"} []
[2017-03-08 15:48:24] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
[2017-03-08 15:48:24] security.DEBUG: Access denied, the user is not fully authenticated; redirecting to authentication entry point. {"exception":"[object] (Symfony\\Component\\Security\\Core\\Exception\\AccessDeniedException(code: 403): Access Denied. at /var/www/html/vendor/symfony/symfony/src/Symfony/Component/Security/Http/Firewall/AccessListener.php:70)"} []
[2017-03-08 15:48:24] security.DEBUG: Calling Authentication entry point. [] []
[2017-03-08 15:48:24] request.INFO: Matched route "login". {"route_parameters":{"_controller":"AppBundle\\Controller\\UserController::loginAction","_route":"login"},"request_uri":"http://noc/app_dev.php/login"} []
[2017-03-08 15:48:24] php.INFO: The Symfony\Component\Ldap\LdapClient class is deprecated since version 3.1 and will be removed in 4.0. Use the Ldap class directly instead. {"type":16384,"file":"/var/www/html/vendor/symfony/ldap/LdapClient.php","line":14,"level":28928,"stack":[{"function":"handleError","class":"Symfony\\Component\\Debug\\ErrorHandler","type":"->"},{"file":"/var/www/html/vendor/symfony/ldap/LdapClient.php","line":14,"function":"trigger_error"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/Debug/DebugClassLoader.php","line":169,"args":["/var/www/html/vendor/symfony/ldap/LdapClient.php"],"function":"require_once"},{"function":"loadClass","class":"Symfony\\Component\\Debug\\DebugClassLoader","type":"->"},{"file":"/var/www/html/app/cache/dev/appDevDebugProjectContainer.php","line":1534,"function":"spl_autoload_call"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php","line":314,"function":"getLdapService","class":"appDevDebugProjectContainer","type":"->"},{"file":"/var/www/html/app/cache/dev/appDevDebugProjectContainer.php","line":3612,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php","line":314,"function":"getSecurity_User_Provider_Concrete_MyLdapService","class":"appDevDebugProjectContainer","type":"->"},{"file":"/var/www/html/app/cache/dev/appDevDebugProjectContainer.php","line":3540,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php","line":314,"function":"getSecurity_Authentication_ManagerService","class":"appDevDebugProjectContainer","type":"->"},{"file":"/var/www/html/app/cache/dev/appDevDebugProjectContainer.php","line":2131,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php","line":314,"function":"getSecurity_Firewall_Map_Context_MainService","class":"appDevDebugProjectContainer","type":"->"},{"file":"/var/www/html/app/cache/dev/classes.php","line":2986,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->"},{"file":"/var/www/html/app/cache/dev/classes.php","line":2628,"function":"getListeners","class":"Symfony\\Bundle\\SecurityBundle\\Security\\FirewallMap","type":"->"},{"function":"onKernelRequest","class":"Symfony\\Component\\Security\\Http\\Firewall","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php","line":61,"function":"call_user_func"},{"function":"__invoke","class":"Symfony\\Component\\EventDispatcher\\Debug\\WrappedListener","type":"->"},{"file":"/var/www/html/app/cache/dev/classes.php","line":1863,"function":"call_user_func"},{"file":"/var/www/html/app/cache/dev/classes.php","line":1778,"function":"doDispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php","line":140,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php","line":125,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php","line":64,"function":"handleRaw","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php","line":69,"function":"handle","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php","line":185,"function":"handle","class":"Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel","type":"->"},{"file":"/var/www/html/web/app_dev.php","line":28,"function":"handle","class":"Symfony\\Component\\HttpKernel\\Kernel","type":"->"}]} []
[2017-03-08 15:48:24] security.INFO: Populated the TokenStorage with an anonymous Token. [] []
[2017-03-08 15:48:25] request.INFO: Matched route "_wdt". {"route_parameters":{"_controller":"web_profiler.controller.profiler:toolbarAction","token":"11e2b4","_route":"_wdt"},"request_uri":"http://noc/app_dev.php/_wdt/11e2b4"} []
[2017-03-08 15:48:25] php.INFO: The Symfony\Component\Ldap\LdapClient class is deprecated since version 3.1 and will be removed in 4.0. Use the Ldap class directly instead. {"type":16384,"file":"/var/www/html/vendor/symfony/ldap/LdapClient.php","line":14,"level":28928,"stack":[{"function":"handleError","class":"Symfony\\Component\\Debug\\ErrorHandler","type":"->"},{"file":"/var/www/html/vendor/symfony/ldap/LdapClient.php","line":14,"function":"trigger_error"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/Debug/DebugClassLoader.php","line":169,"args":["/var/www/html/vendor/symfony/ldap/LdapClient.php"],"function":"require_once"},{"function":"loadClass","class":"Symfony\\Component\\Debug\\DebugClassLoader","type":"->"},{"file":"/var/www/html/app/cache/dev/appDevDebugProjectContainer.php","line":1534,"function":"spl_autoload_call"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php","line":314,"function":"getLdapService","class":"appDevDebugProjectContainer","type":"->"},{"file":"/var/www/html/app/cache/dev/appDevDebugProjectContainer.php","line":3612,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php","line":314,"function":"getSecurity_User_Provider_Concrete_MyLdapService","class":"appDevDebugProjectContainer","type":"->"},{"file":"/var/www/html/app/cache/dev/appDevDebugProjectContainer.php","line":3540,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php","line":314,"function":"getSecurity_Authentication_ManagerService","class":"appDevDebugProjectContainer","type":"->"},{"file":"/var/www/html/app/cache/dev/appDevDebugProjectContainer.php","line":2044,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php","line":314,"function":"getSecurity_AuthorizationCheckerService","class":"appDevDebugProjectContainer","type":"->"},{"file":"/var/www/html/app/cache/dev/appDevDebugProjectContainer.php","line":3134,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php","line":314,"function":"getTwigService","class":"appDevDebugProjectContainer","type":"->"},{"file":"/var/www/html/app/cache/dev/appDevDebugProjectContainer.php","line":3389,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Container.php","line":314,"function":"getWebProfiler_Controller_ProfilerService","class":"appDevDebugProjectContainer","type":"->"},{"file":"/var/www/html/app/cache/dev/classes.php","line":2553,"function":"get","class":"Symfony\\Component\\DependencyInjection\\Container","type":"->"},{"file":"/var/www/html/app/cache/dev/classes.php","line":2170,"function":"createController","class":"Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerResolver","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Controller/TraceableControllerResolver.php","line":46,"function":"getController","class":"Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php","line":132,"function":"getController","class":"Symfony\\Component\\HttpKernel\\Controller\\TraceableControllerResolver","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php","line":64,"function":"handleRaw","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php","line":69,"function":"handle","class":"Symfony\\Component\\HttpKernel\\HttpKernel","type":"->"},{"file":"/var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php","line":185,"function":"handle","class":"Symfony\\Component\\HttpKernel\\DependencyInjection\\ContainerAwareHttpKernel","type":"->"},{"file":"/var/www/html/web/app_dev.php","line":28,"function":"handle","class":"Symfony\\Component\\HttpKernel\\Kernel","type":"->"}]} []

【问题讨论】:

  • 您能发布完整的 securty.yml 文件吗?您的访问控制部分是什么样的?日志中是否有任何消息?
  • @ChadSikorra 发布完整的安全文件和日志
  • 你在使用你没有忘记 dn_string 中的域前缀吗?像 dn_string: 'domain\{username}' 吗?类似的东西。我建议你先用纯 php 函数测试 ldap,一步一步,这样你就可以找出问题所在。我遇到了同样的问题,必须做很多尝试/错误才能获得有效的配置。
  • @COil 查询 AD 没有问题,它工作正常并返回用户信息。问题是创建会话并保持登录状态
  • 是否添加:login: pattern: ^/login$ anonymous: ~ 到您的防火墙(在 main 部分帮助之后(匿名和模式在单独的行上)?

标签: php symfony authentication active-directory ldap


【解决方案1】:

好的,看来我找到了问题...

删除 in_memory 提供程序解决它...如果您在我的日志中的第 9 行注意到,我的用户未找到,然后在第 10 行,TokenStorage 再次填充了匿名令牌。

所以 LDAP 提供程序让我登录,而 in_memory 提供程序让我退出。

【讨论】:

    猜你喜欢
    • 2016-03-25
    • 2023-03-21
    • 2016-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-03
    • 2011-09-23
    相关资源
    最近更新 更多