Symfony2 img/LdapBundle错误的凭证错误 [英] Symfony2 img/LdapBundle Bad credentials error

查看:59
本文介绍了Symfony2 img/LdapBundle错误的凭证错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Symfony2的新手,正在尝试使用上述捆绑包连接到ldap;但是我一直收到错误的凭据错误.我不知道为什么.

I am new to Symfony2 and am trying to connect to ldap using the above bundle; however i keep getting Bad credentials errors. I cannot figure out why..

我的Security.yml文件如下:

My Security.yml file looks like this:

security:
firewalls:
    restricted_area:
        pattern:          ^/login
        anonymous:        ~
        imag_ldap:
            check_path: login_check
            login_path: login
            csrf_provider: form.csrf_provider
            intention: authenticate
            provider: ldap
        logout:
            path:           /logout
            target:         /

providers:
    ldap:
        id: imag_ldap.security.user.provider

encoders:
    IMAG\LdapBundle\User\LdapUser: plaintext

access_control:
    - { path: ^/login,          roles: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/,               roles: IS_AUTHENTICATED_FULLY }

imag_ldap:
client:
    host: someip
    port: 389
#    version: 3 # Optional
#    username:  
#    password: 
#    network_timeout:
#    referrals_enabled:
#    bind_username_before:
#    skip_roles:

user:
    base_dn: dc=some, dc=dom, dc=ain
#    filter: null
    name_attribute: uid
#    attributes:

role:
    base_dn: dc=some, dc=dom, dc=ain
#    filter: null #Optional
    name_attribute: cn
    user_attribute: member
#    user_id: [ dn or username ] #Default dn

我的路线如下:

login:
    pattern:              /login
    defaults:             { _controller: IMAGLdapBundle:Default:login }
    requirements:
    _method:            GET

login_check:
    pattern:              /login_check

logout:
    pattern:              /logout

我似乎无法测试其是否真正连接,但是当我尝试转到http://domain/app_dev.php/check_login时,出现以下错误:

I cant seem to test if its actually connecting but when i try to go to http://domain/app_dev.php/check_login i get the following error:

Unable to find the controller for path "/login_check". Maybe you forgot to add the matching route in your routing configuration?

我想我需要为/login_check添加一条路线,但不确定.如果可以的话,如何调用ldap连接?

Im guessing i need to add a route for /login_check but not sure. and if so how to i call the ldap connection?

编辑

好的,我想我需要手握.. 我已将security.yml更改为以下内容:

OK I think I need hand holding.. I have changed my security.yml to the following:

security:
    firewalls:
        login_firewall:
            pattern:    ^/login$
            anonymous:  ~
            imag_ldap:
                check_path: login_check
                login_path: login
                csrf_provider: form.csrf_provider
                intention: authenticate
                provider: ldap
            logout:
                path:           /logout
                target:         /
        restricted_area:
            pattern:          ^/
            #anonymous:        ~ 
    providers:
        ldap:
           id: imag_ldap.security.user.provider

    encoders:
        IMAG\LdapBundle\User\LdapUser: plaintext

    access_control:
        - { path: ^/login,          roles: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/,               roles: IS_AUTHENTICATED_FULLY }

但现在我收到以下错误: LogicException: No authentication listener registered for firewall "restricted_area".

but now im getting the following error: LogicException: No authentication listener registered for firewall "restricted_area".

所以我尝试了以下操作:

SO i tried the following:

security:
    firewalls:
        login_firewall:
            pattern:    ^/login$
            anonymous:  ~
            imag_ldap:
                check_path: login_check
                login_path: login
                csrf_provider: form.csrf_provider
                intention: authenticate
                provider: ldap
            logout:
                path:           /logout
                target:         /
        restricted_area:
            pattern:          ^/
            #anonymous:        ~ 
            imag_ldap:
                check_path: login_check
                login_path: login
                csrf_provider: form.csrf_provider
                intention: authenticate
                provider: ldap
            logout:
                path:           /logout
                target:         /

但这会导致重定向循环.

but this causes a redirect loop.

编辑2 如评论中所述,此问题的第二部分是一个单独的问题,可以在这里找到:

Edit 2 As mentioned in the comments the second part of this is a separate issue, which can be found here:Symfony 2 Security.yml redirect loop and LogicException issues

推荐答案

您还需要将login_check放在防火墙后面:

You need to put login_check behind your firewall as well:

firewalls:
    restricted_area:
        pattern: ^/
        #anonymous: ~
    login_firewall:
            pattern:    ^/login$
            anonymous:  ~

顺便说一句,这是避免常见陷阱部分中列出的常见陷阱.

有些类似的东西可能会在此处为您提供帮助.

There is something similar that might help you here.

这篇关于Symfony2 img/LdapBundle错误的凭证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆